-
Notifications
You must be signed in to change notification settings - Fork 0
Implement github action for calver version bumping #17
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
Merged
JaLuka98
merged 20 commits into
main
from
2025_05_20_hotfix_calver_conventions_bumpmyversion
May 21, 2025
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
078592b
fix calver convention with % signs to {}
JaLuka98 0544899
Undo overwriting (accidental) of pyprojct toml
JaLuka98 f2b7d5f
{} instead of % in bumpversion toml
JaLuka98 1654f76
Avoid hardcoding current version in bumpversion toml
JaLuka98 6d217e0
Fix bumpversion serialise month zero padding hopefully
JaLuka98 56964bd
Try with literal serialise
JaLuka98 b6c9755
Switching back to static version encoding in init since bump-my-versi…
JaLuka98 cc878b8
Update git workflow manual release calver to check actual date
JaLuka98 bdeedfa
Test if a local dry run of manual release is possible
JaLuka98 4a2f088
Trying with --new-version instead of set
JaLuka98 493c36d
Comment out git pushing for manual release to test
JaLuka98 f6ce812
Putting git stuff back for local change
JaLuka98 741ae90
Forbid no commit and no tag
JaLuka98 968bbe6
Set dry run dynamically, maybe this works
JaLuka98 5b00046
Adding basic dispatch test
JaLuka98 c5cac3e
Try with input dry run to stop overwriting
JaLuka98 18f52a1
Expose the dry run in the main step and then use it in the push chang…
JaLuka98 ca90c21
Remove the local dispatch test
JaLuka98 70ea77f
Update .bumpversion.toml
JaLuka98 adce714
Update .github/workflows/manual-release.yaml
JaLuka98 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,31 @@ | ||
| [tool.bumpversion] | ||
| current_version = "2025.04.0" | ||
| parse = "^(?P<year>\\d{4})\\.(?P<month>\\d{2})\\.(?P<patch>\\d+)$" | ||
| serialize = ["{year}.{month}.{patch}"] | ||
| parse = '^(?P<year>\d{4})\.(?P<month>\d{2})\.(?P<patch>\d+)$' | ||
| # ← use your part names here and pad month to two digits | ||
| serialize = ["{year}.{month:02d}.{patch}"] | ||
| tag = true | ||
| tag_name = "v{new_version}" | ||
| commit = true | ||
| message = "Release: {new_version}" | ||
|
|
||
| [tool.bumpversion.parts.year] | ||
| type = "calver" | ||
| calver_format = "%Y" | ||
| type = "calver" | ||
| # calver_format only affects how the part’s default or reset value is computed, | ||
| # you can leave this or remove if you don’t need it. | ||
|
|
||
| [tool.bumpversion.parts.month] | ||
| type = "calver" | ||
| calver_format = "%m" | ||
| type = "calver" | ||
| # likewise, calver_format here is optional once you’re formatting via Python sintax. | ||
|
|
||
| [tool.bumpversion.parts.patch] | ||
| type = "integer" | ||
| type = "integer" | ||
|
|
||
| [[tool.bumpversion.files]] | ||
| filename = "pyproject.toml" | ||
| search = 'version = "2025.04.0"' | ||
| search = 'version = "{current_version}"' | ||
| replace = 'version = "{new_version}"' | ||
|
|
||
| [[tool.bumpversion.files]] | ||
| filename = "src/cpax/__init__.py" | ||
| ignore_missing_version = true | ||
| filename = "src/cpax/__init__.py" | ||
| search = '__version__ = "{current_version}"' | ||
| replace = '__version__ = "{new_version}"' | ||
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 |
|---|---|---|
| @@ -1,24 +1,65 @@ | ||
| # .github/workflows/manual-release.yml | ||
| name: Manual CalVer Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: 'Dry-run only? (no commit, no push)' | ||
| type: boolean | ||
| default: true | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| tags: true | ||
JaLuka98 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: Set up Python | ||
| - name: Set up Python 3.11 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install bump-my-version | ||
| run: pip install bump-my-version | ||
|
|
||
| - name: Bump version | ||
| - name: Compute & (dry-)apply CalVer bump | ||
| env: | ||
| INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }} | ||
| run: | | ||
| bump-my-version bump patch | ||
| git push origin HEAD --follow-tags | ||
| set -e | ||
| # If `DRY_RUN` was passed via act CLI, keep it; else use the workflow‐dispatch input | ||
| DRY_RUN="${DRY_RUN:-$INPUT_DRY_RUN}" | ||
| echo "DRY_RUN is: '$DRY_RUN'" | ||
| # 1) Get latest tag or empty | ||
| LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | ||
| YEAR=$(date +%Y) # calendar year | ||
| MONTH=$(date +%m) # zero-padded month | ||
| PREFIX="v${YEAR}.${MONTH}" | ||
| if [[ "$LATEST" == $PREFIX.* ]]; then | ||
| SEQ=${LATEST##*.} | ||
| NEXT_SEQ=$((SEQ + 1)) | ||
| else | ||
| NEXT_SEQ=0 | ||
| fi | ||
| NEW_VERSION="${YEAR}.${MONTH}.${NEXT_SEQ}" | ||
| echo "Next version will be ${NEW_VERSION}" | ||
| # Build the bump command | ||
| CMD="bump-my-version bump --new-version ${NEW_VERSION}" | ||
| if [[ "$DRY_RUN" == 'true' ]]; then | ||
| CMD+=" --dry-run --verbose --no-commit --no-tag" | ||
| fi | ||
| echo "Running: $CMD" | ||
| # expose DRY_RUN to all later steps | ||
| echo "DRY_RUN=$DRY_RUN" >> $GITHUB_ENV | ||
| $CMD | ||
| - name: Push changes | ||
| if: env.DRY_RUN == 'false' | ||
| run: git push origin HEAD --follow-tags | ||
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 |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| # cpax/__init__.py | ||
|
|
||
| from importlib.metadata import version | ||
| __version__ = version("cpax") | ||
| __version__ = "2025.04.0" | ||
|
|
||
| # Import submodules but don’t expose specific functions | ||
| from . import ode |
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.