Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,33 @@ def cmd_tag() -> int:
if tags[-1] not in version_tags(merged_into=sha):
summary(f"{sha[:7]} is older than {tags[-1]}; not tagging it.")
return 0
head = default_branch_head()
if head and head != sha:
# A newer commit landed meanwhile; its run tags (and deploys) both.
summary(f"{sha[:7]} is no longer the head of main ({head[:7]}); skipping.")
return 0
new = bump(tags[-1], "patch")
create_tag(new, sha)
try:
create_tag(new, sha)
except RuntimeError as error:
# GITHUB_TOKEN may not create refs to commits whose workflow files differ
# from main's; the next run tags a newer commit.
print(f"::warning::Could not tag {sha[:7]} as {new}: {error}")
return 0
output(version=new)
summary(f"Tagged {sha[:7]} as {new}.")
return 0


def default_branch_head() -> str | None:
"""SHA at the tip of the remote default branch, None if unknown."""
try:
listing = run("git", "ls-remote", "origin", "HEAD").split()
except RuntimeError:
return None
return listing[0] if listing else None


# --- release notes ---------------------------------------------------------


Expand Down
Loading