-
-
Notifications
You must be signed in to change notification settings - Fork 0
🔖 Promote 1.1.21: test → prod #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
91e11ac
fae2cfd
177206d
e671779
3c09a3c
db1fa0a
4d50bee
25b4aa3
a6a31f8
d47c155
ed57c00
29d00b1
aa4e883
94e1efa
fe27bf4
8a29ff7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| [bumpversion] | ||
| current_version = 1.1.19 | ||
| current_version = 1.1.21 | ||
| commit = True | ||
| tag = False | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,26 +233,32 @@ def amend_commit(new_commit_msg: str) -> None: | |
| """ | ||
| Amends the current commit with the new commit message. | ||
|
|
||
| Pre-commit hooks (e.g. generate-changelog, prettier) may modify tracked files such | ||
| as CHANGELOG.md while the amend runs, which aborts the amend. We re-stage those | ||
| tracked changes with ``git add -u`` and retry so they are folded into the bump | ||
| commit. ``--no-verify``/``--force`` are never used (global rule): the hooks are | ||
| idempotent, so the retry converges once their changes are staged. | ||
|
|
||
| Args: | ||
| new_commit_msg (str): The new commit message. | ||
|
|
||
| Raises: | ||
| subprocess.CalledProcessError: If git amend fails. | ||
| """ | ||
| try: | ||
| # Amend the commit with the new commit message | ||
| subprocess.run( | ||
| ["git", "commit", "--amend", "-m", new_commit_msg], | ||
| check=True, | ||
| encoding="utf-8", | ||
| ) | ||
| logger.info("Successfully amended the commit with the new version bump.") | ||
| logger.info( | ||
| "Please perform a push using 'git push' to update the remote repository. Avoid using --force" | ||
| amend_cmd = ["git", "commit", "--amend", "-m", new_commit_msg] | ||
| max_attempts = 3 | ||
| for attempt in range(1, max_attempts + 1): | ||
| result = subprocess.run(amend_cmd, encoding="utf-8") | ||
| if result.returncode == 0: | ||
| logger.info("Successfully amended the commit with the new version bump.") | ||
| logger.info( | ||
| "Please perform a push using 'git push' to update the remote repository. Avoid using --force" | ||
| ) | ||
| return | ||
| logger.warning( | ||
| f"Amend attempt {attempt} aborted by pre-commit hooks modifying files; " | ||
| "re-staging tracked changes and retrying." | ||
| ) | ||
| except subprocess.CalledProcessError as e: | ||
| logger.error(f"Failed to amend the commit: {e}") | ||
| sys.exit(1) | ||
| subprocess.run(["git", "add", "-u"], check=True, encoding="utf-8") | ||
|
Comment on lines
+255
to
+259
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If the first amend fails because a hook rewrites Useful? React with 👍 / 👎. |
||
| logger.error(f"Failed to amend the commit after {max_attempts} attempts.") | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| def main() -> None: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,8 @@ | |
| import warnings | ||
| import smtplib | ||
| from email.mime.text import MIMEText | ||
| import json # Added import for JSON handling | ||
| import json | ||
| import re | ||
|
|
||
| from cryptography.hazmat.backends import default_backend | ||
| from cryptography.hazmat.primitives.asymmetric import rsa, padding | ||
|
|
@@ -536,6 +537,19 @@ def get_status(self) -> None: | |
| print("Failed to retrieve status. Check logs for more details.") | ||
|
|
||
|
|
||
| def _resolve_key_pair_name(cert_location: str) -> str: | ||
| """Returns the active key pair name whose year range contains the current year.""" | ||
| current_year = datetime.now().year | ||
| if os.path.isdir(cert_location): | ||
| for fname in os.listdir(cert_location): | ||
| match = re.match(r"^Crypto-Key-Pair-(\d{4})-(\d{4})\.kp$", fname) | ||
|
Comment on lines
+543
to
+545
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Existing installations created by the previous default use Useful? React with 👍 / 👎. |
||
| if match: | ||
| start, end = int(match.group(1)), int(match.group(2)) | ||
| if start <= current_year <= end: | ||
| return fname[:-3] | ||
| return f"Crypto-Key-Pair-{current_year}-{current_year + int(CERT_EXPIRATION_YEARS)}" | ||
|
|
||
|
|
||
| def parse_arguments() -> argparse.Namespace: | ||
| """ | ||
| Parses command-line arguments. | ||
|
|
@@ -561,7 +575,7 @@ def parse_arguments() -> argparse.Namespace: | |
| ) | ||
| parser.add_argument( | ||
| "--key-pair-name", | ||
| default=f"Crypto-Key-Pair-{datetime.now().year}", | ||
| default=_resolve_key_pair_name(os.path.join(os.getcwd(), "certs")), | ||
| help="Name of the key pair. Defaults to 'Crypto-Key-Pair-<YEAR>'.", | ||
|
Comment on lines
577
to
579
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When callers pass Useful? React with 👍 / 👎. |
||
| ) | ||
| parser.add_argument( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ python-dotenv>=0.19.0 | |
| wheel>=0.36.2 | ||
| pytest>=7.0.0 | ||
| pytest-cov>=4.0.0 | ||
| pytest-mock>=3.11.0 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
|| echoconverts every failed tag push—including authentication, permission, network, and remote-hook failures—into a successful workflow step, after which the workflow still creates the promotion PR. Checkedgit push -h, whose documented invocation isgit push [<options>] [<repository> [<refspec>...]]; nothing here restricts the fallback to an already-existing ref. Detect that specific condition explicitly and let all other failures stop the workflow.Useful? React with 👍 / 👎.