Skip to content

Commit

Permalink
πŸ”§ chore(ci): restructure GitHub Actions workflow for PyPI publication
Browse files Browse the repository at this point in the history
- split single workflow into logical job stages
- add separate jobs for build, PyPI, TestPyPI, and post-release tasks
- improve clarity and modularity of release process
- align step names with descriptive emojis for better readability
  • Loading branch information
awwaawwa committed Jan 24, 2025
1 parent 80b623f commit cd9335c
Showing 1 changed file with 56 additions and 8 deletions.
64 changes: 56 additions & 8 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ permissions:
id-token: write

jobs:
release:
name: Release
build:
name: Build distribution πŸ“¦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -38,9 +38,11 @@ jobs:
with:
version-command: |
cat pyproject.toml | grep "version = " | head -n 1 | awk -F'"' '{print $2}'
- name: Install Dependencies
run: |
uv sync
- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
Expand All @@ -56,18 +58,62 @@ jobs:
name: python-package-distributions
path: dist/

- name: Publish to PyPI
if: steps.check-version.outputs.tag
publish-to-pypi:
name: Publish Python 🐍 distribution πŸ“¦ to PyPI
if: steps.check-version.outputs.tag
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/yadt

permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-to-testpypi:
name: Publish Python 🐍 distribution πŸ“¦ to TestPyPI
if: "! steps.check-version.outputs.tag"
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/yadt

permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
repository-url: https://pypi.org/legacy/
name: python-package-distributions
path: dist/

- name: Publish to TestPyPI
if: "! steps.check-version.outputs.tag"
- name: Publish distribution πŸ“¦ to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

post-release:
name: Post Release Tasks
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
Expand Down Expand Up @@ -99,5 +145,7 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
"${{ steps.check-version.outputs.tag }}" dist/**
"${{ steps.check-version.outputs.tag }}"
./dist/*.tar.gz.sig
./dist/*.whl.sig
--repo "$GITHUB_REPOSITORY"

0 comments on commit cd9335c

Please sign in to comment.