|
| 1 | +name: release-binaries |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "bin-v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: release-binaries-${{ github.ref }} |
| 13 | + cancel-in-progress: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-sign-publish: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + timeout-minutes: 30 |
| 19 | + environment: binary-release |
| 20 | + permissions: |
| 21 | + contents: write |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + persist-credentials: false |
| 27 | + - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5 |
| 28 | + with: |
| 29 | + go-version-file: go.mod |
| 30 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 31 | + with: |
| 32 | + node-version: "24.16.0" |
| 33 | + - name: Require protected, annotated, verified tag and release pin |
| 34 | + env: |
| 35 | + GH_TOKEN: ${{ github.token }} |
| 36 | + run: | |
| 37 | + set -euo pipefail |
| 38 | + tag_ref="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$GITHUB_REF_NAME" --jq .object.sha)" |
| 39 | + tag_type="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$GITHUB_REF_NAME" --jq .object.type)" |
| 40 | + [[ "$tag_type" == "tag" ]] || { echo "binary release tag must be annotated" >&2; exit 1; } |
| 41 | + verified="$(gh api "repos/$GITHUB_REPOSITORY/git/tags/$tag_ref" --jq .verification.verified)" |
| 42 | + [[ "$verified" == "true" ]] || { echo "binary release tag signature is not GitHub-verified" >&2; exit 1; } |
| 43 | + target="$(gh api "repos/$GITHUB_REPOSITORY/git/tags/$tag_ref" --jq .object.sha)" |
| 44 | + git merge-base --is-ancestor "$target" origin/main |
| 45 | + [[ "$(tr -d '\r\n' < packages/cli/BINARY_RELEASE)" == "$GITHUB_REF_NAME" ]] || { |
| 46 | + echo "packages/cli/BINARY_RELEASE does not match $GITHUB_REF_NAME" >&2 |
| 47 | + exit 1 |
| 48 | + } |
| 49 | + - name: Build deterministic cross-platform artifacts |
| 50 | + run: node scripts/build-release-binaries.mjs --out dist/binaries |
| 51 | + - name: Require complete 36-artifact matrix |
| 52 | + run: | |
| 53 | + set -euo pipefail |
| 54 | + expected="$(node scripts/build-release-binaries.mjs --list | sort)" |
| 55 | + actual="$(find dist/binaries -maxdepth 1 -type f ! -name checksums.txt -printf '%f\n' | sort)" |
| 56 | + [[ "$actual" == "$expected" ]] || { |
| 57 | + diff -u <(printf '%s\n' "$expected") <(printf '%s\n' "$actual") |
| 58 | + exit 1 |
| 59 | + } |
| 60 | + - name: Sign checksum manifest with pinned release key |
| 61 | + env: |
| 62 | + CAVEMAN_BINARY_SIGNING_PRIVATE_KEY_PEM: ${{ secrets.CAVEMAN_BINARY_SIGNING_PRIVATE_KEY_PEM }} |
| 63 | + run: >- |
| 64 | + node scripts/sign-binary-checksums.mjs |
| 65 | + dist/binaries/checksums.txt |
| 66 | + dist/binaries/checksums.txt.keysig |
| 67 | + packages/cli/BINARY_SIGNING_PUBKEY.pub |
| 68 | + - name: Publish binary-only release |
| 69 | + env: |
| 70 | + GH_TOKEN: ${{ github.token }} |
| 71 | + run: | |
| 72 | + set -euo pipefail |
| 73 | + if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then |
| 74 | + echo "release $GITHUB_REF_NAME already exists; refusing overwrite" >&2 |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | + gh release create "$GITHUB_REF_NAME" dist/binaries/* \ |
| 78 | + --repo "$GITHUB_REPOSITORY" \ |
| 79 | + --title "$GITHUB_REF_NAME" \ |
| 80 | + --notes "Signed Caveman runtime companions for macOS, Linux, and Windows." |
0 commit comments