Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pypi publish workflow #101

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 50 additions & 19 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,57 @@ jobs:
echo "Contents of wheelhouse:"
ls -l wheelhouse/

- name: Upload to PyPI
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
path: ./wheelhouse/*.whl
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
${{ matrix.buildplat[2] }} ${{ matrix.buildplat[3] }}
${{ matrix.buildplat[4] }}

publish-to-pypi:
name: Publish Python distribution to PyPI
# only publish to PyPI on tag pushes
if: startsWith(github.ref, 'refs/tags/')
needs:
- build_wheels
runs-on: ubuntu-latest
environment:
name: pypi-release
url: https://pypi.org/project/${{ env.PYPI_NAME }}
permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
if [ "$(ls -A wheelhouse)" ]; then
python -m pip install --upgrade twine
python -m twine upload --repository-url https://upload.pypi.org/legacy/ wheelhouse/*
else
echo "No wheel files to upload"
fi

- name: Upload to TestPyPI
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: |
if [ "$(ls -A wheelhouse)" ]; then
python -m pip install --upgrade twine
python -m twine upload --repository-url https://test.pypi.org/legacy/ wheelhouse/*
else
echo "No wheel files to upload"
fi
# - name: Upload to PyPI
# env:
# TWINE_USERNAME: "__token__"
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
# run: |
# if [ "$(ls -A wheelhouse)" ]; then
# python -m pip install --upgrade twine
# python -m twine upload --repository-url https://upload.pypi.org/legacy/ wheelhouse/*
# else
# echo "No wheel files to upload"
# fi

# - name: Upload to TestPyPI
# env:
# TWINE_USERNAME: "__token__"
# TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
# run: |
# if [ "$(ls -A wheelhouse)" ]; then
# python -m pip install --upgrade twine
# python -m twine upload --repository-url https://test.pypi.org/legacy/ wheelhouse/*
# else
# echo "No wheel files to upload"
# fi