File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Publish to npm
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ tags :
8+ - ' v*'
9+
10+ jobs :
11+ publish :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - uses : actions/checkout@v3
15+
16+ - name : Setup Node.js
17+ uses : actions/setup-node@v3
18+ with :
19+ node-version : ' 16'
20+ registry-url : ' https://registry.npmjs.org'
21+
22+ - name : Install dependencies
23+ run : npm ci
24+
25+ - name : Publish to npm
26+ run : npm publish --access public
27+ env :
28+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # 检查是否提供了NPM令牌
4+ if [ -z " $1 " ]; then
5+ echo " 请提供NPM令牌作为参数"
6+ echo " 用法: ./publish.sh your-npm-token"
7+ exit 1
8+ fi
9+
10+ # 设置NPM令牌
11+ NPM_TOKEN=$1
12+
13+ # 创建临时.npmrc文件
14+ echo " //registry.npmjs.org/:_authToken=$NPM_TOKEN " > .npmrc
15+
16+ # 发布包
17+ npm publish --access public
18+
19+ # 删除临时.npmrc文件
20+ rm .npmrc
21+
22+ echo " 发布完成!"
You can’t perform that action at this time.
0 commit comments