@peiyanlu/release 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/cli.mjs +1354 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.cts +51 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.mjs +25 -0
- package/index.js +3 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) $YEAR $OWNER
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Release Project
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<a href="https://www.npmjs.com/package/@peiyanlu/create-release" target="_blank">
|
|
5
|
+
<img src="https://img.shields.io/badge/npm-@peiyanlu/create--release-blue.svg?logo=npm" alt="NPM Package" />
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@peiyanlu/create-release" target="_blank">
|
|
8
|
+
<img src="https://img.shields.io/npm/v/@peiyanlu/create-release.svg" alt="NPM Version" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@peiyanlu/create-release" target="_blank">
|
|
11
|
+
<img src="https://img.shields.io/npm/l/@peiyanlu/create-release.svg" alt="Package License" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@peiyanlu/create-release" target="_blank">
|
|
14
|
+
<img src="https://img.shields.io/npm/dm/@peiyanlu/create-release.svg" alt="NPM Downloads" />
|
|
15
|
+
</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
🚀 Generic CLI tool to automate versioning and package publishing
|
|
20
|
+
|
|
21
|
+
- Bump version (in e.g. `package.json`)
|
|
22
|
+
- [Git commit, tag, push][1]
|
|
23
|
+
- [Create release at GitHub][3]
|
|
24
|
+
- [Generate changelog][5]
|
|
25
|
+
- [Publish to npm][6]
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -D @peiyanlu/release
|
|
31
|
+
|
|
32
|
+
yarn add -D @peiyanlu/release
|
|
33
|
+
|
|
34
|
+
pnpm add -D @peiyanlu/release
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
发布流程可以通过配置文件进行自定义。如果项目中没有提供配置文件,工具会自动使用内置的默认配置,配置文件可以是以下文件之一:`release.config.{ts,mts,cts,js,mjs,cjs}`
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// release.config.ts
|
|
43
|
+
import { defineConfig } from '@peiyanlu/release'
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export default defineConfig({
|
|
47
|
+
git: {
|
|
48
|
+
commitMessage: 'chore(release): ${version}',
|
|
49
|
+
tagName: '${version}',
|
|
50
|
+
},
|
|
51
|
+
npm: {
|
|
52
|
+
publish: true,
|
|
53
|
+
},
|
|
54
|
+
github: {
|
|
55
|
+
release: true,
|
|
56
|
+
autoGenerate: true,
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Git
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
将 **暂存(stage)→ 提交(commit)→ 打标签(tag)→ 推送(push)** 这些发布步骤自动化,并支持推送到 **任意 Git 远程仓库**。
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
## npmjs.com Releases
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
截至 **2025 年 7 月**,GitHub CI 工作流现在可以使用 npm 的 **[Trusted Publishing(可信发布)][30]** 的 **OpenID Connect(OIDC)** 集成,从 CI/CD 中实现**安全、无 Token 的发布**。
|
|
72
|
+
这将不再需要长期有效的访问令牌(long-lived tokens),并且会**自动生成来源证明(provenance attestations)**。
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## GitHub Releases
|
|
76
|
+
|
|
77
|
+
GitHub 项目可以将 **Release** 附加到 **Git 标签(Tag)** 上,其中包含 **发布说明(release notes)** 和 **构建产物(assets)**。
|
|
78
|
+
在你的发布流程中,有两种方式可以创建 **GitHub Releases**:
|
|
79
|
+
|
|
80
|
+
1. **自动化方式**(需要提供 `GITHUB_TOKEN`)
|
|
81
|
+
2. **手动方式**(通过 GitHub 网页界面,使用预先填充好的字段来创建)
|
|
82
|
+
|
|
83
|
+
## Changelog
|
|
84
|
+
|
|
85
|
+
通过读取 Git 提交历史(`git log`) 自动生成 Changelog
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git log --pretty=format:"%s %h %H" {from}...{to}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Publish to npm
|
|
92
|
+
|
|
93
|
+
通过读取 `package.json` 中的 `publishConfig` 配置发布到 npm 仓库
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## Dry Runs
|
|
97
|
+
|
|
98
|
+
使用 `--dry-run` 可以展示整个交互流程,以及工具原本将要执行的所有命令,但不会真正执行任何操作。
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
[1]: #git
|
|
102
|
+
|
|
103
|
+
[3]: #github-releases
|
|
104
|
+
|
|
105
|
+
[5]: #changelog
|
|
106
|
+
|
|
107
|
+
[6]: #publish-to-npm
|
|
108
|
+
|
|
109
|
+
[30]: https://docs.npmjs.com/trusted-publishers
|
|
110
|
+
|
|
111
|
+
[32]: https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases
|