Skip to content

Commit

Permalink
chore(ci): only publish to PyPI if a new release was created
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Dec 17, 2024
1 parent 6bfd52a commit 523c89c
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Generate Next Release
# This workflow will generate changelog and release notes.
# Source: https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/.github/workflows/release.yml

on:
workflow_dispatch:
Expand All @@ -9,10 +8,11 @@ env:
DIST_DIR: dist
jobs:
release:
name: Build and publish package
name: Create next release
runs-on: ubuntu-latest
permissions:
id-token: write

outputs:
new_release_published: ${{ steps.release.outputs.new_release_published }}

steps:
- name: Checkout
Expand All @@ -21,16 +21,8 @@ jobs:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version

- name: Install dependencies
run: |
python -m pip install --upgrade build
- name: Create GitHub release
id: release
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 19.0.5
Expand All @@ -46,11 +38,36 @@ jobs:
GIT_COMMITTER_EMAIL: [email protected]
RELEASE_REQUESTER: "@${{ github.event.sender.login }}"

publish:
name: Publish artifacts
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.new_release_published == 'true'

permissions:
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version

- name: Install dependencies
run: |
python -m pip install --upgrade build
- name: Build package
run: |
python -m build --sdist --wheel --outdir ${{ env.DIST_DIR }} .
- name: Publish package
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ env.DIST_DIR }}

0 comments on commit 523c89c

Please sign in to comment.