|
7 | 7 | import json |
8 | 8 | import os |
9 | 9 | import pprint |
| 10 | +import shutil |
10 | 11 | import subprocess |
11 | 12 | import sys |
12 | 13 | from collections import OrderedDict |
@@ -200,13 +201,38 @@ def run_post_gen_hook(): |
200 | 201 | ) |
201 | 202 |
|
202 | 203 | if os.environ.get("SKIP_GIT_PUSH") != "true": |
203 | | - # TODO: Remove --force; just for testing |
| 204 | + cmd = ["git", "push", "--set-upstream", "origin", "main"] |
| 205 | + |
| 206 | + # We only force push if we were explicitly allowed to |
| 207 | + if os.environ.get("ALLOW_FORCE_PUSH") == "true": |
| 208 | + cmd.append("--force") |
| 209 | + |
204 | 210 | subprocess.run( |
205 | | - ["git", "push", "--set-upstream", "origin", "main", "--force"], |
| 211 | + cmd, |
206 | 212 | capture_output=True, |
207 | 213 | check=True, |
208 | 214 | ) |
209 | 215 |
|
| 216 | + if os.environ.get("ALLOW_FORCE_PUSH") == "true": |
| 217 | + # Attempt to cleanup the v0.1.0 tag and corresponding release |
| 218 | + release = "v0.1.0" |
| 219 | + |
| 220 | + subprocess.run( |
| 221 | + ["git", "push", "--delete", "origin", release], |
| 222 | + check=False, |
| 223 | + stdout=subprocess.DEVNULL, |
| 224 | + stderr=subprocess.DEVNULL, |
| 225 | + ) |
| 226 | + |
| 227 | + # If the user has the gh cli installed and setup, we cleanup the corresponding release as well |
| 228 | + if shutil.which("gh"): |
| 229 | + subprocess.run( |
| 230 | + ["gh", "release", "delete", release, "--yes"], |
| 231 | + check=False, |
| 232 | + stdout=subprocess.DEVNULL, |
| 233 | + stderr=subprocess.DEVNULL, |
| 234 | + ) |
| 235 | + |
210 | 236 | # Cut an initial release |
211 | 237 | subprocess.run( |
212 | 238 | ["task", "release"], |
|
0 commit comments