Skip to content

Commit c459f80

Browse files
committed
Always start bump from a fresh release branch
Delete any pre-existing release/bump-v<ver> branch before creating it, so the version bump always sits directly on main's HEAD. Prevents STALE_DATA from createCommitOnBranch and avoids stacking multiple bump commits when a prior publish run failed partway through.
1 parent 70491db commit c459f80

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

.github/workflows/ci-stable.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,24 @@ jobs:
140140
raw = resp.read()
141141
return json.loads(raw) if raw else None
142142
143+
# Delete any pre-existing release branch (from a prior partial run)
144+
# so the bump always starts from main's HEAD. Avoids STALE_DATA from
145+
# createCommitOnBranch and prevents stacking multiple bump commits.
146+
# Any open PR on the stale branch gets auto-closed when the branch
147+
# is deleted, which is fine — we always open a fresh PR below.
143148
try:
144-
api(
145-
f"repos/{repo}/git/refs",
146-
method="POST",
147-
body={"ref": f"refs/heads/{branch}", "sha": head_oid},
148-
)
149-
expected_oid = head_oid
149+
api(f"repos/{repo}/git/refs/heads/{branch}", method="DELETE")
150+
print(f"deleted stale branch: {branch}")
150151
except urllib.error.HTTPError as error:
151-
if error.code != 422: # 422 = ref already exists; OK to reuse
152+
if error.code not in (404, 422): # ref doesn't exist; nothing to clean
152153
raise
153-
# Branch already exists (likely from a previous run); use its
154-
# actual tip as expectedHeadOid so createCommitOnBranch doesn't
155-
# fail with STALE_DATA.
156-
ref_info = api(f"repos/{repo}/git/ref/heads/{branch}")
157-
expected_oid = ref_info["object"]["sha"]
154+
155+
api(
156+
f"repos/{repo}/git/refs",
157+
method="POST",
158+
body={"ref": f"refs/heads/{branch}", "sha": head_oid},
159+
)
160+
expected_oid = head_oid
158161
159162
def b64(path: str) -> str:
160163
with open(path, "rb") as fp:

0 commit comments

Comments
 (0)