Skip to content

Commit 6c78f2d

Browse files
committed
Fix for pipelines to get version correctly
1 parent e5ea94a commit 6c78f2d

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

.github/workflows/pipeline.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,56 +42,70 @@ 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+
permissions:
53+
id-token: write # IMPORTANT: this permission is required to write to github envs
54+
steps:
55+
- uses: actions/checkout@v4
56+
with:
57+
fetch-depth: 0
58+
- name: Check whether to release
59+
uses: MathieuMoalic/action-python-package-new-version@v1.0.5
60+
- name: test
61+
run: echo "what is it? ${{ env.PUBLISHING }}"
62+
- name: Assign whether to release to output
63+
id: whether_to_release
64+
run: echo "should_release=${{ env.PUBLISHING }}" >> "$GITHUB_OUTPUT"
4565
release:
4666
name: Release NMSpy wheels and source build to PyPI
4767
# Only run this job if the commit was tagged.
48-
if: startsWith(github.ref, 'refs/tags')
68+
if: ${{ startsWith(github.ref, 'refs/tags') && needs.release_check.outputs.should_release == 'true' }}
4969
needs:
5070
- build_test
71+
- release_check
5172
runs-on: ubuntu-latest
5273
environment:
5374
name: pypi
5475
url: https://pypi.org/p/NMSpy
5576
permissions:
5677
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
5778
steps:
58-
- name: Check whether to release
59-
uses: MathieuMoalic/action-python-package-new-version@v1.0.5
6079
- name: Download files for release
61-
if: env.PUBLISHING == 'true'
6280
uses: actions/download-artifact@v4
6381
with:
6482
name: python-package-distributions
6583
path: dist/
6684
- name: Publish package distributions to PyPI
67-
if: env.PUBLISHING == 'true'
6885
uses: pypa/gh-action-pypi-publish@release/v1
6986
with:
7087
attestations: true
7188

7289
test-release:
7390
name: Release NMSpy wheels and source build to test-PyPI
7491
# Only run this job if we merge into master. Addition check is added later.
75-
if: github.ref == 'refs/heads/master'
92+
if: ${{ github.ref == 'refs/heads/master' && needs.release_check.outputs.should_release == 'true' }}
7693
needs:
7794
- build_test
95+
- release_check
7896
runs-on: ubuntu-latest
7997
environment:
8098
name: testpypi
8199
url: https://test.pypi.org/p/NMSpy
82100
permissions:
83101
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
84102
steps:
85-
- name: Check whether to release
86-
uses: MathieuMoalic/action-python-package-new-version@v1.0.5
87103
- name: Download files for release
88-
if: env.PUBLISHING == 'true'
89104
uses: actions/download-artifact@v4
90105
with:
91106
name: python-package-distributions
92107
path: dist/
93108
- name: Publish package distributions to PyPI
94-
if: env.PUBLISHING == 'true'
95109
uses: pypa/gh-action-pypi-publish@release/v1
96110
with:
97111
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)