name: Release on: workflow_run: workflows: ["Lint, Test & Build"] types: [completed] permissions: contents: read concurrency: group: release-${{ github.event.workflow_run.head_sha }} cancel-in-progress: false jobs: prepare: name: Build exact release artifacts if: >- github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_commit.message, 'chore(release):') runs-on: ubuntu-latest timeout-minutes: 90 outputs: artifact_name: ${{ steps.release.outputs.artifact_name }} cli_version: ${{ steps.release.outputs.cli_version }} release_version: ${{ steps.release.outputs.release_version }} source_sha: ${{ steps.release.outputs.source_sha }} steps: - name: Checkout the exact required-CI revision uses: actions/checkout@v4 with: ref: ${{ github.event.workflow_run.head_sha }} fetch-depth: 0 persist-credentials: false - name: Setup pinned Bun uses: oven-sh/setup-bun@v2 with: bun-version: 1.4.0 - name: Setup pinned Node uses: actions/setup-node@v4 with: node-version: 24.11.1 registry-url: https://registry.npmjs.org - name: Setup pinned npm run: npm install --global npm@11.6.2 - name: Setup pinned pnpm run: | corepack enable corepack prepare pnpm@10.20.0 --activate - name: Setup pinned Go uses: actions/setup-go@v5 with: go-version: 1.25.1 - name: Setup pinned Python uses: actions/setup-python@v5 with: python-version: 3.12.12 - name: Setup pinned uv uses: astral-sh/setup-uv@v5 with: version: 0.8.14 - name: Setup pinned Rust uses: dtolnay/rust-toolchain@1.89.0 - name: Setup pinned Java uses: actions/setup-java@v4 with: distribution: temurin java-version: 21.0.8 - name: Setup pinned Erlang and Elixir uses: erlef/setup-beam@v1 with: otp-version: 28.0.2 elixir-version: 1.19.0 - name: Setup pinned .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 10.0.100 - name: Setup pinned Crystal and Shards uses: crystal-lang/install-crystal@v1 with: crystal: "1.22.1" shards: "0.20.0" - name: Setup pinned Ruby and Bundler uses: ruby/setup-ruby@v1 with: ruby-version: "3.4.11" bundler: "4.0.21" - name: Setup pinned PHP and Composer uses: shivammathur/setup-php@v2 with: php-version: "8.5.12" extensions: dom, filter, json, libxml, mbstring, xmlwriter coverage: none tools: composer:2.10.3 - name: Install dependencies run: bun install --frozen-lockfile env: BTS_TELEMETRY: 0 - name: Resolve exact release identity id: release env: COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }} SOURCE_SHA: ${{ github.event.workflow_run.head_sha }} run: | set -euo pipefail [[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]] FIRST_LINE=${COMMIT_MESSAGE%%$'\n'*} RELEASE_VERSION=$(sed -nE 's/^chore\(release\): ([0-9]+\.[0-9]+\.[0-9]+)( .*)?$/\1/p' <<< "$FIRST_LINE") [[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] CLI_VERSION=$(jq -r '.version' apps/cli/package.json) [[ "$CLI_VERSION" == "$RELEASE_VERSION" ]] ARTIFACT_NAME="npm-release-${SOURCE_SHA}-${RELEASE_VERSION}" echo "artifact_name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" echo "cli_version=$CLI_VERSION" >> "$GITHUB_OUTPUT" echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT" echo "source_sha=$SOURCE_SHA" >> "$GITHUB_OUTPUT" - name: Build and pack every publishable workspace package env: BTS_TELEMETRY: 1 BFS_TELEMETRY_INGEST_URL: https://better-fullstack.dev/api/analytics/ingest ARTIFACT_DIR: ${{ runner.temp }}/npm-release RELEASE_VERSION: ${{ steps.release.outputs.release_version }} SOURCE_SHA: ${{ steps.release.outputs.source_sha }} run: >- bun run scripts/release/release-state.ts prepare --artifact-dir "$ARTIFACT_DIR" --release-version "$RELEASE_VERSION" --sha "$SOURCE_SHA" - name: Run complete generated-project proof env: PROOF_DIR: ${{ runner.temp }}/generated-project-proof BTS_TELEMETRY: 0 run: bun run testing/generated-project-proof.ts --output "$PROOF_DIR" - name: Run native Crystal HTTP proof env: PROOF_DIR: ${{ runner.temp }}/crystal-runtime-proof BTS_TELEMETRY: 0 run: bun run testing/crystal-runtime-proof.ts --output "$PROOF_DIR" - name: Run native Ruby HTTP proof env: PROOF_DIR: ${{ runner.temp }}/ruby-runtime-proof BTS_TELEMETRY: 0 run: bun run testing/ruby-runtime-proof.ts --output "$PROOF_DIR" - name: Run native PHP HTTP proof env: PHP_PROOF_DIR: ${{ runner.temp }}/php-runtime-proof BTS_TELEMETRY: 0 run: bun run testing/php-runtime-proof.ts --output "$PHP_PROOF_DIR" - name: Capture executable upgrade fixtures from exact package artifacts env: ARTIFACT_DIR: ${{ runner.temp }}/npm-release BTS_TELEMETRY: 0 run: >- bun run scripts/release/capture-release-fixture.ts --manifest "$ARTIFACT_DIR/release-manifest.json" --output "$ARTIFACT_DIR/upgrade-fixture.v1.json" - name: Qualify the previous executable release fixture env: ARTIFACT_DIR: ${{ runner.temp }}/npm-release BUN_INSTALL_CACHE_DIR: ${{ runner.temp }}/upgrade-qualification-bun-cache BUN_CONFIG_MAX_HTTP_REQUESTS: 16 GH_TOKEN: ${{ github.token }} REPOSITORY: ${{ github.repository }} run: >- bun run scripts/release/qualify-previous-release.ts --repository "$REPOSITORY" --target-manifest "$ARTIFACT_DIR/release-manifest.json" --output "$ARTIFACT_DIR/cross-version-qualification.v1.json" - name: Create SHA-bound verification receipt from clean evidence env: ARTIFACT_DIR: ${{ runner.temp }}/npm-release CI_CONCLUSION: ${{ github.event.workflow_run.conclusion }} CI_NAME: ${{ github.event.workflow_run.name }} CI_RUN_ID: ${{ github.event.workflow_run.id }} CI_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} PROOF_PATH: ${{ runner.temp }}/generated-project-proof/generated-project-proof.json SOURCE_SHA: ${{ steps.release.outputs.source_sha }} run: >- bun run scripts/release/release-receipt.ts create --manifest "$ARTIFACT_DIR/release-manifest.json" --fixture "$ARTIFACT_DIR/upgrade-fixture.v1.json" --qualification "$ARTIFACT_DIR/cross-version-qualification.v1.json" --proof "$PROOF_PATH" --output "$ARTIFACT_DIR/verification-receipt.v1.json" --sha "$SOURCE_SHA" --ci-run-id "$CI_RUN_ID" --ci-run-url "$CI_RUN_URL" --ci-name "$CI_NAME" --conclusion "$CI_CONCLUSION" - name: Bundle artifact-only receipt verifier env: ARTIFACT_DIR: ${{ runner.temp }}/npm-release run: >- bun build scripts/release/release-receipt.ts --target bun --outfile "$ARTIFACT_DIR/release-receipt.mjs" - name: Upload immutable release artifact set uses: actions/upload-artifact@v4 with: name: ${{ steps.release.outputs.artifact_name }} path: ${{ runner.temp }}/npm-release if-no-files-found: error retention-days: 14 publish: name: Preflight and publish exact npm artifacts needs: prepare runs-on: ubuntu-latest timeout-minutes: 20 environment: npm-publish permissions: contents: read id-token: write steps: - name: Download exact prepared artifacts uses: actions/download-artifact@v4 with: name: ${{ needs.prepare.outputs.artifact_name }} path: ${{ runner.temp }}/npm-release - name: Setup pinned Bun uses: oven-sh/setup-bun@v2 with: bun-version: 1.4.0 - name: Setup pinned Node uses: actions/setup-node@v4 with: node-version: 24.11.1 registry-url: https://registry.npmjs.org - name: Setup pinned npm run: npm install --global npm@11.6.2 - name: Setup pinned pnpm run: | corepack enable corepack prepare pnpm@10.20.0 --activate - name: Verify receipt and preflight every package env: RELEASE_VERSION: ${{ needs.prepare.outputs.release_version }} SOURCE_SHA: ${{ needs.prepare.outputs.source_sha }} run: | bun "${{ runner.temp }}/npm-release/release-receipt.mjs" verify \ --receipt "${{ runner.temp }}/npm-release/verification-receipt.v1.json" \ --manifest "${{ runner.temp }}/npm-release/release-manifest.json" \ --fixture "${{ runner.temp }}/npm-release/upgrade-fixture.v1.json" \ --qualification "${{ runner.temp }}/npm-release/cross-version-qualification.v1.json" \ --proof "${{ runner.temp }}/npm-release/generated-project-proof.json" \ --release-version "$RELEASE_VERSION" \ --sha "$SOURCE_SHA" bun "${{ runner.temp }}/npm-release/release-state.ts" preflight \ --manifest "${{ runner.temp }}/npm-release/release-manifest.json" - name: Publish absent packages and verify every registry identity env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true RELEASE_VERSION: ${{ needs.prepare.outputs.release_version }} SOURCE_SHA: ${{ needs.prepare.outputs.source_sha }} run: | bun "${{ runner.temp }}/npm-release/release-receipt.mjs" verify \ --receipt "${{ runner.temp }}/npm-release/verification-receipt.v1.json" \ --manifest "${{ runner.temp }}/npm-release/release-manifest.json" \ --fixture "${{ runner.temp }}/npm-release/upgrade-fixture.v1.json" \ --qualification "${{ runner.temp }}/npm-release/cross-version-qualification.v1.json" \ --proof "${{ runner.temp }}/npm-release/generated-project-proof.json" \ --release-version "$RELEASE_VERSION" \ --sha "$SOURCE_SHA" bun "${{ runner.temp }}/npm-release/release-state.ts" publish \ --manifest "${{ runner.temp }}/npm-release/release-manifest.json" smoke: name: Smoke the exact published CLI version needs: [prepare, publish] runs-on: ubuntu-latest timeout-minutes: 20 permissions: contents: read steps: - name: Checkout the exact required-CI revision uses: actions/checkout@v4 with: ref: ${{ needs.prepare.outputs.source_sha }} persist-credentials: false - name: Setup pinned Bun uses: oven-sh/setup-bun@v2 with: bun-version: 1.4.0 - name: Setup pinned Node uses: actions/setup-node@v4 with: node-version: 24.11.1 - name: Setup pinned npm and pnpm run: | npm install --global npm@11.6.2 corepack enable corepack prepare pnpm@10.20.0 --activate - name: Install smoke harness dependencies run: bun install --frozen-lockfile env: BTS_TELEMETRY: 0 - name: Smoke exact published release env: PUBLISHED_VERSION: ${{ needs.prepare.outputs.cli_version }} BTS_TELEMETRY: 0 run: bun run test:published-package --specifier "$PUBLISHED_VERSION" finalize: name: Create success tag and GitHub release needs: [prepare, publish, smoke] runs-on: ubuntu-latest timeout-minutes: 10 permissions: contents: write steps: - name: Download exact prepared artifacts uses: actions/download-artifact@v4 with: name: ${{ needs.prepare.outputs.artifact_name }} path: ${{ runner.temp }}/npm-release - name: Setup pinned Bun uses: oven-sh/setup-bun@v2 with: bun-version: 1.4.0 - name: Setup pinned Node uses: actions/setup-node@v4 with: node-version: 24.11.1 - name: Setup pinned npm run: npm install --global npm@11.6.2 - name: Setup pinned pnpm run: | corepack enable corepack prepare pnpm@10.20.0 --activate - name: Reverify packages, then create tag and release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPOSITORY: ${{ github.repository }} RELEASE_VERSION: ${{ needs.prepare.outputs.release_version }} SOURCE_SHA: ${{ needs.prepare.outputs.source_sha }} run: | bun "${{ runner.temp }}/npm-release/release-receipt.mjs" verify \ --receipt "${{ runner.temp }}/npm-release/verification-receipt.v1.json" \ --manifest "${{ runner.temp }}/npm-release/release-manifest.json" \ --fixture "${{ runner.temp }}/npm-release/upgrade-fixture.v1.json" \ --qualification "${{ runner.temp }}/npm-release/cross-version-qualification.v1.json" \ --proof "${{ runner.temp }}/npm-release/generated-project-proof.json" \ --release-version "$RELEASE_VERSION" \ --sha "$SOURCE_SHA" bun "${{ runner.temp }}/npm-release/release-state.ts" finalize \ --manifest "${{ runner.temp }}/npm-release/release-manifest.json" \ --repository "$REPOSITORY" \ --sha "$SOURCE_SHA" \ --asset "${{ runner.temp }}/npm-release/release-manifest.json" \ --asset "${{ runner.temp }}/npm-release/verification-receipt.v1.json" \ --asset "${{ runner.temp }}/npm-release/upgrade-fixture.v1.json" \ --asset "${{ runner.temp }}/npm-release/cross-version-qualification.v1.json" - name: Write release summary env: RELEASE_VERSION: ${{ needs.prepare.outputs.release_version }} REPOSITORY: ${{ github.repository }} run: | echo "## Release v$RELEASE_VERSION complete" >> "$GITHUB_STEP_SUMMARY" echo "All exact package artifacts passed registry identity checks and the published-package smoke lane. The release includes eight executable manifest-v2 upgrade fixtures." >> "$GITHUB_STEP_SUMMARY" echo "https://github.com/$REPOSITORY/releases/tag/v$RELEASE_VERSION" >> "$GITHUB_STEP_SUMMARY"