From 78d55f3ed8ed50c018f81dc4bcf04ce30586d4bd Mon Sep 17 00:00:00 2001 From: Michael I Chen Date: Tue, 27 Oct 2026 20:32:30 -0700 Subject: [PATCH 1/6] ci: pin actions that hold write tokens Pin each third-party action that runs with a write token to the commit its major tag points to today: peter-evans/create-pull-request, iarekylew00t/verified-bot-commit, softprops/action-gh-release, googleapis/release-please-action and crazy-max/ghaction-import-gpg, wherever this repository uses them. A major tag can be moved to any commit, and these actions write to the repository or handle the release signing key. Every other action still floats on its major. Dependabot updates the commit and its version comment, and its cooldown applies to these updates as to any other. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pre-commit-autoupdate.yml | 3 ++- .github/workflows/release-pr.yml | 3 ++- .github/workflows/release-publish.yml | 3 ++- .github/workflows/release-tag.yml | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 5d483ae..8e9b885 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -91,7 +91,8 @@ jobs: echo "default_branch=$DEFAULT" >> "$GITHUB_OUTPUT" - name: Commit changes if: steps.autoupdate-pre-commit.outputs.has_updates == 'true' - uses: iarekylew00t/verified-bot-commit@v2 + # Pinned to a commit because it runs with a write token; Dependabot bumps it. + uses: iarekylew00t/verified-bot-commit@1ee4374942e5c5f814e9b3121d766cbe45cea360 # v2.3.6 with: message: 'chore(pre-commit): bump hook versions' files: | diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 5018ac5..a14fbe2 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -296,7 +296,8 @@ jobs: - name: Create release PR id: cpr - uses: peter-evans/create-pull-request@v8 + # Pinned to a commit because it runs with a write token; Dependabot bumps it. + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: branch: ${{ needs.resolve.outputs.branch }} base: main diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 1694e4d..b1f8e4c 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -70,7 +70,8 @@ jobs: uses: sigstore/cosign-installer@v3 - name: Import release GPG key - uses: crazy-max/ghaction-import-gpg@v7 + # Pinned to a commit because it runs with a write token; Dependabot bumps it. + uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 with: gpg_private_key: ${{ secrets.RELEASE_GPG_PRIVATE_KEY }} passphrase: ${{ secrets.RELEASE_GPG_PASSPHRASE }} diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index c9302f8..6fd26a4 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -51,7 +51,8 @@ jobs: echo "tag=$tag" >> "$GITHUB_OUTPUT" - name: Import release GPG key - uses: crazy-max/ghaction-import-gpg@v7 + # Pinned to a commit because it runs with a write token; Dependabot bumps it. + uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 with: gpg_private_key: ${{ secrets.RELEASE_GPG_PRIVATE_KEY }} passphrase: ${{ secrets.RELEASE_GPG_PASSPHRASE }} From 65737eba88c83a03925fc1f0c7b6fb5941a272dc Mon Sep 17 00:00:00 2001 From: Michael I Chen Date: Tue, 27 Oct 2026 20:32:33 -0700 Subject: [PATCH 2/6] ci: build the changelog in a read-only job Split changelog-autoupdate.yml into two jobs. `generate` installs git-cliff and markdownlint, regenerates CHANGELOG.md under a read-only token with no persisted credentials, and uploads the file. The `pull-request` job, which holds contents and pull-requests write, runs only checkout, download-artifact and create-pull-request, pinned to a commit. The id-token grant goes, since no step requests an OIDC token. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/changelog-autoupdate.yml | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/changelog-autoupdate.yml b/.github/workflows/changelog-autoupdate.yml index 2e71497..26beffe 100644 --- a/.github/workflows/changelog-autoupdate.yml +++ b/.github/workflows/changelog-autoupdate.yml @@ -6,20 +6,21 @@ on: workflow_dispatch: permissions: - contents: write - pull-requests: write - id-token: write + contents: read env: BRANCH_NAME: chore/changelog-autoupdate jobs: - changelog-autoupdate: + # Builds the changelog under a read-only token, so the tools it installs never + # run beside the write token that opening the pull request needs. + generate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: fetch-depth: 0 # Full history needed for git cliff + persist-credentials: false # Temporary; see the note in release-pr.yml and tracking issue #87. Pinned # only because 2.14.x drops commits that touch .git-blame-ignore-revs # alone (orhun/git-cliff#1643). Drop the pin once that ships rather @@ -36,8 +37,25 @@ jobs: config: .markdownlint.yml globs: | CHANGELOG.md + - uses: actions/upload-artifact@v7 + with: + name: changelog + path: CHANGELOG.md + + pull-request: + needs: generate + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v7 + - uses: actions/download-artifact@v8 + with: + name: changelog + # Pinned to a commit because it runs with a write token; Dependabot bumps it. - name: Push changes and create PR - uses: peter-evans/create-pull-request@v8 + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: branch: '${{ env.BRANCH_NAME }}' sign-commits: true From ffd6f8a16e25f23704f5b04184a9f34ed34379e8 Mon Sep 17 00:00:00 2001 From: Michael I Chen Date: Tue, 27 Oct 2026 20:46:42 -0700 Subject: [PATCH 3/6] ci: prepare release PRs in a read-only job Split release-pr.yml's release-pr job in two. `prepare` checks out without persisted credentials, stamps the changelog, bumps the pins, runs the formatters, hooks and tests, and uploads the files the release PR commits. `release-pr` holds contents and pull-requests write and runs only checkout, download-artifact, the body render, create-pull-request and the superseded-PR cleanup. The workflow-level token is now read-only, so `resolve` no longer narrows its own. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-pr.yml | 33 ++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index a14fbe2..9f0c3b7 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -21,9 +21,7 @@ on: type: string permissions: - contents: write - pull-requests: write - id-token: write + contents: read concurrency: group: release-pr @@ -45,10 +43,6 @@ jobs: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'chore(release): prepare') runs-on: ubuntu-latest - # Nothing in this job writes. The workflow-level block is what the job - # below needs; narrowing here keeps the read-only half read-only. - permissions: - contents: read outputs: release: ${{ steps.version.outputs.release }} tag: ${{ steps.version.outputs.tag }} @@ -200,7 +194,9 @@ jobs: echo "branch=release/$tag" } >>"$GITHUB_OUTPUT" - release-pr: + # Stamps, formats and tests under the read-only token, so git-cliff, pre-commit, + # prettier and the tests never run beside the write token `release-pr` needs. + prepare: needs: resolve if: needs.resolve.outputs.release == 'true' runs-on: ubuntu-latest @@ -208,6 +204,7 @@ jobs: - uses: actions/checkout@v7 with: fetch-depth: 0 + persist-credentials: false # Temporary; see the note in the step above and tracking issue #87. Pinned # only because 2.14.x drops commits that touch .git-blame-ignore-revs @@ -267,6 +264,26 @@ jobs: - name: Run tests run: make test + - uses: actions/upload-artifact@v7 + with: + name: release-files + path: | + CHANGELOG.md + README.md + if-no-files-found: error + + release-pr: + needs: [resolve, prepare] + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v7 + - uses: actions/download-artifact@v8 + with: + name: release-files + # The body is a Markdown file rather than an inline block, and the reason # is that the two rules were in direct conflict. Inline, yamllint's # 100-column limit forces every paragraph to be wrapped -- and GitHub From c0093e33cda8fcdc740c2e3f8ac0d35ffbf8a5fa Mon Sep 17 00:00:00 2001 From: Michael I Chen Date: Tue, 27 Oct 2026 20:46:45 -0700 Subject: [PATCH 4/6] ci: build and sign releases in their own jobs Split release-publish.yml's one job into three. `build` resolves the tag, checks it out and builds the artifacts under a read-only token. `sign` waits on the `release` environment, imports the release key and signs with cosign under an OIDC token but no write access. Only `release-publish` holds contents write, and it runs download-artifact and gh. The approval prompt is unchanged: one per run, now on `sign`. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-publish.yml | 79 +++++++++++++++++++++------ scripts/release/approve.sh | 12 ++-- 2 files changed, 69 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index b1f8e4c..d89335c 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -16,21 +16,22 @@ on: type: string permissions: - contents: write - id-token: write + contents: read concurrency: group: release-publish cancel-in-progress: false +env: + DIST_DIR: dist + jobs: - release-publish: + # Builds under the read-only token. Only `sign` sees the release key, and only + # `release-publish` can write, running nothing but gh. + build: runs-on: ubuntu-latest - # Gated on the protected `release` environment: minting a signed tag - # and publishing artifacts both pause for maintainer approval. - environment: release - env: - DIST_DIR: dist + outputs: + tag: ${{ steps.release-tag.outputs.tag }} steps: # Checked out before the tag is parsed so that the shared, unit-tested # parser can be used. A tag push already lands on the tag; a manual @@ -39,6 +40,7 @@ jobs: - uses: actions/checkout@v7 with: fetch-depth: 0 + persist-credentials: false - name: Resolve release tag id: release-tag @@ -66,31 +68,76 @@ jobs: RELEASE_TAG: ${{ steps.release-tag.outputs.tag }} run: git checkout --detach "refs/tags/$RELEASE_TAG" + - name: Build release artifacts + env: + RELEASE_TAG: ${{ steps.release-tag.outputs.tag }} + run: scripts/release/build-artifacts.sh "$RELEASE_TAG" "$DIST_DIR" + + - uses: actions/upload-artifact@v7 + with: + name: dist + path: ${{ env.DIST_DIR }}/ + if-no-files-found: error + + sign: + needs: build + runs-on: ubuntu-latest + # Gated on the protected `release` environment, which holds the release key. + # Publishing waits on this approval too, since it needs the signed artifacts. + environment: release + permissions: + contents: read + id-token: write + steps: + # sign-artifacts.sh comes from the tag, like every file this run builds from. + - uses: actions/checkout@v7 + with: + ref: refs/tags/${{ needs.build.outputs.tag }} + persist-credentials: false + + - uses: actions/download-artifact@v8 + with: + name: dist + path: ${{ env.DIST_DIR }} + - name: Install cosign uses: sigstore/cosign-installer@v3 - name: Import release GPG key - # Pinned to a commit because it runs with a write token; Dependabot bumps it. + # Pinned to a commit because it handles the release key; Dependabot bumps it. uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 with: gpg_private_key: ${{ secrets.RELEASE_GPG_PRIVATE_KEY }} passphrase: ${{ secrets.RELEASE_GPG_PASSPHRASE }} - - name: Build release artifacts - env: - RELEASE_TAG: ${{ steps.release-tag.outputs.tag }} - run: scripts/release/build-artifacts.sh "$RELEASE_TAG" "$DIST_DIR" - - name: Sign artifacts env: - RELEASE_TAG: ${{ steps.release-tag.outputs.tag }} + RELEASE_TAG: ${{ needs.build.outputs.tag }} GPG_PASSPHRASE: ${{ secrets.RELEASE_GPG_PASSPHRASE }} run: scripts/release/sign-artifacts.sh "$DIST_DIR" "$RELEASE_TAG" + - uses: actions/upload-artifact@v7 + with: + name: signed + path: ${{ env.DIST_DIR }}/ + if-no-files-found: error + + release-publish: + needs: [build, sign] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/download-artifact@v8 + with: + name: signed + path: ${{ env.DIST_DIR }} + - name: Publish GitHub release assets env: GH_TOKEN: ${{ github.token }} - RELEASE_TAG: ${{ steps.release-tag.outputs.tag }} + GH_REPO: ${{ github.repository }} + RELEASE_TAG: ${{ needs.build.outputs.tag }} run: | set -euo pipefail if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then diff --git a/scripts/release/approve.sh b/scripts/release/approve.sh index 39d5634..530b3b9 100755 --- a/scripts/release/approve.sh +++ b/scripts/release/approve.sh @@ -26,12 +26,12 @@ # confirmation. That is the run left behind when the wait above timed out or # Release Tag was approved on GitHub, and the run a manual dispatch creates. # -# The publish job also holds the release key, and a run's name is set by the -# run's own workflow file, read from whichever ref the run started on. So a -# publish run is approved only when it started from a file already on main or -# in the tag: the dispatch on main that Release Tag makes or a maintainer -# repeats by hand, or a push of the tag itself. The run that follows a Release -# Tag approval must be that dispatch. +# Release Publish's signing job also holds the release key, and a run's name +# is set by the run's own workflow file, read from whichever ref the run +# started on. So a publish run is approved only when it started from a file +# already on main or in the tag: the dispatch on main that Release Tag makes +# or a maintainer repeats by hand, or a push of the tag itself. The run that +# follows a Release Tag approval must be that dispatch. # # The branch name is parsed through parse-version.sh for the same reason the # workflows do it: it decides what gets tagged, so a `case` glob that also From c0d47d76d6277430c08b90b9ae939b8f76b0abad Mon Sep 17 00:00:00 2001 From: Michael I Chen Date: Tue, 27 Oct 2026 20:58:22 -0700 Subject: [PATCH 5/6] ci: drop the pin comments The `# vX.Y.Z` after each pinned commit stays; Dependabot reads it. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/changelog-autoupdate.yml | 1 - .github/workflows/pre-commit-autoupdate.yml | 1 - .github/workflows/release-pr.yml | 1 - .github/workflows/release-publish.yml | 1 - .github/workflows/release-tag.yml | 1 - 5 files changed, 5 deletions(-) diff --git a/.github/workflows/changelog-autoupdate.yml b/.github/workflows/changelog-autoupdate.yml index 26beffe..bacc61b 100644 --- a/.github/workflows/changelog-autoupdate.yml +++ b/.github/workflows/changelog-autoupdate.yml @@ -53,7 +53,6 @@ jobs: - uses: actions/download-artifact@v8 with: name: changelog - # Pinned to a commit because it runs with a write token; Dependabot bumps it. - name: Push changes and create PR uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 8e9b885..c5f148d 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -91,7 +91,6 @@ jobs: echo "default_branch=$DEFAULT" >> "$GITHUB_OUTPUT" - name: Commit changes if: steps.autoupdate-pre-commit.outputs.has_updates == 'true' - # Pinned to a commit because it runs with a write token; Dependabot bumps it. uses: iarekylew00t/verified-bot-commit@1ee4374942e5c5f814e9b3121d766cbe45cea360 # v2.3.6 with: message: 'chore(pre-commit): bump hook versions' diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index a14fbe2..6c85f82 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -296,7 +296,6 @@ jobs: - name: Create release PR id: cpr - # Pinned to a commit because it runs with a write token; Dependabot bumps it. uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: branch: ${{ needs.resolve.outputs.branch }} diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index b1f8e4c..276e311 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -70,7 +70,6 @@ jobs: uses: sigstore/cosign-installer@v3 - name: Import release GPG key - # Pinned to a commit because it runs with a write token; Dependabot bumps it. uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 with: gpg_private_key: ${{ secrets.RELEASE_GPG_PRIVATE_KEY }} diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index 6fd26a4..fa60545 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -51,7 +51,6 @@ jobs: echo "tag=$tag" >> "$GITHUB_OUTPUT" - name: Import release GPG key - # Pinned to a commit because it runs with a write token; Dependabot bumps it. uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 with: gpg_private_key: ${{ secrets.RELEASE_GPG_PRIVATE_KEY }} From 463143d595ea9a0169a8e7da6996cd2ba5992d78 Mon Sep 17 00:00:00 2001 From: Michael I Chen Date: Tue, 27 Oct 2026 21:00:19 -0700 Subject: [PATCH 6/6] ci: drop the pin comments The `# vX.Y.Z` after each pinned commit stays; Dependabot reads it. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index d89335c..34f3436 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -104,7 +104,6 @@ jobs: uses: sigstore/cosign-installer@v3 - name: Import release GPG key - # Pinned to a commit because it handles the release key; Dependabot bumps it. uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 with: gpg_private_key: ${{ secrets.RELEASE_GPG_PRIVATE_KEY }}