From 99532398e7402412255cba0e5902519fc8a2242e Mon Sep 17 00:00:00 2001 From: AleksaC Date: Sat, 4 Feb 2023 03:15:25 +0100 Subject: [PATCH] Move tagging to add-new-versions.py script --- .github/workflows/add-new-versions.yml | 2 +- add-new-versions.py | 19 ++++++++++++++----- tag.sh | 10 ---------- 3 files changed, 15 insertions(+), 16 deletions(-) delete mode 100755 tag.sh diff --git a/.github/workflows/add-new-versions.yml b/.github/workflows/add-new-versions.yml index 8e26f68..d712ea9 100644 --- a/.github/workflows/add-new-versions.yml +++ b/.github/workflows/add-new-versions.yml @@ -31,4 +31,4 @@ jobs: git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' - name: Add new versions - run: ./add-new-versions.py + run: ./add-new-versions.py --push diff --git a/add-new-versions.py b/add-new-versions.py index f3d636b..4108412 100755 --- a/add-new-versions.py +++ b/add-new-versions.py @@ -82,6 +82,10 @@ def get_text(url: str, headers: Optional[dict[str, str]] = None) -> str: return _get(url, headers).read().decode() +def git(*args: str) -> None: + subprocess.run(["git", *args], check=True) + + @lru_cache def get_gh_auth_headers(): gh_token = os.environ["GH_TOKEN"] @@ -192,13 +196,15 @@ def render_templates(templates: list[Template]) -> None: f.write(template.render(**vars)) -def push_tag(version: Version) -> None: - subprocess.run(["./tag.sh", f"v{version}"], check=True) +def tag_version(version: str) -> None: + git("add", "-u") + git("commit", "-m", f"Add version {version}") + git("tag", version) def main(argv=None): parser = argparse.ArgumentParser() - parser.add_argument("--render-only", default=False, action="store_true") + parser.add_argument("--push", default=False, action="store_true") args = parser.parse_args(argv) versions = get_missing_versions(REPO, MIRROR_REPO, Version.from_string(MIN_VERSION)) @@ -223,8 +229,11 @@ def main(argv=None): ] ) - if not args.render_only: - push_tag(version) + tag_version(f"v{version}") + + if args.push: + git("push") + git("push", "--tags") return 0 diff --git a/tag.sh b/tag.sh deleted file mode 100755 index c1a04cc..0000000 --- a/tag.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -git add -u -git commit -m "Add version $1" -git pull --ff-only -git tag $1 -git push -git push --tags