Skip to content

Commit 8ada59e

Browse files
authored
Modify release workflow for version bump and permissions (#33)
Updated permissions to allow pushing version bump commit and modified the npm install command. Added a step to bump the version based on the release tag.
1 parent 00aaf66 commit 8ada59e

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
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:
74
release:
85
types: [created]
96

107
permissions:
11-
id-token: write # required for OIDC
12-
contents: read
8+
id-token: write # Required for OIDC
9+
contents: write # Required for pushing version bump commit
1310

1411
jobs:
15-
test:
16-
runs-on: ubuntu-latest
17-
steps:
18-
- uses: actions/checkout@v6
19-
- uses: actions/setup-node@v6
20-
with:
21-
node-version: 22
22-
- run: npm ci --ignore-scripts --no-audit --no-fund
23-
- run: npm test
24-
2512
publish-npm:
26-
needs: test
2713
runs-on: ubuntu-latest
2814
steps:
2915
- uses: actions/checkout@v6
@@ -32,6 +18,16 @@ jobs:
3218
node-version: 22
3319
registry-url: https://registry.npmjs.org/
3420
- run: npm install -g npm@latest
35-
- run: npm ci --ignore-scripts --no-audit --no-fund
21+
- run: npm install --ignore-scripts --no-audit --no-fund
22+
- name: Bump version from release tag
23+
run: |
24+
VERSION=${GITHUB_REF_NAME#v}
25+
npm version $VERSION --no-git-tag-version
26+
git config user.name "github-actions[bot]"
27+
git config user.email "github-actions[bot]@users.noreply.github.com"
28+
git add package.json package-lock.json
29+
git commit -m "chore: bump version to $VERSION"
30+
git push origin HEAD:${{ github.event.repository.default_branch }}
31+
- run: npm test
3632
- run: npm run build
3733
- run: npm publish --access public

0 commit comments

Comments
 (0)