Skip to content

Commit 1959c83

Browse files
committed
github actions
1 parent fa39f11 commit 1959c83

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/npm-publish.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ name: Node.js Package
66
on:
77
workflow_dispatch:
88
release:
9-
types: [created]
10-
9+
types: [ created ]
10+
pull_request:
11+
types: [ review_requested ]
1112
jobs:
1213
build:
1314
runs-on: ubuntu-latest
@@ -18,9 +19,32 @@ jobs:
1819
node-version: 16
1920
- run: npm ci
2021

21-
publish-npm:
22+
update-version:
2223
needs: build
2324
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Update setup.py version
28+
run: |
29+
TAG_NAME=$(echo ${{github.ref_name}})
30+
jq --arg tag "$TAG_NAME" '.version = $tag' package.json > tmp.$$.json && mv tmp.$$.json package.json
31+
32+
- name: Commit and push changes
33+
run: |
34+
TAG_NAME=$(echo ${{github.ref_name}})
35+
git config --global user.name 'github-actions[bot]'
36+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
37+
git add package.json
38+
git commit -m "Update package.json version to $TAG_NAME"
39+
git tag -f $TAG_NAME
40+
git push --force origin $TAG_NAME
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
44+
publish-npm:
45+
needs: update-version
46+
runs-on: ubuntu-latest
47+
if: startsWith(github.ref, 'refs/tags/')
2448
steps:
2549
- uses: actions/checkout@v4
2650
- uses: actions/setup-node@v3

0 commit comments

Comments
 (0)