8686
8787 cd :
8888 needs : ci
89- if : github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master')
89+ # Note: github.event.pull_request.draft == false WON'T WORK in "if" statement,
90+ # because the triggered event is a push, not a pull_request.
91+ # This means each commit will trigger a release on TestPyPI.
92+ # Those releases will only succeed when each push has a new version number: a1, a2, a3, etc.
93+ if : |
94+ github.event_name == 'push' &&
95+ (
96+ startsWith(github.ref, 'refs/tags') ||
97+ startsWith(github.ref, 'refs/heads/release-')
98+ )
9099 runs-on : ubuntu-latest
91100 steps :
92101 - uses : actions/checkout@v4
@@ -98,14 +107,16 @@ jobs:
98107 run : |
99108 python -m pip install build --user
100109 python -m build --sdist --wheel --outdir dist/ .
101- - name : Publish to TestPyPI
110+ - name : |
111+ Publish to TestPyPI when pushing to release-* branch.
112+ You better test with a1, a2, b1, b2 releases first.
102113103- if : github.ref == 'refs/heads/master'
114+ if: startsWith( github.ref, 'refs/heads/release-')
104115 with:
105116 user: __token__
106117 password: ${{ secrets.TEST_PYPI_API_TOKEN }}
107118 repository_url: https://test.pypi.org/legacy/
108- - name : Publish to PyPI
119+ - name : Publish to PyPI when tagged
109120 if : startsWith(github.ref, 'refs/tags')
110121111122 with :
0 commit comments