Skip to content

chore(release): update pypi packaging #35

chore(release): update pypi packaging

chore(release): update pypi packaging #35

---
name: Build and Optionally Publish to PyPi
on:
pull_request:
branches:
- main
push:
# Pattern matched against refs/tags
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build_src_for_pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Install dependencies
run: |
pip install build
- name: Build src dist
run: |
python -m build --sdist
env:
PIP_CONSTRAINT: requirements.txt
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: ./**/*.tar.gz
build_dist_for_pypi:
needs:
- build_src_for_pypi
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-13
- macos-latest
- ubuntu-24.04-arm
- ubuntu-latest
- windows-latest
steps:
- name: Download the sdist
uses: actions/download-artifact@v4
with:
name: cibw-sdist
- name: Get sdist filename
id: get-sdist
run: |
echo "sdist_filename=$(ls dist/)" >> "${GITHUB_OUTPUT}"
shell: bash
- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: dist/${{ steps.get-sdist.outputs.sdist_filename }}
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
publish_to_pypi:
if: github.ref_type == 'tag'
needs:
- build_dist_for_pypi
- build_src_for_pypi
permissions:
id-token: write # This is required for OIDC
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: cibw-*
- name: Publish package to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true