Skip to content

Commit 2600477

Browse files
authored
feat: auto release (#4)
* feat: auto release * fix: Update npm-publish.yml * fix: Update npm-publish.yml
1 parent fef1716 commit 2600477

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

.github/workflows/npm-publish.yml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
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://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3-
4-
name: Node.js Package
1+
name: Publish npm Package
52

63
on:
7-
release:
8-
types: [created]
4+
push:
5+
branches:
6+
- master
7+
- main
98

109
jobs:
11-
build:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: actions/checkout@v4
15-
- uses: actions/setup-node@v4
16-
with:
17-
node-version: 20
18-
- run: npm test
19-
2010
publish-npm:
21-
needs: build
2211
runs-on: ubuntu-latest
2312
steps:
2413
- uses: actions/checkout@v4
2514
- uses: actions/setup-node@v4
2615
with:
2716
node-version: 20
2817
registry-url: https://registry.npmjs.org/
29-
30-
- name: Get release name
31-
run: echo "RELEASE_NAME=${{ github.event.release.name }}" >> $GITHUB_ENV
32-
33-
- name: Update package.json version
34-
run: |
35-
npm version ${{ env.RELEASE_NAME }} --no-git-tag-version
36-
37-
- run: npm publish
18+
- run: git config --global user.name "GitHub CD bot"
19+
- run: git config --global user.email "[email protected]"
20+
- run: npm i && npm run test
21+
- run: npm config set access public && npx semantic-release
22+
env:
23+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
# push the version changes to GitHub
26+
- run: git add package.json && git commit -m'update version' && git push
3827
env:
39-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
28+
# The secret is passed automatically. Nothing to configure.
29+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)