diff --git a/.github/scripts/release.py b/.github/scripts/release.py index fb1368e..efa35a2 100644 --- a/.github/scripts/release.py +++ b/.github/scripts/release.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 """Versioning, release and pull request automation for the GitHub Actions workflows. Subcommands: @@ -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() @@ -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: @@ -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." diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 98bd597..46866b8 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -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