@@ -13,21 +13,21 @@ runs:
1313 using : composite
1414 steps :
1515 - id : pkg
16+ name : 获取 package.json 信息
1617 uses : jaywcjlove/github-action-package@main
18+
1719 - id : naming
20+ name : 命名规则变更
1821 shell : bash
1922 # originName -> underscoreName
2023 # my-pkg -> my-pkg
2124 # @my-scope/my-pkg -> my-scope__my-pkg
25+ env :
26+ UNDERSCORE_NAME : ${${n1/@/}/\//__}
2227 run : |
23- # 原始名称
2428 echo "N1=${{ steps.pkg.outputs.name }}" >> $GITHUB_ENV
25- # 删除 @ 开头
26- echo "N2=${N1/@/}" >> $GITHUB_ENV
27- # 将 / 替换为 __
28- echo "N3=${N2/\//__}" >> $GITHUB_ENV
2929 echo "origin=$N1" >> "$GITHUB_OUTPUT"
30- echo "underscore=$N3 " >> "$GITHUB_OUTPUT"
30+ echo "underscore=${${N1/@/}/\//__} " >> "$GITHUB_OUTPUT"
3131
3232 - name : 仓库类型是 npm
3333 if : inputs.type == 'npm'
3636 echo "//registry.npmjs.org/:_authToken=${{ inputs.token }}" > .npmrc
3737 echo "registry=https://registry.npmjs.org/" >> .npmrc
3838 echo "always-auth=true" >> .npmrc
39- - shell : bash
40- run : npm publish
41- - name : 同步新版本到 npmmirror.com
42- if : inputs.type == 'npm'
43- shell : bash
44- run : curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true
4539
4640 - name : 仓库类型是 github
4741 if : inputs.type == 'github'
@@ -50,11 +44,21 @@ runs:
5044 echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" > .npmrc
5145 echo "registry=https://npm.pkg.github.com/" >> .npmrc
5246 echo "always-auth=true" >> .npmrc
53- - name : 将 package.json name 修改为符合 GitHub 要求
47+ - name : 将 package.json name 修改为符合 GitHub 的命名要求
5448 if : inputs.type == 'github'
5549 uses : jaywcjlove/github-action-package@main
5650 with :
5751 data : |
5852 {
5953 "name": "@${{ github.repository_owner }}/${{ steps.naming.outputs.underscore }}"
6054 }
55+
56+ # 发布
57+ - shell : bash
58+ run : npm publish
59+
60+ # npm 发布时同步新版本
61+ - name : 同步新版本到 npmmirror.com
62+ if : inputs.type == 'npm'
63+ shell : bash
64+ run : curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true
0 commit comments