name: Release Binary # PR builds are covered by the gate's check/test proof; release packaging is a # release-lane concern. on: push: tags: - 'v*' workflow_dispatch: permissions: contents: read concurrency: group: release-binary-${{ github.ref }} cancel-in-progress: false jobs: package: name: Build release asset runs-on: ubuntu-latest timeout-minutes: 20 permissions: contents: read env: ASSET_NAME: ub-review-x86_64-unknown-linux-gnu.tar.gz TARGET_DIR: ub-review-x86_64-unknown-linux-gnu steps: - uses: actions/checkout@v5 - uses: dtolnay/rust-toolchain@master with: toolchain: 1.95.0 - name: Build release binary shell: bash run: | set -euo pipefail cargo build --locked --release --bin ub-review test -x target/release/ub-review target/release/ub-review --help >/dev/null - name: Package release asset shell: bash run: | set -euo pipefail mkdir -p "dist/$TARGET_DIR" install -m 0755 target/release/ub-review "dist/$TARGET_DIR/ub-review" tar -czf "dist/$ASSET_NAME" -C "dist/$TARGET_DIR" ub-review sha256sum "dist/$ASSET_NAME" > "dist/$ASSET_NAME.sha256" tar -tzf "dist/$ASSET_NAME" | grep -Fx ub-review test -s "dist/$ASSET_NAME.sha256" - name: Write immutable release candidate receipt shell: bash env: TOOLCHAIN: 1.95.0 run: | set -euo pipefail candidate_sha="$(git rev-parse HEAD)" archive_sha256="$(awk 'NF >= 1 {print $1; exit}' "dist/$ASSET_NAME.sha256")" jq -n \ --arg schema "ub-review.release_candidate.v1" \ --arg head_sha "$candidate_sha" \ --arg ref "$GITHUB_REF" \ --arg tag "${GITHUB_REF_NAME:-}" \ --arg toolchain "$TOOLCHAIN" \ --arg asset "$ASSET_NAME" \ --arg checksum_asset "$ASSET_NAME.sha256" \ --arg archive_sha256 "$archive_sha256" \ '{schema:$schema,head_sha:$head_sha,ref:$ref,tag:$tag,toolchain:$toolchain,asset:$asset,checksum_asset:$checksum_asset,archive_sha256:$archive_sha256}' \ > dist/release-candidate.json test "$(jq -r '.head_sha' dist/release-candidate.json)" = "$candidate_sha" - name: Upload workflow artifact uses: actions/upload-artifact@v7 with: name: ub-review-linux-x64-release path: | dist/${{ env.ASSET_NAME }} dist/${{ env.ASSET_NAME }}.sha256 dist/release-candidate.json if-no-files-found: error retention-days: 14 publish: name: Publish release asset needs: package if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest timeout-minutes: 10 permissions: contents: write env: ASSET_NAME: ub-review-x86_64-unknown-linux-gnu.tar.gz steps: - uses: actions/checkout@v5 - name: Validate release tag id: tag shell: bash run: | set -euo pipefail tag="${GITHUB_REF_NAME:-}" if [[ ! "$tag" =~ ^v[0-9][A-Za-z0-9._-]*$ ]]; then echo "::error::release tag must start with v plus a digit and contain only letters, numbers, dot, underscore, or dash" exit 1 fi echo "tag=$tag" >> "$GITHUB_OUTPUT" - name: Download packaged release asset uses: actions/download-artifact@v7 with: name: ub-review-linux-x64-release path: dist - name: Validate immutable release candidate receipt shell: bash env: TAG: ${{ steps.tag.outputs.tag }} run: | set -euo pipefail manifest="dist/release-candidate.json" test -s "$manifest" test "$(jq -r '.schema' "$manifest")" = "ub-review.release_candidate.v1" test "$(jq -r '.head_sha' "$manifest")" = "$GITHUB_SHA" test "$(jq -r '.ref' "$manifest")" = "refs/tags/$TAG" test "$(jq -r '.tag' "$manifest")" = "$TAG" test "$(jq -r '.toolchain' "$manifest")" = "1.95.0" test "$(jq -r '.asset' "$manifest")" = "$ASSET_NAME" test "$(jq -r '.checksum_asset' "$manifest")" = "$ASSET_NAME.sha256" archive_sha256="$(awk 'NF >= 1 {print $1; exit}' "dist/$ASSET_NAME.sha256")" test "$(jq -r '.archive_sha256' "$manifest")" = "$archive_sha256" sha256sum -c "dist/$ASSET_NAME.sha256" - name: Install pinned Rust toolchain shell: bash run: | set -euo pipefail rustup toolchain install 1.95.0 --profile minimal - name: Render release notes shell: bash env: TAG: ${{ steps.tag.outputs.tag }} run: | set -euo pipefail cargo +1.95.0 run --locked --package xtask -- render-release-notes --tag "$TAG" --output dist/release-notes.md - name: Publish GitHub release asset shell: bash env: GH_TOKEN: ${{ github.token }} TAG: ${{ steps.tag.outputs.tag }} run: | set -euo pipefail if gh release view "$TAG" >/dev/null 2>&1; then gh release upload "$TAG" "dist/$ASSET_NAME" "dist/$ASSET_NAME.sha256" --clobber else gh release create "$TAG" "dist/$ASSET_NAME" "dist/$ASSET_NAME.sha256" \ --verify-tag \ --title "$TAG" \ --notes-file dist/release-notes.md fi