Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions .github/scripts/release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Versioning, release and pull request automation for the GitHub Actions workflows.

Subcommands:
Expand Down Expand Up @@ -59,7 +58,9 @@


def run(*args: str, stdin: str | None = None) -> str:
result = subprocess.run(args, input=stdin, capture_output=True, text=True)
result = subprocess.run(
args, input=stdin, capture_output=True, text=True, check=False
)
if result.returncode != 0:
raise RuntimeError(f"{' '.join(args)} failed: {result.stderr.strip()}")
return result.stdout.strip()
Expand All @@ -82,8 +83,7 @@ def output(**values: str) -> None:
path = os.environ.get("GITHUB_OUTPUT")
if path:
with open(path, "a", encoding="utf-8") as fh:
for key, value in values.items():
fh.write(f"{key}={value}\n")
fh.writelines(f"{key}={value}\n" for key, value in values.items())


def summary(text: str) -> None:
Expand Down Expand Up @@ -154,11 +154,15 @@ def create_tag(tag: str, sha: str) -> None:
def cmd_tag() -> int:
sha = os.environ["GITHUB_SHA"]
existing = sort_versions(run("git", "tag", "--points-at", sha).split())
tags = version_tags()
if existing:
if existing[-1] != tags[-1]:
# Re-run of an older commit: no version output, so nothing redeploys it.
summary(f"{sha[:7]} is {existing[-1]}, older than {tags[-1]}; skipping.")
return 0
output(version=existing[-1])
summary(f"{sha[:7]} is already tagged {existing[-1]}.")
return 0
tags = version_tags()
if not tags:
summary(
"No version tag yet. Create the first release with the Release workflow."
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:

permissions:
actions: write
# Private repos need these to read the pull request's check results.
checks: read
statuses: read
contents: write
issues: write
pull-requests: write
Expand Down
Loading