Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ on:
required: true
type: string

permissions:
contents: write
# Granted per job below, not here: a workflow-level grant reaches every job,
# and only the release job pushes.
permissions: {}

concurrency:
group: release
Expand All @@ -48,6 +49,8 @@ jobs:
# names a tag that already exists, so there is nothing to compute.
if: ${{ github.event_name == 'push' && !startsWith(github.event.head_commit.message, 'chore(release):') }}
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
released: ${{ steps.version.outputs.release }}
version: ${{ steps.version.outputs.next }}
Expand All @@ -63,6 +66,10 @@ jobs:
with:
app-id: ${{ secrets.RELEASE_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
# Scoped to what the job uses, even though the installation grants
# no more: a token minted without this inherits whatever the App
# is later given.
permission-contents: write

# The committer line needs the App's bot *user* id, which is not any of
# the ids the token action returns -- `installation-id` is a different
Expand Down Expand Up @@ -115,6 +122,10 @@ jobs:
env:
VERSION: ${{ steps.version.outputs.next }}
GH_TOKEN: ${{ github.token }}
# Passed through the environment rather than expanded into the
# script: an expression inside `run:` is pasted into the shell
# before it runs, which is how workflow injection happens.
BRANCH: ${{ github.ref_name }}
run: |
set -euo pipefail

Expand Down Expand Up @@ -146,7 +157,7 @@ jobs:
# push is atomic and nothing after it has run, a lost race leaves no
# tag, no release and no changelog commit, so re-running the job is
# a clean redo.
git push --atomic origin "HEAD:${{ github.ref_name }}" "$VERSION"
git push --atomic origin "HEAD:${BRANCH}" "$VERSION"

gh release create "$VERSION" --title "$VERSION" --notes-file RELEASE_NOTES.md

Expand Down Expand Up @@ -191,6 +202,9 @@ jobs:
needs: tag
if: ${{ !cancelled() && needs.tag.outputs.released == 'true' }}
runs-on: ubuntu-latest
# Reads the tag and nothing more.
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
Expand Down
Loading