|
35 | 35 |
|
36 | 36 | import argparse
|
37 | 37 | from pathlib import Path
|
| 38 | +from os import environ |
38 | 39 | import subprocess
|
39 | 40 | import re
|
40 | 41 |
|
@@ -132,19 +133,24 @@ def main():
|
132 | 133 | )
|
133 | 134 | print("Updated CHANGELOG.md")
|
134 | 135 |
|
| 136 | + if environ.get("CI", "false") == "true": |
| 137 | + # configure git credentials on CI runner |
| 138 | + # NOTE: this is design to fail locally with `KeyError` |
| 139 | + git_config = {"name": environ["GITHUB_ACTOR"]} |
| 140 | + git_config["email"] = ( |
| 141 | + f'{environ["GITHUB_ACTOR_ID"]}+{git_config["name"]}@users.noreply.github.com' |
| 142 | + ) |
| 143 | + for key, value in git_config.items(): |
| 144 | + subprocess.run( |
| 145 | + ["git", "config", "--global", f"user.{key}", value], check=True |
| 146 | + ) |
135 | 147 | subprocess.run(["git", "add", "--all"], check=True)
|
136 | 148 | tag = "v" + Updater.new_version
|
137 | 149 | subprocess.run(["git", "commit", "-m", f"Bump version to {tag}"], check=True)
|
138 |
| - try: |
139 |
| - subprocess.run(["git", "push"], check=True) |
140 |
| - except subprocess.CalledProcessError as exc: |
141 |
| - raise RuntimeError( |
142 |
| - """Failed to push commit for version bump. Please ensure that |
143 |
| -- You have the necessary permissions and are authenticated properly. |
144 |
| -- All other commits on the branch have ben pushed already.""" |
145 |
| - ) from exc |
146 |
| - title, notes = get_release_notes() |
| 150 | + subprocess.run(["git", "push"], check=True) |
147 | 151 | print("Pushed commit to 'Bump version to", tag, "'")
|
| 152 | + |
| 153 | + title, notes = get_release_notes() |
148 | 154 | gh_cmd = ["gh", "release", "create", tag, "--title", title, "--notes", notes]
|
149 | 155 | if Updater.component == "rc":
|
150 | 156 | gh_cmd.append("--prerelease")
|
|
0 commit comments