Skip to content

Commit 1c5616f

Browse files
authored
Merge pull request #9 from monkeyman192/pipeline_fix
Fix for pipelines to get version correctly
2 parents e5ea94a + 78daa99 commit 1c5616f

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

.github/workflows/pipeline.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,56 +42,68 @@ 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: Assign whether to release to output
61+
id: whether_to_release
62+
run: echo "should_release=${{ env.PUBLISHING }}" >> "$GITHUB_OUTPUT"
4563
release:
4664
name: Release NMSpy wheels and source build to PyPI
4765
# Only run this job if the commit was tagged.
48-
if: startsWith(github.ref, 'refs/tags')
66+
if: ${{ startsWith(github.ref, 'refs/tags') && needs.release_check.outputs.should_release == 'true' }}
4967
needs:
5068
- build_test
69+
- release_check
5170
runs-on: ubuntu-latest
5271
environment:
5372
name: pypi
5473
url: https://pypi.org/p/NMSpy
5574
permissions:
5675
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
5776
steps:
58-
- name: Check whether to release
59-
uses: MathieuMoalic/action-python-package-new-version@v1.0.5
6077
- name: Download files for release
61-
if: env.PUBLISHING == 'true'
6278
uses: actions/download-artifact@v4
6379
with:
6480
name: python-package-distributions
6581
path: dist/
6682
- name: Publish package distributions to PyPI
67-
if: env.PUBLISHING == 'true'
6883
uses: pypa/gh-action-pypi-publish@release/v1
6984
with:
7085
attestations: true
7186

7287
test-release:
7388
name: Release NMSpy wheels and source build to test-PyPI
7489
# Only run this job if we merge into master. Addition check is added later.
75-
if: github.ref == 'refs/heads/master'
90+
if: ${{ github.ref == 'refs/heads/master' && needs.release_check.outputs.should_release == 'true' }}
7691
needs:
7792
- build_test
93+
- release_check
7894
runs-on: ubuntu-latest
7995
environment:
8096
name: testpypi
8197
url: https://test.pypi.org/p/NMSpy
8298
permissions:
8399
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
84100
steps:
85-
- name: Check whether to release
86-
uses: MathieuMoalic/action-python-package-new-version@v1.0.5
87101
- name: Download files for release
88-
if: env.PUBLISHING == 'true'
89102
uses: actions/download-artifact@v4
90103
with:
91104
name: python-package-distributions
92105
path: dist/
93106
- name: Publish package distributions to PyPI
94-
if: env.PUBLISHING == 'true'
95107
uses: pypa/gh-action-pypi-publish@release/v1
96108
with:
97109
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)