aaden-cli 1.6.102 → 1.6.103-rc.2
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/.github/workflows/publish.yml +97 -0
- package/README.md +20 -0
- package/dist/index.js +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
# 推 tag 后发布到 npm,走 npm Trusted Publishing(OIDC):不需要 npm token,也不需要 OTP。
|
|
4
|
+
# npmjs.com 上 aaden-cli 的 Trusted Publisher 必须登记这个文件名(publish.yml)并允许 npm publish,改名要同步改那边。
|
|
5
|
+
#
|
|
6
|
+
# - `x.y.z`(`npm run update` 打的)→ npm `latest`。
|
|
7
|
+
# ⚠️ 全网约 650 台设备每天 04:55 `npm install aaden-cli -g` 装 latest:发出去就等于全网发布。
|
|
8
|
+
# - `x.y.z-任意后缀`(如 1.6.103-rc.0,任何分支都可以打)→ npm `next`,设备不会自动装。
|
|
9
|
+
# 用来灰度:在某台设备上 `sudo npm i -g aaden-cli@next` 先试;那台设备第二天 04:55 会自己回到 latest。
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
tags:
|
|
13
|
+
- '[0-9]+.[0-9]+.[0-9]+'
|
|
14
|
+
- '[0-9]+.[0-9]+.[0-9]+-*'
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: write # 发布成功后建 GitHub Release
|
|
18
|
+
id-token: write # Trusted Publishing 用 OIDC 换发布权限
|
|
19
|
+
|
|
20
|
+
concurrency:
|
|
21
|
+
group: npm-publish
|
|
22
|
+
cancel-in-progress: false
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
publish:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v6
|
|
29
|
+
with:
|
|
30
|
+
fetch-depth: 0
|
|
31
|
+
|
|
32
|
+
- uses: actions/setup-node@v6
|
|
33
|
+
with:
|
|
34
|
+
node-version: '24'
|
|
35
|
+
registry-url: 'https://registry.npmjs.org'
|
|
36
|
+
package-manager-cache: false
|
|
37
|
+
|
|
38
|
+
- name: 决定发布渠道
|
|
39
|
+
id: channel
|
|
40
|
+
run: |
|
|
41
|
+
if [[ "$GITHUB_REF_NAME" == *-* ]]; then
|
|
42
|
+
echo "dist_tag=next" >> "$GITHUB_OUTPUT"
|
|
43
|
+
else
|
|
44
|
+
echo "dist_tag=latest" >> "$GITHUB_OUTPUT"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
- name: 校验 tag(latest)
|
|
48
|
+
if: steps.channel.outputs.dist_tag == 'latest'
|
|
49
|
+
run: |
|
|
50
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
51
|
+
if [ "$GITHUB_REF_NAME" != "$VERSION" ]; then
|
|
52
|
+
echo "::error::tag $GITHUB_REF_NAME 和 package.json 的版本 $VERSION 不一致"
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
# 只发 master 上的提交:从别的分支推个 tag 不能直接发到全网
|
|
56
|
+
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/master; then
|
|
57
|
+
echo "::error::tag $GITHUB_REF_NAME 指向的提交不在 master 上"
|
|
58
|
+
exit 1
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
# 预发布的版本号以 tag 为准,不用为了灰度去提交一次版本号
|
|
62
|
+
- name: 写入预发布版本号(next)
|
|
63
|
+
if: steps.channel.outputs.dist_tag == 'next'
|
|
64
|
+
run: npm version "$GITHUB_REF_NAME" --no-git-tag-version
|
|
65
|
+
|
|
66
|
+
- run: npm ci
|
|
67
|
+
|
|
68
|
+
- name: 打包
|
|
69
|
+
run: npx ncc build index.js -o dist -C
|
|
70
|
+
|
|
71
|
+
- name: 冒烟检查
|
|
72
|
+
run: |
|
|
73
|
+
OUT=$(node dist/index.js --version | tail -n 1)
|
|
74
|
+
if [ "$OUT" != "$GITHUB_REF_NAME" ]; then
|
|
75
|
+
echo "::error::dist/index.js --version 输出「$OUT」,期望 $GITHUB_REF_NAME"
|
|
76
|
+
exit 1
|
|
77
|
+
fi
|
|
78
|
+
npm pack --dry-run 2>&1 | grep -q 'dist/index.js' || {
|
|
79
|
+
echo "::error::npm 包里没有 dist/index.js"
|
|
80
|
+
exit 1
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# 私有仓库不支持 provenance,显式关掉免得 publish 失败
|
|
84
|
+
- name: 发布到 npm
|
|
85
|
+
env:
|
|
86
|
+
NPM_CONFIG_PROVENANCE: 'false'
|
|
87
|
+
run: npm publish --tag "${{ steps.channel.outputs.dist_tag }}"
|
|
88
|
+
|
|
89
|
+
- name: GitHub Release
|
|
90
|
+
if: steps.channel.outputs.dist_tag == 'latest'
|
|
91
|
+
env:
|
|
92
|
+
GH_TOKEN: ${{ github.token }}
|
|
93
|
+
run: |
|
|
94
|
+
gh release create "$GITHUB_REF_NAME" \
|
|
95
|
+
--title "aaden-cli: release v$GITHUB_REF_NAME" \
|
|
96
|
+
--generate-notes \
|
|
97
|
+
--verify-tag
|
package/README.md
CHANGED
|
@@ -35,3 +35,23 @@ Commands:
|
|
|
35
35
|
help [command] display help for command
|
|
36
36
|
|
|
37
37
|
```
|
|
38
|
+
|
|
39
|
+
## 发布
|
|
40
|
+
|
|
41
|
+
1. 在 master 上运行 `npm run update`:release-it 把版本号升一个 patch,提交 `aaden-cli: release vX.Y.Z`,打 tag `X.Y.Z` 并推上去。本地不再发布 npm。
|
|
42
|
+
要在普通 clone 里运行:release-it 13 认不出 `git worktree`,在 worktree 里只会改版本号,不会提交、打 tag。
|
|
43
|
+
2. tag 推上去后,GitHub Actions 的 `.github/workflows/publish.yml` 自动执行:
|
|
44
|
+
- 校验 tag 和 `package.json` 的版本一致,并且 tag 指向的提交在 master 上;
|
|
45
|
+
- 从这个 tag 对应的提交 `npm ci` 并用 ncc 打包,冒烟检查 `dist/index.js --version`;
|
|
46
|
+
- 用 npm Trusted Publishing(OIDC)执行 `npm publish`,不需要 npm token 或 OTP;
|
|
47
|
+
- 创建 GitHub Release。
|
|
48
|
+
3. 全网设备在第二天 04:55 自动 `npm install aaden-cli -g` 装上新版本。
|
|
49
|
+
|
|
50
|
+
⚠️ `latest` 一发布就是全网发布。要先在个别设备上试,用预发布通道:
|
|
51
|
+
|
|
52
|
+
- 在任意分支的提交上打 `x.y.z-后缀` 形式的 tag(如 `1.6.103-rc.0`)并推上去,CI 会把这个提交按 tag 的版本号发到 npm 的 `next`(不需要提交版本号)。
|
|
53
|
+
- 设备每天只装 `latest`,不会自动装 `next`。要试的设备上手动运行 `sudo npm i -g aaden-cli@next`;这台设备第二天 04:55 会自动回到 `latest`。
|
|
54
|
+
|
|
55
|
+
CI 发布失败时的手动兜底:在 tag 对应的提交上运行 `npx ncc build index.js -o dist -C && npm publish`(需要 npm 2FA)。
|
|
56
|
+
|
|
57
|
+
一次性配置:npmjs.com → aaden-cli → Settings → Trusted Publisher → GitHub Actions,填组织 `innerken-gmbh`、仓库 `aaden-cli`、workflow `publish.yml`;允许的操作要勾上 `npm publish`(2026-09-03 之后新建的配置默认只允许 `npm stage publish`,直接 publish 会报 403 "OIDC permission denied for this action")。
|
package/dist/index.js
CHANGED
|
@@ -18577,7 +18577,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
|
|
|
18577
18577
|
/***/ ((module) => {
|
|
18578
18578
|
|
|
18579
18579
|
"use strict";
|
|
18580
|
-
module.exports = {"i8":"1.6.
|
|
18580
|
+
module.exports = JSON.parse('{"i8":"1.6.103-rc.2"}');
|
|
18581
18581
|
|
|
18582
18582
|
/***/ })
|
|
18583
18583
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aaden-cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.103-rc.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,12 @@
|
|
|
21
21
|
"hooks": {
|
|
22
22
|
"after:bump": "ncc build index.js -o dist -C"
|
|
23
23
|
},
|
|
24
|
-
"
|
|
24
|
+
"npm": {
|
|
25
|
+
"publish": false
|
|
26
|
+
},
|
|
27
|
+
"github": {
|
|
28
|
+
"release": false
|
|
29
|
+
},
|
|
25
30
|
"git": {
|
|
26
31
|
"commitMessage": "aaden-cli: release v${version}",
|
|
27
32
|
"requireCleanWorkingDir": false
|