upload to PyPI on create a release (#639)

This commit is contained in:
Inada Naoki 2025-06-02 14:46:53 +09:00 committed by GitHub
parent cdc7644503
commit fe9e620a60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,10 @@
name: Build Wheels name: Build sdist and Wheels
on: on:
push: push:
branches: [main] branches: [main]
create: release:
types:
- published
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@ -34,7 +36,7 @@ jobs:
CIBW_SKIP: "pp* cp38-macosx_*" CIBW_SKIP: "pp* cp38-macosx_*"
- name: Build sdist - name: Build sdist
if: runner.os == 'Linux' if: runner.os == 'Linux' && runner.arch == 'X64'
run: | run: |
pip install build pip install build
python -m build -s -o wheelhouse python -m build -s -o wheelhouse
@ -44,3 +46,43 @@ jobs:
with: with:
name: wheels-${{ matrix.os }} name: wheels-${{ matrix.os }}
path: wheelhouse path: wheelhouse
# combine all wheels into one artifact
combine_wheels:
needs: [build_wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: wheels-*
path: dist
merge-multiple: true
- name: Upload Wheels to artifact
uses: actions/upload-artifact@v4
with:
name: wheels-all
path: dist
# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
upload_pypi:
needs: [build_wheels]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: wheels-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
#with:
# To test: repository-url: https://test.pypi.org/legacy/