File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Sync Version & Publish
1+ name : Publish
22
33on :
4- # push:
5- # tags:
6- # - "v*.*.*"
7- workflow_dispatch :
8- inputs :
9- version :
10- description : " Version to release (e.g. 0.6.0)"
11- required : true
4+ push :
5+ tags :
6+ - " v*.*.*"
127
138jobs :
149 release :
2318 uses : actions/setup-python@v5
2419 with :
2520 python-version : " 3.11"
26-
27- # Build and publish to PyPI/TestPyPI (same as before)
21+
22+ - name : Update version from tag
23+ run : |
24+ TAG_NAME=${GITHUB_REF#refs/tags/}
25+ python scripts/set_version.py $TAG_NAME
26+ git config user.name "github-actions"
27+ git config user.email "actions@github.com"
28+ git commit -am "chore: set version from $TAG_NAME" || echo "No changes to commit"
29+ git push origin HEAD:${GITHUB_REF_NAME}
30+
31+ - name : Verify new version
32+ run : grep __version__ pytest_htmlx/__init__.py
33+
2834 - name : Install build tools
2935 run : |
3036 python -m pip install --upgrade pip
Original file line number Diff line number Diff line change 1+ import re
2+ import sys
3+ from pathlib import Path
4+
5+ root_dir = Path (__file__ ).parent .parent
6+ if len (sys .argv ) != 2 :
7+ print ("Usage: python scripts/set_version.py vX.Y.Z" )
8+ sys .exit (1 )
9+
10+ tag = sys .argv [1 ] # e.g. v0.5.0
11+ if not tag .startswith ("v" ):
12+ raise RuntimeError ("Tag must start with 'v', e.g. v1.2.3" )
13+
14+ new_version = tag .lstrip ("v" )
15+
16+ version_file = root_dir / "pytest_htmlx" / "__init__.py"
17+ text = version_file .read_text ()
18+
19+ new_text = re .sub (r'__version__ = ".+"' , f'__version__ = "{ new_version } "' , text )
20+ version_file .write_text (new_text )
21+
22+ print (f"Updated version to { new_version } " )
You can’t perform that action at this time.
0 commit comments