File tree Expand file tree Collapse file tree 4 files changed +41
-73
lines changed
Expand file tree Collapse file tree 4 files changed +41
-73
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,15 @@ jobs:
4545 VERSION=$(grep '__version__' src/codius/version.py | cut -d'"' -f2)
4646 echo "version=$VERSION" >> $GITHUB_OUTPUT
4747
48+ - name : Sync version to pyproject.toml
49+ run : |
50+ python scripts/sync_version.py
51+
4852 - name : Commit and push version bump
4953 run : |
5054 git config user.name "GitHub Actions"
5155 git config user.email "actions@github.com"
52- git add src/codius/version.py
56+ git add src/codius/version.py pyproject.toml
5357 git commit -m "chore(release): bump version to ${{ steps.bump.outputs.version }}"
5458 git push
5559
Original file line number Diff line number Diff line change @@ -125,6 +125,15 @@ test-install-version: ## Test installing package from TestPyPI with a specific P
125125 $$ VENV_DIR/bin/codius /tmp/test-codius --version || echo " ❌ Failed to run codius with Python $( PY) " ; \
126126 rm -rf $$ VENV_DIR /tmp/test-codius
127127
128+ .PHONY : bump-version
129+ bump-version : # # Bump version and update pyproject.toml
130+ python scripts/bump_version.py
131+ make sync-version
132+
133+ .PHONY : sync-version
134+ sync-version : # # Sync version.py to pyproject.toml
135+ python scripts/sync_version.py
136+
128137# ###############################################################################
129138# PRE-COMMIT HOOKS
130139# ###############################################################################
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+
3+ import re
4+ from pathlib import Path
5+
6+ VERSION_FILE = Path ("src/codius/version.py" )
7+ PYPROJECT_FILE = Path ("pyproject.toml" )
8+
9+
10+ def get_version ():
11+ content = VERSION_FILE .read_text ()
12+ match = re .search (r'__version__ = ["\']([^"\']+)["\']' , content )
13+ if not match :
14+ raise RuntimeError ("Version not found in version.py" )
15+ return match .group (1 )
16+
17+
18+ def update_pyproject (version : str ):
19+ content = PYPROJECT_FILE .read_text ()
20+ new_content = re .sub (r'version\s*=\s*"[^"]+"' , f'version = "{ version } "' , content )
21+ PYPROJECT_FILE .write_text (new_content )
22+ print (f"✅ Synced pyproject.toml version to { version } " )
23+
24+
25+ if __name__ == "__main__" :
26+ version = get_version ()
27+ update_pyproject (version )
You can’t perform that action at this time.
0 commit comments