feat: Enable automated PyPI publishing on release (#46)

- Added publish-pypi job to release workflow
- Builds, verifies, and uploads package to PyPI after GitHub release
- Uses PYPI_API_TOKEN secret for authentication
- Added id-token permission for trusted publishing support
- Package verification with twine check before upload
This commit is contained in:
Jatin K Malik
2025-12-29 21:56:18 -08:00
committed by GitHub
parent 98e9c10c75
commit 2dcf0ef17c
+39 -16
View File
@@ -8,6 +8,7 @@ on:
permissions:
contents: write
packages: write
id-token: write # Required for PyPI trusted publishing
env:
PYTHON_VERSION: '3.10'
@@ -91,19 +92,41 @@ jobs:
---
See [CHANGELOG](https://github.com/jatinkrmalik/vocalinux/releases) for detailed changes.
# Optional: publish to PyPI when ready
# publish-pypi:
# name: Publish to PyPI
# needs: build-and-release
# runs-on: ubuntu-latest
# if: ${{ !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') }}
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-python@v5
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# - run: pip install build twine
# - run: python -m build
# - uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
publish-pypi:
name: Publish to PyPI
needs: build-and-release
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/vocalinux/
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
echo "Built packages:"
ls -la dist/
- name: Verify package
run: |
twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/* --skip-existing