|
31 | 31 | with: |
32 | 32 | app-id: ${{ secrets.APP_ID }} |
33 | 33 | private-key: ${{ secrets.APP_PRIVATE_KEY }} |
34 | | - permission-contents: write |
35 | | - permission-pull-requests: write |
36 | | - permission-workflows: write |
37 | 34 |
|
38 | 35 | - uses: actions/checkout@v6 |
39 | 36 | with: |
@@ -71,19 +68,60 @@ jobs: |
71 | 68 | if git merge --no-ff --no-edit "origin/${SOURCE_BRANCH}"; then |
72 | 69 | MERGE_STATUS="clean" |
73 | 70 | else |
74 | | - # 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. |
75 | 109 | # npm/PyPI already have stable's published version; downgrading to |
76 | 110 | # main's track would break the next stable release. Mirrors the |
77 | 111 | # auto-resolve in sync-patches.yml, biased the other direction. |
78 | | - git diff --name-only --diff-filter=U | while read -r f; do |
| 112 | + while read -r f; do |
79 | 113 | case "$f" in |
80 | 114 | package.json|*/package.json|pyproject.toml|*/pyproject.toml|version.json|*/version.json) |
81 | | - echo " Auto-resolving $f (keeping stable's version)" |
82 | | - git checkout --ours "$f" |
83 | | - 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 |
84 | 122 | ;; |
85 | 123 | esac |
86 | | - done |
| 124 | + done < <(git diff --name-only --diff-filter=U) |
87 | 125 |
|
88 | 126 | if [ -z "$(git diff --name-only --diff-filter=U)" ]; then |
89 | 127 | MERGE_STATUS="auto_resolved" |
@@ -141,7 +179,7 @@ jobs: |
141 | 179 |
|
142 | 180 | - creates \`${BRANCH_NAME}\` from \`${BASE_BRANCH}\` |
143 | 181 | - merges \`${SOURCE_BRANCH}\` into the candidate branch |
144 | | - - 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 |
145 | 183 |
|
146 | 184 | --- |
147 | 185 | _Auto-created by promote-stable workflow._ |
|
0 commit comments