Skip to content

Commit 8bb17f4

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

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

.github/workflows/release.yaml

Lines changed: 27 additions & 12 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,28 +8,23 @@ 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
1413
permissions:
1514
id-token: write
1615

16+
outputs:
17+
new_release_published: ${{ steps.release.outputs.new_release_published }}
18+
1719
steps:
1820
- name: Checkout
1921
uses: actions/checkout@v4
2022
with:
2123
fetch-depth: 0
2224
ssh-key: ${{ secrets.DEPLOY_KEY }}
2325

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-
3326
- name: Create GitHub release
27+
id: release
3428
uses: cycjimmy/semantic-release-action@v4
3529
with:
3630
semantic_version: 19.0.5
@@ -46,11 +40,32 @@ jobs:
4640
GIT_COMMITTER_EMAIL: bot@equinix.noreply.github.com
4741
RELEASE_REQUESTER: "@${{ github.event.sender.login }}"
4842

43+
publish:
44+
name: Publish artifacts
45+
runs-on: ubuntu-latest
46+
needs: release
47+
if: needs.release.outputs.new_release_published == 'true'
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 0
53+
ssh-key: ${{ secrets.DEPLOY_KEY }}
54+
55+
- name: Install Python
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version-file: .python-version
59+
60+
- name: Install dependencies
61+
run: |
62+
python -m pip install --upgrade build
63+
4964
- name: Build package
5065
run: |
5166
python -m build --sdist --wheel --outdir ${{ env.DIST_DIR }} .
5267
53-
- name: Publish package
68+
- name: Publish to PyPI
5469
uses: pypa/gh-action-pypi-publish@release/v1
5570
with:
5671
packages-dir: ${{ env.DIST_DIR }}

0 commit comments

Comments
 (0)