Skip to content

Commit fe4629b

Browse files
authored
Merge pull request #87 from cloudcome/feat/v0.x
Feat/v0.x 2023-03-17 17:00:34
2 parents ad50ce0 + 1c54242 commit fe4629b

File tree

3 files changed

+62
-17
lines changed

3 files changed

+62
-17
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: npm publish
2+
description: |
3+
按仓库类型执行 npm publish,可以将包发布到 npm、github 等仓库
4+
如果是发布到 github 则会将 package.name 替换为 @${{ github.repository }}
5+
6+
inputs:
7+
type:
8+
description: 仓库类型,可选 npm/github
9+
required: true
10+
token:
11+
description: 仓库授权令牌,如果是非 github 仓库则需要指定
12+
required: false
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: 仓库类型是 github
18+
if: inputs.type == "github"
19+
run: |
20+
echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" > .npmrc
21+
echo "registry=https://npm.pkg.github.com/" >> .npmrc
22+
echo "always-auth=true" >> .npmrc
23+
shell: bash
24+
- name: 修改 package.json name 为 @${{ github.repository }}
25+
if: inputs.type == "github"
26+
uses: jaywcjlove/github-action-package@main
27+
with:
28+
data: |
29+
{
30+
"name": "@${{ github.repository }}"
31+
}
32+
- name: 仓库类型是 npm
33+
if: inputs.type == "npm"
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+
shell: bash
41+
- id: pkg
42+
if: inputs.type == "npm"
43+
uses: jaywcjlove/github-action-package@main
44+
- name: 同步新版本到 npmmirror.com
45+
if: inputs.type == "npm"
46+
run: curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true
47+
shell: bash

.github/workflows/code-review.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# 代码格式检查
2+
13
name: code review
24

35
on:
@@ -21,6 +23,7 @@ jobs:
2123
- uses: ./.github/actions/node-env
2224
- run: npm ci
2325
- run: npm run lint
26+
2427
test:
2528
runs-on: ubuntu-latest
2629
steps:

.github/workflows/release-please.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 如果是开发合并请求到主干,则会根据约定式提交创建一个 releasePR,是一个新版本合并请求。
2+
# 如果是新版本合并请求合并到主干,则会触发版本发布到 npm/github 等仓库。
3+
14
name: release please
25

36
on:
@@ -22,6 +25,7 @@ jobs:
2225
with:
2326
release-type: node
2427
bump-minor-pre-major: true
28+
2529
test-coverage:
2630
runs-on: ubuntu-latest
2731
needs: release
@@ -35,6 +39,7 @@ jobs:
3539
with:
3640
api-token: ${{ secrets.CODACY_API_TOKEN }}
3741
coverage-reports: coverage/lcov.info
42+
3843
publish-npm:
3944
runs-on: ubuntu-latest
4045
needs: test-coverage
@@ -43,14 +48,11 @@ jobs:
4348
- uses: ./.github/actions/node-env
4449
- run: npm ci
4550
- run: npm run build
46-
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
47-
- run: echo "registry=https://registry.npmjs.org/" >> .npmrc
48-
- run: echo "always-auth=true" >> .npmrc
49-
- run: npm publish
50-
- uses: jaywcjlove/github-action-package@main
51-
id: pkg
52-
- run: curl --silent -X PUT https://registry-direct.npmmirror.com/${{ steps.pkg.outputs.name }}/sync?sync_upstream=true
53-
name: Sync the new version to npmmirror.com
51+
- uses: ./.github/actions/npm-publish
52+
with:
53+
type: npm
54+
token: ${{ secrets.NPM_TOKEN }}
55+
5456
publish-github:
5557
runs-on: ubuntu-latest
5658
needs: test-coverage
@@ -59,13 +61,6 @@ jobs:
5961
- uses: ./.github/actions/node-env
6062
- run: npm ci
6163
- run: npm run build
62-
- run: echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" > .npmrc
63-
- run: echo "registry=https://npm.pkg.github.com/" >> .npmrc
64-
- run: echo "always-auth=true" >> .npmrc
65-
- uses: jaywcjlove/github-action-package@main
64+
- uses: ./.github/actions/npm-publish
6665
with:
67-
data: |
68-
{
69-
"name": "@${{ github.repository }}"
70-
}
71-
- run: npm publish
66+
type: github

0 commit comments

Comments
 (0)