codescythe_cli: v0.10.1 #30
Workflow file for this run
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: Codescythe CLI Release | |
| on: | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: "Dry run (build and verify only, no upload)" | |
| type: boolean | |
| required: false | |
| default: true | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.release.tag_name || github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Build release binaries | |
| runs-on: ubuntu-24.04-16core | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Setup Bazel | |
| uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 | |
| with: | |
| bazelisk-cache: true | |
| disk-cache: ${{ github.workflow }}-release-binaries | |
| repository-cache: true | |
| - name: Build binaries | |
| run: | | |
| set -euo pipefail | |
| bazel build \ | |
| //crates/codescythe_cli:release_binary_darwin_arm64 \ | |
| //crates/codescythe_cli:release_binary_linux_amd64 \ | |
| //crates/codescythe_cli:release_binary_linux_arm64 | |
| mkdir -p artifacts | |
| copy_artifact() { | |
| local target="$1" | |
| local output="$2" | |
| local binary_path | |
| binary_path="$(bazel cquery --output=files "$target" | tail -n 1)" | |
| cp "$binary_path" "artifacts/$output" | |
| chmod +x "artifacts/$output" | |
| } | |
| copy_artifact //crates/codescythe_cli:release_binary_darwin_arm64 codescythe-darwin-arm64 | |
| copy_artifact //crates/codescythe_cli:release_binary_linux_amd64 codescythe-linux-amd64 | |
| copy_artifact //crates/codescythe_cli:release_binary_linux_arm64 codescythe-linux-arm64 | |
| - name: Upload macOS ARM64 artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: codescythe-darwin-arm64 | |
| path: artifacts/codescythe-darwin-arm64 | |
| retention-days: 7 | |
| - name: Upload Linux AMD64 artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: codescythe-linux-amd64 | |
| path: artifacts/codescythe-linux-amd64 | |
| retention-days: 7 | |
| - name: Upload Linux ARM64 artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: codescythe-linux-arm64 | |
| path: artifacts/codescythe-linux-arm64 | |
| retention-days: 7 | |
| verify: | |
| name: Verify ${{ matrix.name }} | |
| needs: build | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: macOS ARM64 | |
| runner: macos-15 | |
| artifact: codescythe-darwin-arm64 | |
| binary: codescythe-darwin-arm64 | |
| - name: Linux AMD64 | |
| runner: ubuntu-24.04-16core | |
| artifact: codescythe-linux-amd64 | |
| binary: codescythe-linux-amd64 | |
| - name: Linux ARM64 | |
| runner: ubuntu-24.04-arm | |
| artifact: codescythe-linux-arm64 | |
| binary: codescythe-linux-arm64 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Download binary | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: artifacts | |
| - name: Smoke test binary | |
| run: | | |
| set -euo pipefail | |
| binary="artifacts/${{ matrix.binary }}" | |
| chmod +x "$binary" | |
| file "$binary" | |
| "$binary" --version | |
| "$binary" --help | |
| set +e | |
| output="$("$binary" --json -C tests/fixtures/knip-export-basics)" | |
| status="$?" | |
| set -e | |
| if [ "$status" -ne 1 ]; then | |
| echo "expected fixture analysis to exit with 1, got $status" >&2 | |
| echo "$output" | |
| exit 1 | |
| fi | |
| echo "$output" | grep '"dangling.ts"' | |
| if [ "${{ runner.os }}" = "Linux" ]; then | |
| ldd_output="$(ldd "$binary" 2>&1 || true)" | |
| echo "$ldd_output" | |
| if echo "$ldd_output" | grep -Eq "not a dynamic executable|statically linked"; then | |
| echo "$binary is static" | |
| elif strings "$binary" | grep -q 'GLIBC_'; then | |
| echo "$binary unexpectedly references glibc symbols" >&2 | |
| exit 1 | |
| else | |
| echo "$binary has no GLIBC_ symbol references" | |
| fi | |
| fi | |
| release: | |
| name: Upload release assets | |
| needs: | |
| - build | |
| - verify | |
| runs-on: ubuntu-24.04-16core | |
| permissions: | |
| contents: write | |
| if: ${{ (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'codescythe_cli_v')) || (github.event_name == 'workflow_dispatch' && inputs.dry_run == false && startsWith(github.ref_name, 'codescythe_cli_v')) }} | |
| steps: | |
| - name: Download release artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| with: | |
| path: release | |
| - name: Organize artifacts | |
| run: | | |
| set -euo pipefail | |
| mkdir -p release-assets | |
| for binary in codescythe-darwin-arm64 codescythe-linux-amd64 codescythe-linux-arm64; do | |
| cp "release/$binary/$binary" "release-assets/$binary" | |
| chmod +x "release-assets/$binary" | |
| done | |
| rm -rf release | |
| mv release-assets release | |
| - name: Generate checksums | |
| run: | | |
| set -euo pipefail | |
| cd release | |
| shasum -a 256 codescythe-* > checksums.txt | |
| cat checksums.txt | |
| - name: List release artifacts | |
| run: | | |
| ls -lh release | |
| echo "---" | |
| cat release/checksums.txt | |
| - name: Upload release assets | |
| env: | |
| GH_REPO: ${{ github.repository }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RELEASE_TAG: ${{ github.event.release.tag_name || github.ref_name }} | |
| run: | | |
| gh release upload "$RELEASE_TAG" \ | |
| release/codescythe-darwin-arm64 \ | |
| release/codescythe-linux-amd64 \ | |
| release/codescythe-linux-arm64 \ | |
| release/checksums.txt \ | |
| --clobber |