@@ -3,6 +3,8 @@ name: Publish to PyPI
33on :
44 release :
55 types : [published]
6+ push :
7+ branches : [develop]
68
79jobs :
810 deploy :
1315
1416 steps :
1517 - uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0 # Full history for proper versioning
1620
1721 - name : Set up Python
1822 uses : actions/setup-python@v4
@@ -22,12 +26,30 @@ jobs:
2226 - name : Install dependencies
2327 run : |
2428 python -m pip install --upgrade pip
25- pip install build twine
29+ pip install build twine setuptools-scm
30+
31+ - name : Determine target repository
32+ id : target
33+ run : |
34+ if [[ "${{ github.event_name }}" == "release" ]]; then
35+ echo "repository=pypi" >> $GITHUB_OUTPUT
36+ echo "repository_url=" >> $GITHUB_OUTPUT
37+ echo "Publishing release to PyPI"
38+ else
39+ echo "repository=testpypi" >> $GITHUB_OUTPUT
40+ echo "repository_url=https://test.pypi.org/legacy/" >> $GITHUB_OUTPUT
41+ echo "Publishing develop to TestPyPI"
42+ fi
2643
2744 - name : Build package
2845 run : python -m build
2946
30- - name : Publish to PyPI
47+ - name : Publish to PyPI (Release)
48+ if : github.event_name == 'release'
3149 uses : pypa/gh-action-pypi-publish@release/v1
32- # No need for user/password with trusted publishing
33- # The action will use OIDC tokens automatically
50+
51+ - name : Publish to TestPyPI (Develop)
52+ if : github.event_name == 'push' && github.ref == 'refs/heads/develop'
53+ uses : pypa/gh-action-pypi-publish@release/v1
54+ with :
55+ repository-url : https://test.pypi.org/legacy/
0 commit comments