Files
在7楼 9e79ca09a1 维护[#1153]: 发布策略重构——CI 托管版本号与单主干 alpha/stable 通道 (#1160)
* chore: 补齐 agent 配置文档,版本升至 4.0.8 (#1152)

* docs(agents): 术语表迁到根目录 CONTEXT.md,补齐 agent 配置文档

新增 AGENTS.md 指向 issue tracker / triage 标签 / 领域文档三份说明,
docs/glossary.md 的内容改为 CONTEXT.md 的术语条目后删除。

* chore: VersionPrefix 升到 4.0.8

* docs(changelog): 开 4.0.8 段落

与 common.props 的 VersionPrefix 同号,否则 CI 的版本一致性校验会失败。

* docs: 版本与分支策略重构的 ADR-0002 与术语表(#1153)

* feat: CI 托管版本号的算号与 notes 生成脚本(#1154 #1155)

- version-next.sh:alpha/stable/latest 算号,权威源为 git tag 历史
- release-notes.sh:PR 标题分类生成 release notes 与 CHANGELOG 段落,不合规标题兜底
- 两个 fixture 测试套件(临时 git 仓库 / 模拟标题列表),并作为 ScriptTests job 纳入 PR CI

* refactor: code-review 修复——断言框架提取 test-lib、section 对齐 CHANGELOG 无空行风格、latest 复用 version-next.sh、补跨 major fixture 与错误信息断言

* feat: alpha 通道——main 合并自动推 alpha 镜像(#1156)

- 新增 alpha.yml:version-next.sh 算号,推 :x.y.z-alpha.N + :alpha 到 DockerHub/GHCR,串行防撞号
- Dockerfile:ARG VERSION 完整版本显式注入(构建时烘焙),补 OCI version LABEL;VERSION_SUFFIX 暂时兼容
- ci.yml ScriptTests:真实 tag 历史上的 alpha dry-run 冒烟

* feat: 稳定版通道——手动触发,全套制品 + CHANGELOG 回写(#1157)

- workflow_dispatch 下拉 patch/minor/major,version-next.sh 算号
- release-notes.sh 生成 notes(无合并 PR 时发版失败,不发空版本)
- softprops/action-gh-release 建 tag 与 Release(重跑幂等)
- 镜像 :x.y.z + :latest,显式 VERSION 注入
- CHANGELOG 段落 bot 回写 main([skip ci] 防触发 alpha)

* refactor: 拆除旧发布体系,版本权威源切换为 git tag 历史(#1158)

- common.props:VersionPrefix 0.0.0 + VersionSuffix dev,仅本地兜底(已验证宿主产物为 0.0.0-dev)
- ci.yml:删版本一致性校验与播报步骤,PR 目标收窄为 main
- 删除 preview-image/release/verify-pr-target 三个旧 workflow 与 version.sh/report-version.sh
- publish.sh:版本与 notes 改用新脚本
- codeql/dependabot/README 的 develop 引用改为 main

* fix: code-review 修复——Console zip 显式注入程序集版本、changelog 逻辑入脚本、platforms 断链修復

- publish.sh:dotnet publish 补 -p:Version,否则 zip 内程序集恒为 0.0.0-dev(Spec 轴关键发现);本地兜底统一为 0.0.0-dev
- Dockerfile:删除已无调用方的 VERSION_SUFFIX 遗留分支
- 提取 update-changelog.sh(重跑安全:同版本段落替换而非重复插入)+ 5 个 fixture,纳入 ScriptTests
- 术语对齐 CONTEXT.md:避免词「预览镜像」改为「alpha 版本镜像」
- platforms:青龙 QL_BRANCH 默认改 main,baihu/daidai/qinglong 脚本内 blob/develop 链接改 main,两份 README 的先行版说明对齐单主干
2026-09-28 01:24:53 +08:00

111 lines
3.6 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# version-next.sh 的 fixture 测试:在临时 git 仓库里构造 tag 与提交序列,
# 断言算号结果。只测脚本 CLI 的外部行为(给定 git 历史 -> 版本号),不测实现细节。
#
# 本地/CI 通用:bash ./scripts/test-version-next.sh
set -euo pipefail
repo_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
sut="$repo_dir/scripts/version-next.sh"
source "$repo_dir/scripts/test-lib.sh"
# 在临时目录造一个 git 仓库,全局变量 FIX 指向它
FIX=""
new_fixture() {
FIX=$(mktemp -d)
git -C "$FIX" init -q -b main
git -C "$FIX" config user.email ci@example.com
git -C "$FIX" config user.name ci
git -C "$FIX" commit -q --allow-empty -m "init"
}
commit() { # <msg>:在 fixture 仓库里加一个空提交
git -C "$FIX" commit -q --allow-empty -m "$1"
}
tag() { # <tag>:在 fixture 仓库当前位置打 tag
git -C "$FIX" tag "$1"
}
run() { # <子命令...>:对 fixture 仓库执行被测脚本
VERSION_REPO_DIR="$FIX" bash "$sut" "$@"
}
cleanup() {
# 只在 CI 上主动删除 fixture 目录;本地跑时留着由操作系统清,
# 某些本地沙箱会对 rm -rf 临时目录直接 SIGTERM,把测试进程一起带走。
[ -n "$FIX" ] || return 0
if [ "${CI:-}" = "true" ]; then rm -rf "$FIX" 2>/dev/null || true; fi
FIX=""
}
trap cleanup EXIT
# --- 场景 1:无任何 tag(首次发版场景),版本线从 0.1.0 起步 ---
new_fixture
commit "a"; commit "b"
assert_eq "无 tag: alpha 基底为 0.1.0,N=提交数" "0.1.0-alpha.3" "$(run alpha)"
assert_eq "无 tag: stable patch 兜底 0.1.0" "0.1.0" "$(run stable patch)"
assert_eq "无 tag: stable minor 兜底 0.1.0" "0.1.0" "$(run stable minor)"
assert_eq "无 tag: stable major 兜底 0.1.0" "0.1.0" "$(run stable major)"
assert_eq "无 tag: latest 输出空" "" "$(run latest)"
cleanup
# --- 场景 2:稳定 tag 后的连续 alpha ---
new_fixture
commit "c1"; tag "4.0.7"
commit "c2"
assert_eq "首个 alpha: 基底=下一 patch,N=1" "4.0.8-alpha.1" "$(run alpha)"
commit "c3"; commit "c4"
assert_eq "第三个 alpha: N=3" "4.0.8-alpha.3" "$(run alpha)"
assert_eq "latest 为最新稳定 tag" "4.0.7" "$(run latest)"
cleanup
# --- 场景 3:stable 按级别 bump ---
new_fixture
commit "c1"; tag "4.0.7"
commit "c2"
assert_eq "patch bump" "4.0.8" "$(run stable patch)"
assert_eq "minor bump" "4.1.0" "$(run stable minor)"
assert_eq "major bump" "5.0.0" "$(run stable major)"
assert_exit_nonzero "未知级别报错" run stable banana
cleanup
# --- 场景 4:发稳定版后 alpha 序号复位、基底前移 ---
new_fixture
commit "c1"; tag "4.0.7"
commit "c2"; tag "4.0.8" # 模拟发了 4.0.8
commit "c3"
assert_eq "发版后首个 alpha: 基底=4.0.9,N 复位为 1" "4.0.9-alpha.1" "$(run alpha)"
cleanup
new_fixture
commit "c1"; tag "4.1.0" # 跨 minor 发版之后
commit "c2"
assert_eq "跨 minor 后: alpha 基底为其下一 patch" "4.1.1-alpha.1" "$(run alpha)"
cleanup
new_fixture
commit "c1"; tag "5.0.0" # 跨 major 发版之后
commit "c2"
assert_eq "跨 major 后: alpha 基底为其下一 patch" "5.0.1-alpha.1" "$(run alpha)"
cleanup
# --- 场景 5:异类 tag 不算稳定 tag ---
new_fixture
commit "c1"; tag "v4.0.0.6" # 历史 v 前缀异类
commit "c2"; tag "4.0.8-alpha.1" # alpha tag 不是稳定版
commit "c3"; tag "3.8.2"
commit "c4"
assert_eq "v 前缀与 alpha tag 被排除" "3.8.2" "$(run latest)"
assert_eq "alpha 基于最新纯数字 tag" "3.8.3-alpha.1" "$(run alpha)"
cleanup
# --- 场景 6:守卫 ---
new_fixture
commit "c1"; tag "4.0.7"
assert_exit_nonzero "HEAD 无新提交时 alpha 报错" run alpha
cleanup
finish