gm-printer 10.41.9 → 10.41.10-beta.1.16.3.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.
|
@@ -7,6 +7,15 @@ on:
|
|
|
7
7
|
push:
|
|
8
8
|
tags:
|
|
9
9
|
- 'v*'
|
|
10
|
+
# 分支推送自动发 beta 预发布包(供宿主灰度/验证):
|
|
11
|
+
# - hotfix/**、hotfix-*:hotfix 分支(从全量版本对应 tag 拉出),patch+1 版本
|
|
12
|
+
# - feature/latest*、release/**、release-*:周期分支,minor+1 版本
|
|
13
|
+
branches:
|
|
14
|
+
- 'hotfix/**'
|
|
15
|
+
- 'hotfix-*'
|
|
16
|
+
- 'feature/latest*'
|
|
17
|
+
- 'release/**'
|
|
18
|
+
- 'release-*'
|
|
10
19
|
|
|
11
20
|
jobs:
|
|
12
21
|
release:
|
|
@@ -22,29 +31,89 @@ jobs:
|
|
|
22
31
|
node-version: 16.x
|
|
23
32
|
registry-url: 'https://registry.npmjs.org'
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
|
|
27
34
|
- name: Setup
|
|
28
35
|
run: npm i -g @antfu/ni@29.0.0
|
|
29
36
|
|
|
30
37
|
- name: Install
|
|
31
38
|
run: nci
|
|
32
39
|
|
|
40
|
+
# 分支推送时自动生成预发布版本号(只用于本次发布,不改分支上的文件):
|
|
41
|
+
# - hotfix 分支: patch+1 + 宿主 hotfix 版本,如 10.41.9 -> 10.41.10-beta.1.16.3.1
|
|
42
|
+
# 末尾序号 = npm 上同前缀已发布版本的最大序号 + 1,首次从 1 开始,每次 push 即一次发版;
|
|
43
|
+
# 分支名非"数字.数字"形式(如 hotfix/longPrint_0624)时回退全局运行序号保证唯一
|
|
44
|
+
# - 周期分支: minor+1,如 10.41.9 -> 10.42.0-beta.N(N 为全局运行序号),与 hotfix 的 patch 序列隔离
|
|
45
|
+
- name: Bump pre-release version
|
|
46
|
+
if: startsWith(github.ref, 'refs/heads/')
|
|
47
|
+
run: |
|
|
48
|
+
if [[ ${{ github.ref }} == refs/heads/hotfix* ]]; then
|
|
49
|
+
BASE=$(node -p "const p = require('./package.json').version.split('-')[0].split('.'); p[2] = Number(p[2]) + 1; p.join('.')")
|
|
50
|
+
HOTFIX=${GITHUB_REF_NAME#hotfix/}
|
|
51
|
+
if [[ $HOTFIX =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
|
|
52
|
+
COUNT=$(npm view gm-printer versions --json 2>/dev/null | PREFIX="$BASE-beta.$HOTFIX." node -e '
|
|
53
|
+
let d = ""
|
|
54
|
+
process.stdin.on("data", c => (d += c)).on("end", () => {
|
|
55
|
+
const list = JSON.parse(d || "[]")
|
|
56
|
+
const nums = list
|
|
57
|
+
.filter(v => v.startsWith(process.env.PREFIX))
|
|
58
|
+
.map(v => Number(v.slice(process.env.PREFIX.length)))
|
|
59
|
+
.filter(n => Number.isInteger(n))
|
|
60
|
+
console.log(nums.length ? Math.max(...nums) : 0)
|
|
61
|
+
})
|
|
62
|
+
')
|
|
63
|
+
COUNT=${COUNT:-0}
|
|
64
|
+
VERSION="$BASE-beta.$HOTFIX.$((COUNT + 1))"
|
|
65
|
+
else
|
|
66
|
+
VERSION="$BASE-beta.${{ github.run_number }}"
|
|
67
|
+
fi
|
|
68
|
+
else
|
|
69
|
+
VERSION=$(node -p "const p = require('./package.json').version.split('-')[0].split('.'); p[1] = Number(p[1]) + 1; p[2] = 0; p.join('.')")
|
|
70
|
+
VERSION="$VERSION-beta.${{ github.run_number }}"
|
|
71
|
+
fi
|
|
72
|
+
npm version "$VERSION" --no-git-tag-version
|
|
73
|
+
echo "本次分支推送发布版本: $VERSION (dist-tag: beta)" | tee -a "$GITHUB_STEP_SUMMARY"
|
|
74
|
+
|
|
75
|
+
# hotfix 发布前差异审查:列出包内相对 npm 全量(latest)版本的全部提交,写入 Actions Summary 与运行日志。
|
|
76
|
+
# hotfix 包应只包含目标修复提交;若清单中出现周期需求提交,说明分支基线不对,应停止发布。
|
|
77
|
+
- name: Audit commits vs npm latest
|
|
78
|
+
if: startsWith(github.ref, 'refs/heads/hotfix')
|
|
79
|
+
run: |
|
|
80
|
+
LATEST=$(npm dist-tag ls gm-printer | awk '/^latest:/ {print $2}')
|
|
81
|
+
if [ -n "$LATEST" ]; then
|
|
82
|
+
git fetch -q origin "refs/tags/v$LATEST:refs/tags/v$LATEST"
|
|
83
|
+
fi
|
|
84
|
+
if [ -n "$LATEST" ] && git rev-parse -q --verify "v$LATEST" >/dev/null; then
|
|
85
|
+
{
|
|
86
|
+
echo "## Hotfix 差异审查(npm latest: v$LATEST)"
|
|
87
|
+
echo "hotfix 包应只包含目标修复提交,以下为 v$LATEST..HEAD 的全部提交:"
|
|
88
|
+
echo '```'
|
|
89
|
+
git log --oneline "v$LATEST..HEAD"
|
|
90
|
+
echo '```'
|
|
91
|
+
} >> "$GITHUB_STEP_SUMMARY"
|
|
92
|
+
echo "Hotfix 差异审查(npm latest: v$LATEST),v$LATEST..HEAD 的全部提交:"
|
|
93
|
+
git log --oneline "v$LATEST..HEAD"
|
|
94
|
+
else
|
|
95
|
+
echo "未找到全量版本 v$LATEST 对应的 tag,跳过差异审查" | tee -a "$GITHUB_STEP_SUMMARY"
|
|
96
|
+
fi
|
|
97
|
+
|
|
33
98
|
- name: Build
|
|
34
99
|
run: npm run build
|
|
35
100
|
|
|
36
101
|
- name: Release
|
|
37
102
|
run: |
|
|
38
|
-
if [[ ${{ github.ref }} ==
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
103
|
+
if [[ ${{ github.ref }} == refs/tags/* ]]; then
|
|
104
|
+
if [[ ${{ github.ref }} == *-beta* ]]; then
|
|
105
|
+
npm publish --tag beta
|
|
106
|
+
elif [[ ${{ github.ref }} == *-alpha* ]]; then
|
|
107
|
+
npm publish --tag alpha
|
|
108
|
+
else
|
|
109
|
+
npm publish
|
|
110
|
+
fi
|
|
42
111
|
else
|
|
43
|
-
npm publish
|
|
112
|
+
npm publish --tag beta
|
|
44
113
|
fi
|
|
45
114
|
env:
|
|
46
115
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
47
116
|
# - name: ChangeLog
|
|
48
117
|
# run: npx changelogithub
|
|
49
118
|
# env:
|
|
50
|
-
# GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
119
|
+
# GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|