-
Notifications
You must be signed in to change notification settings - Fork 20
Auto-bump version on staging and prod deploys #150
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
Open
aditeyabaral
wants to merge
9
commits into
pesu-dev:dev
Choose a base branch
from
aditeyabaral:feat/auto-version-bump
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c134a82
feat: auto-bump version on staging and prod deploys
aditeyabaral 16141d5
Merge branch 'dev' into feat/auto-version-bump
aditeyabaral a7e6fc1
fix: harden auto-version-bump deploy workflows
aditeyabaral 18e2d2a
fix: quote if condition in deploy-staging to escape YAML tag character
aditeyabaral 2de1205
fix: deploy before version bump, add regex guard to bump scripts
aditeyabaral 5fedb4d
fix: bump and push version before deploying to staging
aditeyabaral a7a5ae9
fix: extract shared bump_version script, exit 0 on stale SHA skip
aditeyabaral b5f7a25
fix: update uv.lock alongside pyproject.toml in version bump commits
aditeyabaral 696a839
fix: gate staging deploy on sync-minor-to-dev to ensure dev is up to …
aditeyabaral File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env python3 | ||
| """Bump the project version in pyproject.toml. Usage: bump_version.py [patch|minor].""" | ||
|
|
||
| import re | ||
| import sys | ||
|
|
||
| if len(sys.argv) != 2 or sys.argv[1] not in ("patch", "minor"): | ||
| raise SystemExit("Usage: bump_version.py [patch|minor]") | ||
|
|
||
| bump_type = sys.argv[1] | ||
|
|
||
| with open("pyproject.toml") as f: | ||
| content = f.read() | ||
|
|
||
| match = re.search(r'^version = "(\d+)\.(\d+)\.(\d+)"', content, re.MULTILINE) | ||
| if not match: | ||
| raise SystemExit('version = "x.y.z" not found in pyproject.toml') | ||
|
|
||
| major, minor, patch = int(match.group(1)), int(match.group(2)), int(match.group(3)) | ||
|
|
||
| if bump_type == "patch": | ||
| new_version = f"{major}.{minor}.{patch + 1}" | ||
| else: | ||
| new_version = f"{major}.{minor + 1}.0" | ||
|
|
||
| new_content = re.sub( | ||
| r'^version = "\d+\.\d+\.\d+"', | ||
| f'version = "{new_version}"', | ||
| content, | ||
| count=1, | ||
| flags=re.MULTILINE, | ||
| ) | ||
|
|
||
| with open("pyproject.toml", "w") as f: | ||
| f.write(new_content) | ||
|
aditeyabaral marked this conversation as resolved.
|
||
|
|
||
| print(f"Bumped: {major}.{minor}.{patch} -> {new_version}") | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.