diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 5290f8dac..38f60028a 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -46,6 +46,24 @@ compose freely. Dispatch `release-prepare` with a bump and a channel, review the release PR it opens, merge it. `release-publish` then publishes the merged package.json version. +Publishing listens for pushes to `refactor` (switch to `main` when the refactor lands), not PR +events. It looks up the pushed commit's associated PRs and proceeds only when that exact commit +is the merge of a `release/v*` PR opened by `agentcore-devx-automation[bot]` (account ID +`282717993`) from this repository into the target branch. Manually opened release PRs, +ordinary merges, fork PRs, and pushes without a matching release PR skip verification and +publishing. Every job uses the pushed SHA, so later commits cannot change what is released. + +The prepare job uses `aws-release-4-core`. The check-release and publish jobs stay on +`ubuntu-latest` until `release-publish.yml` is allowlisted for the dedicated runner group. +The allowlist is scoped to workflow paths and branches; renaming a workflow or changing its +branch requires a runner-group administrator to update it. Keep PR-triggered workflows +and the verification matrix off this release-only pool. + +The npm package includes `dist` except `dist/bin`, plus standard package metadata. This keeps +additional bundle chunks and runtime assets included as the build evolves. Native binaries in +`dist/bin` are separate GitHub release assets, never npm package contents, even when packing a +workspace that has already compiled them. + If publish fails after the merge, rerun the failed `release-publish` jobs. Both the npm publish and the GitHub release steps skip work that already succeeded. Do not re-dispatch `release-prepare`, package.json already holds the new version and it would bump again. diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml index 76a28f7fe..188710aa6 100644 --- a/.github/workflows/release-prepare.yml +++ b/.github/workflows/release-prepare.yml @@ -17,7 +17,7 @@ on: jobs: prepare: - runs-on: ubuntu-latest + runs-on: aws-release-4-core permissions: contents: read steps: diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index a7ed01d05..150c17d75 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -2,19 +2,47 @@ # release-prepare.yml merges. The version is whatever the merged package.json says. name: release-publish on: - pull_request: - types: [closed] + push: # TODO: switch to main once the refactor lands there. branches: [refactor] jobs: + check-release: + if: "!github.event.deleted" + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + is_release: ${{ steps.check.outputs.is_release }} + steps: + # Push runs the trusted base-branch workflow, but does not carry the merged PR's metadata. + - name: Check for a merged release PR + id: check + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + IS_RELEASE=$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" \ + | jq -r --arg repository "$GITHUB_REPOSITORY" --arg ref "$GITHUB_REF_NAME" --arg sha "$GITHUB_SHA" ' + any(.[][]; + # Stable account ID for agentcore-devx-automation[bot]. + .user.id == 282717993 and + .merged_at != null and + .merge_commit_sha == $sha and + .head.repo.full_name == $repository and + .base.ref == $ref and + (.head.ref | startswith("release/v")) + )') + echo "is_release=$IS_RELEASE" >> "$GITHUB_OUTPUT" + verify: - if: github.event.pull_request.merged && startsWith(github.head_ref, 'release/v') + needs: check-release + if: needs.check-release.outputs.is_release == 'true' uses: ./.github/workflows/verify.yml permissions: contents: read with: - ref: ${{ github.event.pull_request.merge_commit_sha }} + ref: ${{ github.sha }} publish: needs: verify @@ -24,7 +52,7 @@ jobs: contents: write id-token: write env: - REF: ${{ github.event.pull_request.merge_commit_sha }} + REF: ${{ github.sha }} steps: - uses: actions/checkout@v7 with: diff --git a/package.json b/package.json index db239b23c..5ab4d027e 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "node": ">=20.12.0" }, "files": [ - "dist" + "dist", + "!dist/bin" ], "scripts": { "build": "bun scripts/build.ts bundle",