diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7a2c19..20c03ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: @@ -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 @@ -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.