Run release workflow only on publish #116
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: | |
release: | |
types: | |
- published | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
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 | |
with: | |
python-version: '3.10' | |
- name: Build source distribution | |
run: | | |
pip install build | |
python -m build --sdist | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./dist/*.tar.gz | |
check: | |
name: All wheels built successfully | |
runs-on: ubuntu-latest | |
if: always() | |
needs: | |
- build-wheels | |
steps: | |
- uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} | |
publish: | |
name: Publish package | |
runs-on: ubuntu-latest | |
needs: | |
- build-wheels | |
- build-sdist | |
permissions: | |
id-token: write | |
if: github.event_name == 'release' | |
steps: | |
- id: download-artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: dist | |
- name: Upload binaries to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/* | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |