File tree Expand file tree Collapse file tree 1 file changed +10
-23
lines changed
.github/actions/npm-publish Expand file tree Collapse file tree 1 file changed +10
-23
lines changed Original file line number Diff line number Diff line change @@ -12,21 +12,6 @@ inputs:
1212runs :
1313 using : composite
1414 steps :
15- - id : pkg
16- name : 获取 package.json 信息
17- uses : jaywcjlove/github-action-package@main
18-
19- # originName -> underscoreName
20- # my-pkg -> my-pkg
21- # @my-scope/my-pkg -> my-scope__my-pkg
22- - id : naming
23- name : 命名规则变更
24- uses : frabert/replace-string-action@v2
25- with :
26- string : ${{ steps.pkg.outputs.name }}
27- pattern : ' @(.*)\/(.*)'
28- replace-with : ' $1__$2'
29-
3015 - name : 仓库类型是 npm
3116 if : inputs.type == 'npm'
3217 shell : bash
@@ -44,18 +29,20 @@ runs:
4429 echo "always-auth=true" >> .npmrc
4530 - name : 将 package.json name 修改为符合 GitHub 的命名要求
4631 if : inputs.type == 'github'
47- uses : jaywcjlove /github-action-package@main
32+ uses : actions /github-script@v6
4833 with :
49- data : |
50- {
51- "name": "@${{ github.repository_owner }}/${{ steps.naming.outputs.replaced }}"
52- }
34+ result-encoding : string
35+ script : |
36+ const pkg = require('./package.json');
37+ const safeName = pkg.name.replace(/@(.*)\/(.*)/, '$1__$2');
38+ pkg.name = github.repository_owner + '/' + steps.naming.outputs.replaced;
39+ const fs = require('fs');
40+ fs.writeFileSync('package.json', JSON.stringify(pkg));
5341
54- # 发布
55- - shell : bash
42+ - name : 发布
43+ shell : bash
5644 run : npm publish
5745
58- # npm 发布时同步新版本
5946 - name : 同步新版本到 npmmirror.com
6047 if : inputs.type == 'npm'
6148 shell : bash
You can’t perform that action at this time.
0 commit comments