feat(ci): promote.sh 支持 pin-acr —— 选 ACR 已有 tag 原样钉入客户目录

镜像搬运已剥离给门户「直推 ACR」(crane);发布侧新增 PLAN action pin-acr:
- PLAN: {"service":..,"action":"pin-acr","acrTag":"<ACR 已有 tag>"}
- 不进交付基线(不搬运不 retag),不触发版本号分配(搭纯复用通路)
- pin: image-version 钉所选 tag;chart targetRevision 保持不变(ArgoCD 由 values 变更 sync)
- release-notes/commit message 如实记 from→to 与 sourceTag

本地 PROMOTE_DRY_RUN 全链演练通过(mxlexus:sso v1.0.1 → probe-pin-acr-dryrun)
This commit is contained in:
ximenchuifeng committed 2026-09-08 11:29:37 +08:00
1 parent b1eb05c7a6
commit 8b4f3efa9f
1 file changed
+27 -5
+27 -5
View File
@@ -24,6 +24,9 @@
# reuse(复用已交付版本 version,镜像已在 ACR 不重推) # reuse(复用已交付版本 version,镜像已在 ACR 不重推)
# deliver(harborTag 为未交付过的 Harbor tag,缺省取 demo 当前,retag 到新版本号) # deliver(harborTag 为未交付过的 Harbor tag,缺省取 demo 当前,retag 到新版本号)
# ci-now(行为同 deliver,仅 release-notes 如实记录为 ci-now) # ci-now(行为同 deliver,仅 release-notes 如实记录为 ci-now)
# pin-acr(acrTag 为 ACR 上已有 tag,原样钉进客户目录,不搬运不 retag——
# 镜像搬运已剥离给门户「直推 ACR」;版本号即所选 tag 名,
# chart 引用保持不变,ArgoCD 由 values 变更触发 sync)
# 兼容参数: SERVICES=sso,agent(=这些服务 deliver,其余 keep) # 兼容参数: SERVICES=sso,agent(=这些服务 deliver,其余 keep)
# IMAGES=sso=tagX(=该服务 deliver 且显式 harborTag;逗号分隔多个) # IMAGES=sso=tagX(=该服务 deliver 且显式 harborTag;逗号分隔多个)
# PLAN 存在时优先;全部缺省 = 6 服务全 deliver demo 当前 tag(与改造前一致) # PLAN 存在时优先;全部缺省 = 6 服务全 deliver demo 当前 tag(与改造前一致)
@@ -32,8 +35,8 @@
# 版本号分配: # 版本号分配:
# 有 deliver/ci-now(或 CHART_ONLY=true)→ 需要新版本号(RELEASE_VERSION 缺省 auto-bump); # 有 deliver/ci-now(或 CHART_ONLY=true)→ 需要新版本号(RELEASE_VERSION 缺省 auto-bump);
# chart tag 已存在不再拒绝,记 CHART_TAG_EXISTS=true 复用(幂等,可同参数重跑/同版本发多客户) # chart tag 已存在不再拒绝,记 CHART_TAG_EXISTS=true 复用(幂等,可同参数重跑/同版本发多客户)
# 全部 keep/reuse(纯复用发布)→ 不分配新版本号,chart 步骤跳过, # 全部 keep/reuse/pin-acr(纯复用发布)→ 不分配新版本号,chart 步骤跳过,
# reuse 服务 chart targetRevision 各指已有 chart-<version> # reuse 服务 chart targetRevision 各指已有 chart-<version>;pin-acr 服务 chart 引用不动
# #
# 其他参数: # 其他参数:
# CHART_ONLY=true 只发 chart:prepare 跳过镜像基线与 Harbor 校验,retag 整步跳过, # CHART_ONLY=true 只发 chart:prepare 跳过镜像基线与 Harbor 校验,retag 整步跳过,
@@ -146,7 +149,7 @@ HARBOR_HOST = os.environ.get("HARBOR_HOST", "192.168.1.119:8888")
# ── 服务映射常量表(pin 步骤经 .plan.json 继承同一份定义,勿另起副本)── # ── 服务映射常量表(pin 步骤经 .plan.json 继承同一份定义,勿另起副本)──
ALL = ["gateway", "sso", "ultra", "audit", "agent", "edge"] ALL = ["gateway", "sso", "ultra", "audit", "agent", "edge"]
ACTIONS = ["keep", "reuse", "deliver", "ci-now"] ACTIONS = ["keep", "reuse", "deliver", "ci-now", "pin-acr"]
# 服务 → 镜像 repo 列表(前后端共用同一 tag) # 服务 → 镜像 repo 列表(前后端共用同一 tag)
REPOS = { REPOS = {
"gateway": ["gateway"], "gateway": ["gateway"],
@@ -254,6 +257,11 @@ for e in entries:
tag = str(e.get("harborTag") or "").strip() tag = str(e.get("harborTag") or "").strip()
n["harborTag"] = tag or demo_tag(svc) n["harborTag"] = tag or demo_tag(svc)
n["harborTagExplicit"] = bool(tag) n["harborTagExplicit"] = bool(tag)
elif action == "pin-acr":
tag = str(e.get("acrTag") or "").strip()
if not tag:
die(f"pin-acr 服务 {svc} 需提供 acrTag(ACR 上已有的 tag 名)")
n["acrTag"] = tag
norm[svc] = n norm[svc] = n
plan_out = [norm.get(s) or {"service": s, "action": "keep", plan_out = [norm.get(s) or {"service": s, "action": "keep",
"repos": REPOS[s], "keys": KEYS[s], "appFile": APPFILE[s]} "repos": REPOS[s], "keys": KEYS[s], "appFile": APPFILE[s]}
@@ -329,7 +337,7 @@ open(plantxt_path, "w", encoding="utf-8").write(raw_plan or json.dumps(plan_out,
for e in plan_out: for e in plan_out:
if e["action"] == "keep": if e["action"] == "keep":
continue continue
print(f"[promote] 计划: {e['service']:<8} {e['action']:<8} {e.get('harborTag') or e.get('version') or ''}") print(f"[promote] 计划: {e['service']:<8} {e['action']:<8} {e.get('harborTag') or e.get('version') or e.get('acrTag') or ''}")
print(f"[promote] DB 变更服务: {', '.join(db_change) or '无'}") print(f"[promote] DB 变更服务: {', '.join(db_change) or '无'}")
PY PY
. "$FACTS_FILE" # HAS_DELIVER=true|false . "$FACTS_FILE" # HAS_DELIVER=true|false
@@ -541,7 +549,12 @@ if not CHART_ONLY:
images = data.get("images") or {} images = data.get("images") or {}
for e in actions: for e in actions:
svc = e["service"] svc = e["service"]
new_tag = RELEASE_VERSION if e["action"] in ("deliver", "ci-now") else e["version"] if e["action"] in ("deliver", "ci-now"):
new_tag = RELEASE_VERSION
elif e["action"] == "pin-acr":
new_tag = e["acrTag"] # 所选 ACR tag 原样钉入,不 retag
else:
new_tag = e["version"]
to_tags[svc] = new_tag to_tags[svc] = new_tag
for i, key in enumerate(e["keys"]): for i, key in enumerate(e["keys"]):
node = images.get(key) node = images.get(key)
@@ -586,6 +599,10 @@ def retarget(path, new_ref, required):
return old_ref, new_ref return old_ref, new_ref
for e in actions: for e in actions:
if e["action"] == "pin-acr":
# pin-acr 只钉镜像 tag,chart 引用保持不变(values 变更即可触发 ArgoCD sync)
print(f"[promote] {e['service']}: chart 引用保持不变(pin-acr)")
continue
new_ref = CHART_TAG if e["action"] in ("deliver", "ci-now") else f"chart-{e['version']}" new_ref = CHART_TAG if e["action"] in ("deliver", "ci-now") else f"chart-{e['version']}"
r = retarget(os.path.join(appdir, e["appFile"]), new_ref, required=True) r = retarget(os.path.join(appdir, e["appFile"]), new_ref, required=True)
if r: if r:
@@ -634,6 +651,11 @@ for e in actions:
digest = digests.get(e["repos"][0], "") digest = digests.get(e["repos"][0], "")
if not digest: if not digest:
print(f"[promote] 警告: {svc} 未取到镜像 digest,release-notes 留空") print(f"[promote] 警告: {svc} 未取到镜像 digest,release-notes 留空")
elif action == "pin-acr":
# 源即 ACR 上所选 tag 本身,如实记;未搬运,无 digest
frm, to = from_tags.get(svc, ""), to_tags.get(svc, "")
source_tag = e.get("acrTag", "")
digest = ""
else: # reuse else: # reuse
frm, to = from_tags.get(svc, ""), e["version"] frm, to = from_tags.get(svc, ""), e["version"]
source_tag, digest = find_reuse_source(svc, e["version"]) source_tag, digest = find_reuse_source(svc, e["version"])