File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6565 pytest tests/ --doctest-modules --junitxml=junit/test-results.xml --cov=src/echr_extractor --cov-report=xml --cov-report=html
6666
6767 build :
68+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
6869 name : Build Python package
6970 runs-on : ubuntu-latest
7071 steps :
9091 path : dist/
9192
9293 pypi-publish :
93- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
94+ if : github.event_name == 'push' && startsWith( github.ref, 'refs/tags/')
9495 name : Publish to PyPI
9596 needs : build
9697 runs-on : ubuntu-latest
@@ -110,7 +111,7 @@ jobs:
110111 uses : pypa/gh-action-pypi-publish@release/v1
111112
112113 github-release :
113- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
114+ if : github.event_name == 'push' && startsWith( github.ref, 'refs/tags/')
114115 name : Sign the Python distribution with Sigstore and upload them to GitHub Releases
115116 needs :
116117 - pypi-publish
Original file line number Diff line number Diff line change @@ -146,6 +146,12 @@ write_to = "src/echr_extractor/_version.py" # Auto-generate version file
146146- Check that setuptools_scm is installed: ` pip install setuptools_scm `
147147- Verify pyproject.toml configuration is correct
148148
149+ ### "Local versions not allowed" error on PyPI?
150+ - ** Cause** : setuptools_scm was generating versions with local identifiers (e.g., ` 1.0.47+abc123 ` )
151+ - ** Solution** : The configuration now uses ` local_scheme = "no-local-version" ` to prevent this
152+ - ** Prevention** : Only build from clean, tagged commits (GitHub Actions now only runs on tags)
153+ - ** Manual fix** : Ensure working directory is clean before creating tags
154+
149155## 📚 Additional Resources
150156
151157- [ setuptools_scm Documentation] ( https://github.com/pypa/setuptools_scm )
Original file line number Diff line number Diff line change @@ -108,3 +108,7 @@ disallow_untyped_defs = true
108108
109109[tool .setuptools_scm ]
110110write_to = " src/echr_extractor/_version.py"
111+ # Ensure clean versions for PyPI releases
112+ local_scheme = " no-local-version"
113+ # Use distance-based versioning for development
114+ fallback_version = " 0.0.0"
Original file line number Diff line number Diff line change @@ -64,6 +64,16 @@ def check_working_directory_clean():
6464 print ("Error: Working directory is not clean. Please commit or stash changes." )
6565 print ("Uncommitted changes:" )
6666 print (result .stdout )
67+ print ("\n This is required to ensure clean version numbers for PyPI releases." )
68+ sys .exit (1 )
69+
70+ # Also check that we're on main branch
71+ result = run_command ("git branch --show-current" )
72+ current_branch = result .stdout .strip ()
73+ if current_branch != "main" :
74+ print (f"Error: You must be on the 'main' branch to create releases." )
75+ print (f"Current branch: { current_branch } " )
76+ print ("Please switch to main branch: git checkout main" )
6777 sys .exit (1 )
6878
6979
You can’t perform that action at this time.
0 commit comments