Skip to content

Commit 606d0bb

Browse files
committed
feat: workflow npm publish
1 parent 50b3910 commit 606d0bb

File tree

5 files changed

+335
-246
lines changed

5 files changed

+335
-246
lines changed

.github/workflows/npm-publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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: Npm Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
push:
10+
branches:
11+
- main
12+
tags:
13+
- "*"
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
24+
publish-npm:
25+
needs: build
26+
runs-on: ubuntu-latest
27+
concurrency:
28+
group: ${{ github.workflow }}-${{ github.ref }}
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
registry-url: https://registry.npmjs.org/
38+
39+
- name: Install pnpm
40+
uses: pnpm/action-setup@v2
41+
with:
42+
version: 7
43+
44+
- name: Install & Publish
45+
run: |
46+
pnpm -v
47+
pnpm i
48+
pnpm run publish-changed
49+
env:
50+
NODE_AUTH_TOKEN: ${{secrets.NPM_CHAOS_TOKEN}}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ dist
131131
.pnp.*
132132

133133
# for get changed pkg path
134-
cache-changed-pkg-path.sh
134+
cache-changed-*.sh

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"getchanged": "sh ./scripts/get-changed-pkg-path.sh",
2323
"release-all": "bumpp packages/**/package.json",
2424
"release": "bumpp packages/**/package.json packages/**/*/package.json",
25+
"publish-changed": "npm run getchanged && chmod +x ./cache-changed-pkg-publish-path.sh",
26+
"prepublishOnly": "pnpm run build",
2527
"publish-pkg": "sh ./scripts/publish-to-npm.sh",
2628
"prepare": "husky"
2729
},
@@ -45,7 +47,7 @@
4547
"lint-staged": {
4648
"*": [
4749
"prettier --write --cache --ignore-unknown",
48-
"npm run generate-packages-info",
50+
"pnpm run generate-packages-info",
4951
"pnpm run getchanged",
5052
"git add ."
5153
],

0 commit comments

Comments
 (0)