Skip to content

Commit 0822bf5

Browse files
Update GitHub action for publishing to npmjs
1 parent fbfb7aa commit 0822bf5

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

.github/workflows/publish.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# From https://docs.github.com/en/actions/tutorials/publish-packages/publish-nodejs-packages#publishing-packages-to-the-npm-registry
2-
31
name: Publish Package to npmjs
42
on:
53
release:
@@ -8,15 +6,29 @@ jobs:
86
build:
97
runs-on: ubuntu-latest
108
permissions:
11-
contents: read
9+
contents: write
1210
id-token: write
1311
steps:
14-
- uses: actions/checkout@v5
15-
- uses: actions/setup-node@v4
12+
- name: Checkout code
13+
uses: actions/checkout@v5
14+
- name: Get release version
15+
id: get_version
16+
run: echo "RELEASE_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
17+
- name: Update package.json
18+
run: npm version "${{ steps.get_version.outputs.RELEASE_VERSION }}" --no-git-tag-version
19+
- name: Commit package.json changes
20+
uses: stefanzweifel/git-auto-commit-action@v6
21+
with:
22+
commit_message: "Update package.json version to ${{ steps.get_version.outputs.RELEASE_VERSION }}"
23+
branch: main
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
1626
with:
1727
node-version: '20.x'
1828
registry-url: 'https://registry.npmjs.org'
19-
- run: npm ci
20-
- run: npm publish --provenance --access public
29+
- name: Install dependencies
30+
run: npm ci
31+
- name: Push to npmjs
32+
run: npm publish --provenance --access public
2133
env:
22-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)