@@ -42,56 +42,66 @@ jobs:
4242 with :
4343 name : python-package-distributions
4444 path : dist/
45+ release_check :
46+ name : Check whether to do a release
47+ needs :
48+ - build_test
49+ runs-on : ubuntu-latest
50+ outputs :
51+ should_release : ${{ steps.whether_to_release.outputs.should_release}}
52+ steps :
53+ - uses : actions/checkout@v4
54+ with :
55+ fetch-depth : 0
56+ - name : Check whether to release
57+ uses : MathieuMoalic/action-python-package-new-version@v1.0.5
58+ - name : Assign whether to release to output
59+ id : whether_to_release
60+ run : echo "should_release=${env.PUBLISHING}" >> "$GITHUB_OUTPUT"
4561 release :
4662 name : Release NMSpy wheels and source build to PyPI
4763 # Only run this job if the commit was tagged.
48- if : startsWith(github.ref, 'refs/tags')
64+ if : ${{ startsWith(github.ref, 'refs/tags') && needs.release_check.outputs.should_release == 'true' }}
4965 needs :
5066 - build_test
67+ - release_check
5168 runs-on : ubuntu-latest
5269 environment :
5370 name : pypi
5471 url : https://pypi.org/p/NMSpy
5572 permissions :
5673 id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
5774 steps :
58- - name : Check whether to release
59- uses : MathieuMoalic/action-python-package-new-version@v1.0.5
6075 - name : Download files for release
61- if : env.PUBLISHING == 'true'
6276 uses : actions/download-artifact@v4
6377 with :
6478 name : python-package-distributions
6579 path : dist/
6680 - name : Publish package distributions to PyPI
67- if : env.PUBLISHING == 'true'
6881 uses : pypa/gh-action-pypi-publish@release/v1
6982 with :
7083 attestations : true
7184
7285 test-release :
7386 name : Release NMSpy wheels and source build to test-PyPI
7487 # Only run this job if we merge into master. Addition check is added later.
75- if : github.ref == 'refs/heads/master'
88+ if : ${{ github.ref == 'refs/heads/master' && needs.release_check.outputs.should_release == 'true' }}
7689 needs :
7790 - build_test
91+ - release_check
7892 runs-on : ubuntu-latest
7993 environment :
8094 name : testpypi
8195 url : https://test.pypi.org/p/NMSpy
8296 permissions :
8397 id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
8498 steps :
85- - name : Check whether to release
86- uses : MathieuMoalic/action-python-package-new-version@v1.0.5
8799 - name : Download files for release
88- if : env.PUBLISHING == 'true'
89100 uses : actions/download-artifact@v4
90101 with :
91102 name : python-package-distributions
92103 path : dist/
93104 - name : Publish package distributions to PyPI
94- if : env.PUBLISHING == 'true'
95105 uses : pypa/gh-action-pypi-publish@release/v1
96106 with :
97107 repository-url : https://test.pypi.org/legacy/
0 commit comments