Skip to content

Commit 9927e4e

Browse files
authored
fix: restore release automation and use GitHub App token in publish workflow (#38)
Restore end-to-end release automation in publish.yml. - Use GitHub App token for release PR creation so CI runs on release PRs - Restore automatic tag and GitHub release creation after release PR merge when no changesets remain - Keep npm publish triggered from release event Includes a changeset entry for this workflow fix.
1 parent 8c69918 commit 9927e4e

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"node-es-transformer": patch
3+
---
4+
5+
Use GitHub App token for release PRs and restore automatic GitHub and npm publishing after merge

.github/workflows/publish.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@ jobs:
3737
echo "CI workflow did not succeed. Skipping release."
3838
exit 1
3939
40+
- name: Generate GitHub App Token
41+
id: app-token
42+
uses: actions/create-github-app-token@v1
43+
with:
44+
app-id: ${{ vars.APP_ID }}
45+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
46+
4047
- name: Checkout
4148
uses: actions/checkout@v6
4249
with:
50+
token: ${{ steps.app-token.outputs.token }}
4351
fetch-depth: 0
4452

4553
- name: Setup Node.js 22.x
@@ -69,9 +77,43 @@ jobs:
6977
if: steps.check-changesets.outputs.hasChangesets == 'true'
7078
run: node scripts/create-release-pr.mjs
7179
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
7381
GITHUB_REPOSITORY: ${{ github.repository }}
7482

83+
- name: Check for Published Version
84+
id: check-publish
85+
if: steps.check-changesets.outputs.hasChangesets == 'false'
86+
run: |
87+
VERSION=$(node -p "require('./package.json').version")
88+
89+
if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q "v${VERSION}$"; then
90+
echo "shouldPublish=false" >> $GITHUB_OUTPUT
91+
echo "Tag v${VERSION} already exists"
92+
else
93+
echo "shouldPublish=true" >> $GITHUB_OUTPUT
94+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
95+
echo "Will create release for v${VERSION}"
96+
fi
97+
98+
- name: Create GitHub Release
99+
if: steps.check-publish.outputs.shouldPublish == 'true'
100+
run: |
101+
VERSION="${{ steps.check-publish.outputs.version }}"
102+
103+
git config user.name "github-actions[bot]"
104+
git config user.email "github-actions[bot]@users.noreply.github.com"
105+
106+
git tag -a "v${VERSION}" -m "Release v${VERSION}"
107+
git push origin "v${VERSION}"
108+
109+
RELEASE_NOTES=$(awk '/^## / {if (found) exit; found=1; next} found' CHANGELOG.md)
110+
111+
gh release create "v${VERSION}" \
112+
--title "v${VERSION}" \
113+
--notes "${RELEASE_NOTES}"
114+
env:
115+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
116+
75117
build:
76118
name: Build package
77119
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)