@@ -12,34 +12,48 @@ inputs:
1212runs :
1313 using : composite
1414 steps :
15+ - id : pkg
16+ uses : jaywcjlove/github-action-package@main
17+ - id : name
18+ shell : bash
19+ # originName -> underscoreName
20+ # my-pkg -> my-pkg
21+ # @my-scope/my-pkg -> my-scope__my-pkg
22+ run : |
23+ _n1="${{ steps.pkg.outputs.name }}"
24+ # 删除 @ 开头
25+ _n2="${_n1/@/}"
26+ # 将 / 替换为 __
27+ _n3="${_n2/\//__}"
28+ echo "origin=${{ _n1 }}" >> "$GITHUB_OUTPUT"
29+ echo "underscore=${{ _n3 }}" >> "$GITHUB_OUTPUT"
30+
31+ - name : 仓库类型是 npm
32+ if : inputs.type == 'npm'
33+ shell : bash
34+ run : |
35+ echo "//registry.npmjs.org/:_authToken=${{ inputs.token }}" > .npmrc
36+ echo "registry=https://registry.npmjs.org/" >> .npmrc
37+ echo "always-auth=true" >> .npmrc
38+ - shell : bash
39+ run : npm publish
40+ - name : 同步新版本到 npmmirror.com
41+ if : inputs.type == 'npm'
42+ shell : bash
43+ run : curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true
44+
1545 - name : 仓库类型是 github
1646 if : inputs.type == 'github'
47+ shell : bash
1748 run : |
1849 echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" > .npmrc
1950 echo "registry=https://npm.pkg.github.com/" >> .npmrc
2051 echo "always-auth=true" >> .npmrc
21- shell : bash
22- - name : 修改 package.json name 为 @${{ github.repository }}
52+ - name : 将 package.json name 修改为符合 GitHub 要求
2353 if : inputs.type == 'github'
2454 uses : jaywcjlove/github-action-package@main
2555 with :
2656 data : |
2757 {
28- "name": "@${{ github.repository }}"
58+ "name": "@${{ steps.name.outputs.underscore }}"
2959 }
30- - name : 仓库类型是 npm
31- if : inputs.type == 'npm'
32- run : |
33- echo "//registry.npmjs.org/:_authToken=${{ inputs.token }}" > .npmrc
34- echo "registry=https://registry.npmjs.org/" >> .npmrc
35- echo "always-auth=true" >> .npmrc
36- shell : bash
37- - run : npm publish
38- shell : bash
39- - id : pkg
40- if : inputs.type == 'npm'
41- uses : jaywcjlove/github-action-package@main
42- - name : 同步新版本到 npmmirror.com
43- if : inputs.type == 'npm'
44- run : curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true
45- shell : bash
0 commit comments