Skip to content

Commit 523c89c

Browse files
committed
chore(ci): only publish to PyPI if a new release was created
1 parent 6bfd52a commit 523c89c

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

.github/workflows/release.yaml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Generate Next Release
22
# This workflow will generate changelog and release notes.
3-
# Source: https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/.github/workflows/release.yml
43

54
on:
65
workflow_dispatch:
@@ -9,10 +8,11 @@ env:
98
DIST_DIR: dist
109
jobs:
1110
release:
12-
name: Build and publish package
11+
name: Create next release
1312
runs-on: ubuntu-latest
14-
permissions:
15-
id-token: write
13+
14+
outputs:
15+
new_release_published: ${{ steps.release.outputs.new_release_published }}
1616

1717
steps:
1818
- name: Checkout
@@ -21,16 +21,8 @@ jobs:
2121
fetch-depth: 0
2222
ssh-key: ${{ secrets.DEPLOY_KEY }}
2323

24-
- name: Install Python
25-
uses: actions/setup-python@v5
26-
with:
27-
python-version-file: .python-version
28-
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade build
32-
3324
- name: Create GitHub release
25+
id: release
3426
uses: cycjimmy/semantic-release-action@v4
3527
with:
3628
semantic_version: 19.0.5
@@ -46,11 +38,36 @@ jobs:
4638
GIT_COMMITTER_EMAIL: bot@equinix.noreply.github.com
4739
RELEASE_REQUESTER: "@${{ github.event.sender.login }}"
4840

41+
publish:
42+
name: Publish artifacts
43+
runs-on: ubuntu-latest
44+
needs: release
45+
if: needs.release.outputs.new_release_published == 'true'
46+
47+
permissions:
48+
id-token: write
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
ssh-key: ${{ secrets.DEPLOY_KEY }}
56+
57+
- name: Install Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version-file: .python-version
61+
62+
- name: Install dependencies
63+
run: |
64+
python -m pip install --upgrade build
65+
4966
- name: Build package
5067
run: |
5168
python -m build --sdist --wheel --outdir ${{ env.DIST_DIR }} .
5269
53-
- name: Publish package
70+
- name: Publish to PyPI
5471
uses: pypa/gh-action-pypi-publish@release/v1
5572
with:
5673
packages-dir: ${{ env.DIST_DIR }}

0 commit comments

Comments
 (0)