Skip to content

Commit 9016933

Browse files
bartvenemanclaude
andauthored
chore: automate version bumping in release workflow (#102)
Extract version from release tag and update package.json before publishing to NPM, then commit and push the version bump back to main. Co-authored-by: Claude <noreply@anthropic.com>
1 parent b67d355 commit 9016933

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3-
41
name: NPM Publish
52

63
on:
@@ -9,7 +6,7 @@ on:
96

107
permissions:
118
id-token: write # Required for OIDC
12-
contents: read
9+
contents: write # Required to push version bump commit
1310

1411
jobs:
1512
publish-npm:
@@ -22,6 +19,17 @@ jobs:
2219
registry-url: https://registry.npmjs.org/
2320
- run: npm install -g npm@latest
2421
- run: npm ci --ignore-scripts --no-audit --no-fund
22+
- name: Bump version in package.json
23+
run: |
24+
VERSION="${{ github.event.release.tag_name }}"
25+
npm version "${VERSION#v}" --no-git-tag-version
26+
- name: Commit and push version bump
27+
run: |
28+
git config user.name "github-actions[bot]"
29+
git config user.email "github-actions[bot]@users.noreply.github.com"
30+
git add package.json package-lock.json
31+
git commit -m "chore: bump version to ${{ github.event.release.tag_name }}"
32+
git push origin HEAD:main
2533
- run: npx playwright install chromium --only-shell
2634
- run: npm test -- --forbid-only
2735
- run: npm run build

0 commit comments

Comments
 (0)