Skip to content

Commit

Permalink
Setup cibuildwheel
Browse files Browse the repository at this point in the history
  • Loading branch information
shenanigansd authored Sep 24, 2024
1 parent 4419bd0 commit 59b8fc0
Showing 1 changed file with 43 additions and 25 deletions.
68 changes: 43 additions & 25 deletions .github/workflows/python-publish.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,64 @@
name: Publish Python 🐍 distributions πŸ“¦ to PyPI

on:
pull_request:
release:
types: [published]

jobs:
build:
name: Build distribution πŸ“¦
runs-on: ubuntu-latest
permissions:
attestations: write
id-token: write
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Build wheels
uses: pypa/cibuildwheel@bd033a44476646b606efccdd5eed92d5ea1d77ad # v2.20.0

- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Build and inspect Python 🐍 package πŸ“¦
uses: hynek/build-and-inspect-python-package@73aea398b9c8de9ea9e4464c6b13cb8b1f3d6294 # v2.9.0
- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
attest-build-provenance-github: true
name: cibw-sdist
path: dist/*.tar.gz

publish-to-pypi:
name: Publish Python 🐍 distribution πŸ“¦ to PyPI
needs: build
if: ${{ github.event.action == 'published' }}
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/batgrl/${{ github.ref_name }}
permissions:
attestations: write
id-token: write

if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download dists
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: Packages
path: dist/

- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 # v1.10.1
with:
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@897895f1e160c830e369f9779632ebc134688e1b # v1.10.2
with:
attestations: true
verbose: true
print-hash: true

0 comments on commit 59b8fc0

Please sign in to comment.