Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/actions/npm-publish/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: npm publish
description: |
按仓库类型执行 npm publish,可以将包发布到 npm、github 等仓库
description: 按仓库类型执行 npm publish,可以将包发布到 npm、github 等仓库,
如果是发布到 github 则会将 package.name 替换为 @${{ github.repository }}

inputs:
Expand All @@ -15,22 +14,22 @@ runs:
using: composite
steps:
- name: 仓库类型是 github
if: inputs.type == "github"
if: inputs.type == 'github'
run: |
echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" > .npmrc
echo "registry=https://npm.pkg.github.com/" >> .npmrc
echo "always-auth=true" >> .npmrc
shell: bash
- name: 修改 package.json name 为 @${{ github.repository }}
if: inputs.type == "github"
if: inputs.type == 'github'
uses: jaywcjlove/github-action-package@main
with:
data: |
{
"name": "@${{ github.repository }}"
}
- name: 仓库类型是 npm
if: inputs.type == "npm"
if: inputs.type == 'npm'
run: |
echo "//registry.npmjs.org/:_authToken=${{ inputs.token }}" > .npmrc
echo "registry=https://registry.npmjs.org/" >> .npmrc
Expand All @@ -39,9 +38,9 @@ runs:
- run: npm publish
shell: bash
- id: pkg
if: inputs.type == "npm"
if: inputs.type == 'npm'
uses: jaywcjlove/github-action-package@main
- name: 同步新版本到 npmmirror.com
if: inputs.type == "npm"
if: inputs.type == 'npm'
run: curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true
shell: bash