@@ -68,19 +68,60 @@ jobs:
6868 if git merge --no-ff --no-edit "origin/${SOURCE_BRANCH}"; then
6969 MERGE_STATUS="clean"
7070 else
71- # Auto-resolve release artifact conflicts: keep stable's version.
71+ normalize_json_without_keys() {
72+ python3 -c 'import json, sys; data = json.load(sys.stdin); [data.pop(key, None) for key in sys.argv[1:]]; sys.stdout.write(json.dumps(data, sort_keys=True, separators=(",", ":")))' "$@"
73+ }
74+
75+ release_artifact_only_conflict() {
76+ local f="$1"
77+ local tmpdir
78+ local status
79+ tmpdir="$(mktemp -d)"
80+
81+ case "$f" in
82+ package.json|*/package.json)
83+ git show ":2:${f}" | normalize_json_without_keys version > "${tmpdir}/ours" || { rm -rf "${tmpdir}"; return 1; }
84+ git show ":3:${f}" | normalize_json_without_keys version > "${tmpdir}/theirs" || { rm -rf "${tmpdir}"; return 1; }
85+ ;;
86+ pyproject.toml|*/pyproject.toml)
87+ git show ":2:${f}" | sed -E '/^[[:space:]]*version[[:space:]]*=/d' > "${tmpdir}/ours" || { rm -rf "${tmpdir}"; return 1; }
88+ git show ":3:${f}" | sed -E '/^[[:space:]]*version[[:space:]]*=/d' > "${tmpdir}/theirs" || { rm -rf "${tmpdir}"; return 1; }
89+ ;;
90+ version.json|*/version.json)
91+ git show ":2:${f}" | normalize_json_without_keys version sdkVersion > "${tmpdir}/ours" || { rm -rf "${tmpdir}"; return 1; }
92+ git show ":3:${f}" | normalize_json_without_keys version sdkVersion > "${tmpdir}/theirs" || { rm -rf "${tmpdir}"; return 1; }
93+ ;;
94+ *)
95+ rm -rf "${tmpdir}"
96+ return 1
97+ ;;
98+ esac
99+
100+ cmp -s "${tmpdir}/ours" "${tmpdir}/theirs"
101+ status=$?
102+ rm -rf "${tmpdir}"
103+ return "${status}"
104+ }
105+
106+ # Auto-resolve release artifact conflicts only when the conflict is
107+ # version-only: keep stable's version, but never drop dependency,
108+ # script, export, or package metadata changes from main.
72109 # npm/PyPI already have stable's published version; downgrading to
73110 # main's track would break the next stable release. Mirrors the
74111 # auto-resolve in sync-patches.yml, biased the other direction.
75- git diff --name-only --diff-filter=U | while read -r f; do
112+ while read -r f; do
76113 case "$f" in
77114 package.json|*/package.json|pyproject.toml|*/pyproject.toml|version.json|*/version.json)
78- echo " Auto-resolving $f (keeping stable's version)"
79- git checkout --ours "$f"
80- git add "$f"
115+ if release_artifact_only_conflict "$f"; then
116+ echo " Auto-resolving $f (version-only; keeping stable's version)"
117+ git checkout --ours "$f"
118+ git add "$f"
119+ else
120+ echo " Leaving $f unresolved (contains non-version changes)"
121+ fi
81122 ;;
82123 esac
83- done
124+ done < <(git diff --name-only --diff-filter=U)
84125
85126 if [ -z "$(git diff --name-only --diff-filter=U)" ]; then
86127 MERGE_STATUS="auto_resolved"
@@ -138,7 +179,7 @@ jobs:
138179
139180 - creates \`${BRANCH_NAME}\` from \`${BASE_BRANCH}\`
140181 - merges \`${SOURCE_BRANCH}\` into the candidate branch
141- - release artifact conflicts (package.json, pyproject.toml, version.json) auto-resolved to keep stable's published version
182+ - version-only release artifact conflicts (package.json, pyproject.toml, version.json) auto-resolved to keep stable's published version
142183
143184 ---
144185 _Auto-created by promote-stable workflow._
0 commit comments