Skip to content

Commit

Permalink
Move tagging to add-new-versions.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksaC committed Feb 4, 2023
1 parent 1b566a0 commit 9953239
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/add-new-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 14 additions & 5 deletions add-new-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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))
Expand All @@ -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

Expand Down
10 changes: 0 additions & 10 deletions tag.sh

This file was deleted.

0 comments on commit 9953239

Please sign in to comment.