Create workflows for uploading package to PyPI index #93
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
# don't rebuild when only modifying other workflows | |
paths: | |
- '!.github/workflows/**' | |
- '.github/workflows/build.yml' | |
jobs: | |
build-wheels: | |
name: Build wheels for ${{ matrix.pyver }} on ${{ matrix.platform.os }} ${{ matrix.platform.arch }} | |
runs-on: ${{ matrix.platform.os }} | |
strategy: | |
matrix: | |
pyver: [cp39, cp310, cp311, cp312] | |
platform: | |
- arch: x86_64 | |
os: ubuntu-20.04 | |
- arch: arm64 | |
os: macos-11 | |
- arch: x86_64 | |
os: macos-11 | |
- arch: x86 | |
os: windows-2019 | |
- arch: AMD64 | |
os: windows-2019 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '6.0.x' | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.16.2 | |
env: | |
CIBW_BUILD: ${{ matrix.pyver }}-* | |
CIBW_ARCHS: ${{ matrix.platform.arch }} | |
with: | |
package-dir: . | |
output-dir: dist | |
config-file: pyproject.toml | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./dist/*.whl | |
build-sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/setup-python@v4 | |
- run: | | |
python -m pip install --upgrade pip | |
pip install build | |
python -m build --sdist | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./dist/*.tar.gz | |
check: | |
name: All wheels built successfully | |
if: always() | |
needs: | |
- build-wheels | |
runs-on: ubuntu-latest | |
steps: | |
- uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} | |
publish: | |
name: Publish package distributions to PyPI | |
runs-on: ubuntu-latest | |
needs: [build-wheels, build-sdist] | |
permissions: | |
id-token: write | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- name: Download artifact | |
id: download-artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |