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
17 changes: 14 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ on:
push:
branches: [main]

permissions:
contents: write
# Granted on the job below, not here: a workflow-level grant would also reach
# any job added later, and only the release job pushes.
permissions: {}

concurrency:
group: release
Expand All @@ -28,6 +29,8 @@ jobs:
# Belt and braces: never react to our own release commit.
if: ${{ !startsWith(github.event.head_commit.message, 'chore(release):') }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# A token for the `scattercode-release` GitHub App, which is the only
# actor allowed to bypass main's ruleset. GITHUB_TOKEN cannot be given
Expand All @@ -45,6 +48,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 @@ -109,6 +116,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 @@ -169,6 +180,6 @@ jobs:
# and no changelog commit, so re-running the job is a clean redo.
# A retry would have to move an annotated tag, which is a worse
# thing to get wrong than a re-run is to perform.
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
Loading