Skip to content

Commit 8f4c839

Browse files
authored
Merge pull request #204 from hypercerts-org/ci/release-pr-title-version
2 parents 5a37ede + 96f9ef2 commit 8f4c839

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,33 @@ jobs:
104104
with:
105105
publish: npm run release
106106
version: npm run version-packages
107-
title: "chore: release package"
108-
commit: "chore: release package"
107+
title: "Release"
108+
commit: "Release"
109109
env:
110110
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
111111
NPM_CONFIG_PROVENANCE: true
112112

113+
# changesets/action does not support templating the version into the
114+
# PR title (see changesets/action#388). As a workaround, rename the
115+
# Release PR to include the version number after the action has run
116+
# the version bump. The commit message on the release branch is left
117+
# as the static "Release" value — it gets rewritten on every re-run
118+
# of this workflow, and the merge commit title on main is controlled
119+
# by the person merging the PR.
120+
- name: Rename Release PR with version
121+
if: env.RELEASE_TYPE == 'stable' && steps.changesets.outputs.pullRequestNumber != ''
122+
env:
123+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
124+
PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }}
125+
run: |
126+
VERSION=$(gh api \
127+
"repos/${{ github.repository }}/contents/package.json?ref=changeset-release/main" \
128+
-H "Accept: application/vnd.github.raw" \
129+
| node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version")
130+
NEW_TITLE="Release v$VERSION"
131+
echo "Renaming PR #$PR_NUMBER to: $NEW_TITLE"
132+
gh pr edit "$PR_NUMBER" --title "$NEW_TITLE"
133+
113134
# Beta release: version, commit, publish, and push in one step.
114135
# changesets/action is not used here because it requires two workflow
115136
# runs (one to create a version PR, another to publish after merging).

0 commit comments

Comments
 (0)