Skip to content

Publish to PyPI

Publish to PyPI #35

Workflow file for this run

name: Publish to PyPI
on:
workflow_run:
workflows: ["build-wheels"]
types:
- completed
branches: [main]
jobs:
publish-to-pypi:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyember
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: dist
merge-multiple: true
- name: Organize wheels
run: |
# Show initial structure
echo "Initial directory structure:"
find dist -type f
# Move all wheels to dist directory
find dist -type f -name "*.whl" -exec mv {} dist/ \;
# Clean up empty directories
find dist -type d -empty -delete
# Show final structure
echo "Final directory structure:"
find dist -type f
- name: Publish to PyPI
uses: pypa/[email protected]
with:
verbose: true
packages-dir: dist/
print-hash: true
create-github-release:
needs: publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: dist
merge-multiple: true
- name: Get version
id: get_version
run: |
# Get version from setup.py or pyproject.toml
VERSION=$(python setup.py --version 2>/dev/null || python -c "from setuptools_scm import get_version; print(get_version())")
echo "version=v${VERSION}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.get_version.outputs.version }}
tag_name: ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
files: dist/*.whl
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}