|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + # GitHub Actions tag filters are glob patterns (per the filter-pattern |
| 6 | + # cheat sheet), not regex. `v*.*.*` matches `v<digits>.<digits>.<digits>` |
| 7 | + # tags like `v1.0.0` without relying on the `+` quantifier, which is easy |
| 8 | + # to misread as a literal `+`. |
| 9 | + tags: ["v*.*.*"] |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + verify: |
| 16 | + name: Verify Release Tag |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v6.0.2 |
| 20 | + - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 |
| 21 | + with: |
| 22 | + toolchain: 1.94.1 |
| 23 | + components: clippy, rustfmt |
| 24 | + - uses: Swatinem/rust-cache@v2.8.1 |
| 25 | + - uses: taiki-e/install-action@v2 |
| 26 | + with: |
| 27 | + tool: cargo-nextest |
| 28 | + - uses: taiki-e/install-action@v2 |
| 29 | + with: |
| 30 | + tool: cargo-deny |
| 31 | + - uses: taiki-e/install-action@v2 |
| 32 | + with: |
| 33 | + tool: cargo-shear |
| 34 | + - name: Check formatting |
| 35 | + run: cargo fmt --all --check |
| 36 | + - name: Clippy |
| 37 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 38 | + - name: Cargo Deny |
| 39 | + run: cargo deny check |
| 40 | + - name: Unused dependencies |
| 41 | + run: cargo shear |
| 42 | + - name: Nextest |
| 43 | + run: cargo nextest run --all-features |
| 44 | + |
| 45 | + build: |
| 46 | + name: Build (${{ matrix.target }}) |
| 47 | + needs: verify |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + permissions: |
| 50 | + contents: write |
| 51 | + attestations: write |
| 52 | + id-token: write |
| 53 | + strategy: |
| 54 | + fail-fast: false |
| 55 | + matrix: |
| 56 | + # macOS-only by design for the initial public release scope. |
| 57 | + include: |
| 58 | + - target: x86_64-apple-darwin |
| 59 | + os: macos-latest |
| 60 | + - target: aarch64-apple-darwin |
| 61 | + os: macos-latest |
| 62 | + env: |
| 63 | + REF_NAME: ${{ github.ref_name }} |
| 64 | + TARGET: ${{ matrix.target }} |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v6.0.2 |
| 67 | + # Pinned to a specific SHA (was dtolnay/rust-toolchain@master, 2026-04-15) |
| 68 | + # to avoid a supply-chain vector under `attestations: write` + `id-token: write`. |
| 69 | + - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 |
| 70 | + with: |
| 71 | + toolchain: 1.94.1 |
| 72 | + targets: ${{ matrix.target }} |
| 73 | + - uses: Swatinem/rust-cache@v2.8.1 |
| 74 | + - name: Build |
| 75 | + shell: bash |
| 76 | + # `--locked` ensures the release binary is built against the exact |
| 77 | + # dependency graph captured in Cargo.lock; a tag build must not silently |
| 78 | + # resolve a different graph if a manifest changed. |
| 79 | + run: cargo build --release --locked --target "$TARGET" -p gather-step |
| 80 | + - name: Smoke test binary — version |
| 81 | + shell: bash |
| 82 | + run: "./target/${TARGET}/release/gather-step --version" |
| 83 | + - name: Smoke test binary — help |
| 84 | + shell: bash |
| 85 | + run: "./target/${TARGET}/release/gather-step --help" |
| 86 | + - name: Smoke test binary — index + status against embedded fixture |
| 87 | + shell: bash |
| 88 | + run: | |
| 89 | + set -euo pipefail |
| 90 | + fixture=$(mktemp -d) |
| 91 | + mkdir -p "$fixture/repos/smoke/src" |
| 92 | + cat > "$fixture/gather-step.config.yaml" <<'YAML' |
| 93 | + repos: |
| 94 | + - name: smoke |
| 95 | + path: repos/smoke |
| 96 | + indexing: |
| 97 | + workspace_concurrency: 1 |
| 98 | + YAML |
| 99 | + cat > "$fixture/repos/smoke/package.json" <<'JSON' |
| 100 | + { "name": "smoke", "dependencies": { "@nestjs/core": "^11.0.0" } } |
| 101 | + JSON |
| 102 | + cat > "$fixture/repos/smoke/src/smoke.ts" <<'TS' |
| 103 | + export function smokeFn(): number { return 1; } |
| 104 | + TS |
| 105 | + "./target/${TARGET}/release/gather-step" \ |
| 106 | + --workspace "$fixture" --json index |
| 107 | + "./target/${TARGET}/release/gather-step" \ |
| 108 | + --workspace "$fixture" --json status |
| 109 | + rm -rf "$fixture" |
| 110 | + - name: Package archive |
| 111 | + shell: bash |
| 112 | + run: | |
| 113 | + mkdir -p dist |
| 114 | + cp "target/${TARGET}/release/gather-step" "dist/gather-step-${TARGET}" |
| 115 | + tar -C dist -czf "dist/gather-step-${REF_NAME}-${TARGET}.tar.gz" "gather-step-${TARGET}" |
| 116 | + - name: Upload archive artifact |
| 117 | + uses: actions/upload-artifact@v7.0.1 |
| 118 | + with: |
| 119 | + name: gather-step-${{ matrix.target }} |
| 120 | + path: dist/gather-step-${{ github.ref_name }}-${{ matrix.target }}.tar.gz |
| 121 | + # Attest the archive so users can verify the downloaded release bundle. |
| 122 | + - name: Attest archive provenance |
| 123 | + uses: actions/attest-build-provenance@v4.1.0 |
| 124 | + with: |
| 125 | + subject-path: dist/gather-step-${{ github.ref_name }}-${{ matrix.target }}.tar.gz |
| 126 | + # Attest the binary directly so `gh attestation verify` works on the |
| 127 | + # extracted binary too, not only on the archive bundle. |
| 128 | + - name: Attest binary provenance |
| 129 | + uses: actions/attest-build-provenance@v4.1.0 |
| 130 | + with: |
| 131 | + subject-path: dist/gather-step-${{ matrix.target }} |
| 132 | + |
| 133 | + release: |
| 134 | + name: Publish Release |
| 135 | + needs: build |
| 136 | + runs-on: ubuntu-latest |
| 137 | + permissions: |
| 138 | + contents: write |
| 139 | + steps: |
| 140 | + - name: Download build artifacts |
| 141 | + uses: actions/download-artifact@v5 |
| 142 | + with: |
| 143 | + path: dist |
| 144 | + merge-multiple: true |
| 145 | + - name: Publish GitHub release |
| 146 | + uses: softprops/action-gh-release@v2.5.0 |
| 147 | + with: |
| 148 | + draft: true |
| 149 | + files: dist/*.tar.gz |
0 commit comments