refactor(clippy): extract complex block from if condition in create_p… #495
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: "Release tag to upload assets to (e.g., v0.1.1)" | |
| required: true | |
| type: string | |
| env: | |
| CARGO_TERM_COLOR: always | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release-please: | |
| name: Release Please | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_created: ${{ steps.release.outputs.release_created }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| steps: | |
| - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 | |
| id: release | |
| build: | |
| name: Build (Linux) | |
| needs: release-please | |
| if: >- | |
| always() && | |
| (needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable | |
| - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| - name: Build | |
| run: cargo build --release --verbose | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Prepare release assets | |
| run: | | |
| set -euo pipefail | |
| cp target/release/ado-aw target/release/ado-aw-linux-x64 | |
| - name: Set up Node.js for ado-script bundle | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: scripts/ado-script/package-lock.json | |
| - name: Build ado-script TypeScript bundle (gate.js) | |
| working-directory: scripts/ado-script | |
| run: | | |
| npm ci | |
| npm run build | |
| # `npm run build` runs codegen + ncc and outputs gate.js + import.js. | |
| - name: Package ado-script bundle | |
| run: | | |
| set -euo pipefail | |
| cd scripts | |
| zip -r ../ado-script.zip ado-script/gate.js ado-script/import.js | |
| - name: Upload release assets | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ needs.release-please.outputs.tag_name || github.event.inputs.tag_name }}" | |
| gh release upload "$TAG" \ | |
| target/release/ado-aw-linux-x64 \ | |
| ado-script.zip \ | |
| --clobber | |
| build-windows: | |
| name: Build (Windows) | |
| needs: release-please | |
| if: >- | |
| always() && | |
| (needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch') | |
| runs-on: windows-2022 | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable | |
| - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| - name: Build | |
| run: cargo build --release --verbose | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Prepare release assets | |
| run: | | |
| Copy-Item target/release/ado-aw.exe target/release/ado-aw-windows-x64.exe | |
| - name: Upload release assets | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| $TAG = "${{ needs.release-please.outputs.tag_name || github.event.inputs.tag_name }}" | |
| gh release upload "$TAG" ` | |
| target/release/ado-aw-windows-x64.exe ` | |
| --clobber | |
| build-macos-arm64: | |
| name: Build (macOS arm64) | |
| needs: release-please | |
| if: >- | |
| always() && | |
| (needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch') | |
| runs-on: macos-14 | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable | |
| - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| - name: Build | |
| run: cargo build --release --verbose | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Prepare release assets | |
| run: | | |
| set -euo pipefail | |
| cd target/release | |
| cp ado-aw ado-aw-darwin-arm64 | |
| - name: Upload release assets | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ needs.release-please.outputs.tag_name || github.event.inputs.tag_name }}" | |
| gh release upload "$TAG" \ | |
| target/release/ado-aw-darwin-arm64 \ | |
| --clobber | |
| checksums: | |
| name: Generate Checksums | |
| needs: [release-please, build, build-windows, build-macos-arm64] | |
| if: >- | |
| always() && | |
| (needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch') && | |
| needs.build.result == 'success' && | |
| needs.build-windows.result == 'success' && | |
| needs.build-macos-arm64.result == 'success' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Download release binaries and generate checksums | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| TAG="${{ needs.release-please.outputs.tag_name || github.event.inputs.tag_name }}" | |
| gh release download "$TAG" \ | |
| --pattern "ado-aw-*" \ | |
| --pattern "ado-script.zip" \ | |
| --repo "${{ github.repository }}" | |
| test -f ado-aw-linux-x64 || { echo "Missing ado-aw-linux-x64"; exit 1; } | |
| test -f ado-aw-windows-x64.exe || { echo "Missing ado-aw-windows-x64.exe"; exit 1; } | |
| test -f ado-aw-darwin-arm64 || { echo "Missing ado-aw-darwin-arm64"; exit 1; } | |
| test -f ado-script.zip || { echo "Missing ado-script.zip"; exit 1; } | |
| sha256sum ado-aw-linux-x64 ado-aw-windows-x64.exe ado-aw-darwin-arm64 ado-script.zip > checksums.txt | |
| - name: Upload checksums | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ needs.release-please.outputs.tag_name || github.event.inputs.tag_name }}" | |
| gh release upload "$TAG" checksums.txt --clobber --repo "${{ github.repository }}" |