Skip to content

Add environment specification for PyPI publish step #7

Add environment specification for PyPI publish step

Add environment specification for PyPI publish step #7

Workflow file for this run

name: Build
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
permissions:
contents: write
jobs:
version:
name: Compute build version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
tag: ${{ steps.meta.outputs.tag }}
steps:
- name: Generate hash version
id: meta
run: |
SHORT_SHA="${GITHUB_SHA::7}"
VERSION="${SHORT_SHA}"
TAG="v${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
build-wheels:
name: Build wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: version
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*"
CIBW_SKIP: "*-musllinux_*"
- name: Store built wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [version, build-wheels]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: release-assets
merge-multiple: true
- name: Publish release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.version.outputs.tag }}
name: ${{ needs.version.outputs.tag }}
prerelease: false
generate_release_notes: true
files: release-assets/*.whl