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
19 changes: 13 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
outputs:
tag: ${{ steps.tag.outputs.tag }}
due: ${{ steps.tag.outputs.due }}
body: ${{ steps.pr.outputs.body }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
with:
Expand All @@ -44,18 +45,22 @@ jobs:

# A version bump that did not come through `vp run bump-version` stops here instead of releasing.
- name: Verify commit is a merged release PR
id: pr
if: steps.tag.outputs.due == 'true'
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.tag.outputs.tag }}
run: |
gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" |
jq -e --arg tag "$TAG" 'any(.[];
pr="$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" |
jq -e --arg tag "$TAG" 'first(.[] | select(
.merged_at != null
and .head.repo.full_name == .base.repo.full_name
and .head.ref == "chore/release-\($tag[1:])"
and .title == "chore: release \($tag)")' > /dev/null ||
and .title == "chore: release \($tag)"))')" ||
{ echo "::error::$GITHUB_SHA is not a merged chore/release-${TAG#v} PR titled \"chore: release $TAG\""; exit 1; }
# A random delimiter, so no line of the body can end the output early.
delimiter="EOF_$(openssl rand -hex 16)"
{ echo "body<<$delimiter"; jq -r '.body // ""' <<< "$pr"; echo "$delimiter"; } >> "$GITHUB_OUTPUT"

release:
needs: verify
Expand Down Expand Up @@ -114,12 +119,14 @@ jobs:
# checked this commit.
- run: pnpm publish --provenance --no-git-checks

# Last: a release pointing at a version npm rejected would be a lie. The notes come from the
# PRs merged since the previous tag, grouped by `.github/release.yml`.
# Last: a release pointing at a version npm rejected would be a lie. The notes open with the
# release PR's body, followed by the PRs merged since the previous tag, grouped by
# `.github/release.yml`.
- name: Create the GitHub release
run: gh release create "$TAG" --verify-tag --generate-notes
run: gh release create "$TAG" --verify-tag --notes "$BODY" --generate-notes
env:
GH_TOKEN: ${{ github.token }}
BODY: ${{ needs.verify.outputs.body }}

# The book is published per tag under `{tag}/`, with `latest/` a copy of the newest release and a
# bare index at the root. The site lives on `gh-pages`, which GitHub Pages serves as a branch.
Expand Down
Loading