1414 build_test :
1515 name : Build artefacts
1616 runs-on : Windows-latest
17+ outputs :
18+ should_release : ${{ steps.whether_to_release.outputs.should_release}}
1719 strategy :
1820 fail-fast : false
1921 matrix :
3234 uv sync --frozen --all-groups --all-extras
3335 - name : Build Python ${{ matrix.py_ver.version}} wheel
3436 run : uv build
37+ - name : Check whether to release
38+ uses : MathieuMoalic/action-python-package-new-version@v1.0.5
39+ - name : Assign whether to release to output
40+ id : whether_to_release
41+ run : echo "should_release=${env.PUBLISHING}" >> "$GITHUB_OUTPUT"
3542 - name : Lint and format code
3643 run : |
3744 uv run ruff check ./nmspy
4552 release :
4653 name : Release NMSpy wheels and source build to PyPI
4754 # Only run this job if the commit was tagged.
48- if : startsWith(github.ref, 'refs/tags')
55+ if : ${{ startsWith(github.ref, 'refs/tags') && needs.build_test.outputs.should_release == 'true' }}
4956 needs :
5057 - build_test
5158 runs-on : ubuntu-latest
@@ -55,24 +62,20 @@ jobs:
5562 permissions :
5663 id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
5764 steps :
58- - name : Check whether to release
59- uses : MathieuMoalic/action-python-package-new-version@v1.0.5
6065 - name : Download files for release
61- if : env.PUBLISHING == 'true'
6266 uses : actions/download-artifact@v4
6367 with :
6468 name : python-package-distributions
6569 path : dist/
6670 - name : Publish package distributions to PyPI
67- if : env.PUBLISHING == 'true'
6871 uses : pypa/gh-action-pypi-publish@release/v1
6972 with :
7073 attestations : true
7174
7275 test-release :
7376 name : Release NMSpy wheels and source build to test-PyPI
7477 # Only run this job if we merge into master. Addition check is added later.
75- if : github.ref == 'refs/heads/master'
78+ if : ${{ github.ref == 'refs/heads/master' && needs.build_test.outputs.should_release == 'true' }}
7679 needs :
7780 - build_test
7881 runs-on : ubuntu-latest
@@ -82,16 +85,12 @@ jobs:
8285 permissions :
8386 id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
8487 steps :
85- - name : Check whether to release
86- uses : MathieuMoalic/action-python-package-new-version@v1.0.5
8788 - name : Download files for release
88- if : env.PUBLISHING == 'true'
8989 uses : actions/download-artifact@v4
9090 with :
9191 name : python-package-distributions
9292 path : dist/
9393 - name : Publish package distributions to PyPI
94- if : env.PUBLISHING == 'true'
9594 uses : pypa/gh-action-pypi-publish@release/v1
9695 with :
9796 repository-url : https://test.pypi.org/legacy/
0 commit comments