Skip to content

Commit 9774bef

Browse files
authored
feat: support npm publish --provenance (#1)
pnpm/pnpm#6435
1 parent 8d2469e commit 9774bef

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

.github/workflows/node-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ on:
3333

3434
jobs:
3535
Release:
36+
permissions:
37+
id-token: write
3638
runs-on: ubuntu-latest
3739
defaults:
3840
run:
@@ -83,6 +85,7 @@ jobs:
8385
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8486
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
8587
DRYRUN: ${{ inputs.dryRun }}
88+
NPM_CONFIG_PROVENANCE: true
8689

8790
- name: Publish ${{ steps.release.outputs.name }}@${{ steps.release.outputs.release_version }}
8891
if: steps.release.outputs.release_version && !inputs.dryRun

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2022 Artus.js Working Group
4+
Copyright (c) 2023 - present node-modules and other contributors.
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
自动跑 Lint 和 Cov 单测
1414

15-
> 参考示例:https://github.com/artus-cli/examples/actions
16-
15+
> 参考示例:<https://github.com/artus-cli/examples/actions>
1716
1817
- 配置 `npm scripts`
1918

@@ -40,21 +39,40 @@ on:
4039
pull_request:
4140
branches: [ master, main, next, beta, '*.x' ]
4241

43-
schedule:
44-
- cron: '0 2 * * *'
45-
4642
workflow_dispatch: {}
4743

4844
jobs:
4945
Job:
5046
name: Node.js
51-
uses: artusjs/github-actions/.github/workflows/node-test.yml@v1
47+
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
5248
# 支持以下自定义配置,一般用默认值即可
5349
# with:
5450
# os: 'ubuntu-latest, macos-latest, windows-latest'
5551
# version: '16, 18'
5652
```
5753

54+
### 开启 MySQL 和 Redis 服务依赖
55+
56+
```yaml
57+
name: CI
58+
59+
on:
60+
push:
61+
branches: [ master ]
62+
63+
pull_request:
64+
branches: [ master ]
65+
66+
workflow_dispatch: {}
67+
68+
jobs:
69+
Job:
70+
name: Node.js
71+
uses: node-modules/github-actions/.github/workflows/node-test-mysql.yml@master
72+
with:
73+
os: 'ubuntu-latest'
74+
```
75+
5876
## 发布 NPM 包
5977
6078
使用 [semantic-release](https://semantic-release.gitbook.io/) 自动发布 NPM 包。
@@ -75,17 +93,18 @@ jobs:
7593
### 版本号规则
7694

7795
根据 Commit Message 自动计算下一个版本号:
78-
- major 大版本:`BREAKING CHANGE`
79-
- minor 特性版本: `feat:`
80-
- patch 补丁版本:`fix:`
81-
- 不发布版本: `chore:` / `docs:` / `style:`
82-
- 详见:https://github.com/semantic-release/commit-analyzer
96+
97+
- major 大版本:`BREAKING CHANGE`
98+
- minor 特性版本: `feat:` 等
99+
- patch 补丁版本:`fix:` 等
100+
- 不发布版本: `chore:` / `docs:` / `style:` 等
101+
- 详见:<https://github.com/semantic-release/commit-analyzer>
83102

84103
**注意:**
85-
- 不支持发布 0.x 版本,master 首次发布将是 1.0.0 版本
86-
- 如果你不期望直接发布,请在 beta 分支提交代码运行,将发布 `1.0.0-beta.1` 版本
87-
- 多版本发布实践参见 [semantic-release](https://semantic-release.gitbook.io/semantic-release/recipes/release-workflow/distribution-channels) 文档
88104

105+
- 不支持发布 0.x 版本,master 首次发布将是 1.0.0 版本
106+
- 如果你不期望直接发布,请在 beta 分支提交代码运行,将发布 `1.0.0-beta.1` 版本
107+
- 多版本发布实践参见 [semantic-release](https://semantic-release.gitbook.io/semantic-release/recipes/release-workflow/distribution-channels) 文档
89108

90109
### 配置方式
91110

@@ -116,7 +135,7 @@ on:
116135
jobs:
117136
release:
118137
name: Node.js
119-
uses: artusjs/github-actions/.github/workflows/node-release.yml@v1
138+
uses: node-modules/github-actions/.github/workflows/node-release.yml@master
120139
secrets:
121140
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
122141
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}

scripts/release/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function run() {
4343
core.setOutput('release_version', nextRelease.version);
4444

4545
// cnpm sync
46-
const res = await request(`https://registry-direct.npmmirror.com/-/package/${pkgInfo.name}/syncs`, { method: 'PUT' });
46+
const res = await request(`https://registry.npmmirror.com/-/package/${pkgInfo.name}/syncs`, { method: 'PUT' });
4747
const { id } = await res.body.json();
4848
const logUrl = `https://registry.npmmirror.com/-/package/${pkgInfo.name}/syncs/${id}/log`;
4949
core.setOutput('cnpm_sync_url', logUrl);

0 commit comments

Comments
 (0)