6.0.0 #45
Workflow file for this run
This file contains hidden or 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: Publish release to PyPi | |
| on: | |
| release: | |
| types: [published] | |
| env: | |
| PYTHON_VERSION: "3.12" | |
| jobs: | |
| validate: | |
| name: Validate release tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.vars.outputs.tag }} | |
| steps: | |
| - name: Get tag | |
| id: vars | |
| run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
| - name: Validate version number | |
| run: >- | |
| if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then | |
| if ! [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then | |
| echo "Pre-release: Tag is missing beta suffix (${{ steps.vars.outputs.tag }})" | |
| exit 1 | |
| fi | |
| else | |
| if [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then | |
| echo "Release: Tag must not have a beta suffix (${{ steps.vars.outputs.tag }})" | |
| exit 1 | |
| fi | |
| fi | |
| build-sdist: | |
| name: Build source distribution | |
| needs: ['validate'] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install build dependencies | |
| run: pip install build | |
| - name: Set Python project version from tag | |
| run: sed -i 's/^version = "0.0.0"/version = "${{ needs.validate.outputs.version }}"/' pyproject.toml | |
| - name: Build sdist | |
| run: python3 -m build --sdist | |
| - uses: actions/upload-artifact@v7.0.0 | |
| with: | |
| name: dist-sdist | |
| path: ./dist/*.tar.gz | |
| build-wheels: | |
| name: Build wheels (${{ matrix.os }}, ${{ matrix.archs }}) | |
| needs: ['validate'] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| archs: x86_64 | |
| qemu: false | |
| - os: ubuntu-latest | |
| archs: aarch64 | |
| qemu: true | |
| - os: macos-latest | |
| archs: x86_64 arm64 | |
| qemu: false | |
| - os: windows-latest | |
| archs: AMD64 | |
| qemu: false | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Set Python project version from tag | |
| shell: python | |
| run: | | |
| import pathlib | |
| p = pathlib.Path("pyproject.toml") | |
| p.write_text(p.read_text().replace('version = "0.0.0"', 'version = "${{ needs.validate.outputs.version }}"', 1)) | |
| - name: Set up QEMU | |
| if: matrix.qemu | |
| uses: docker/setup-qemu-action@v4.0.0 | |
| with: | |
| platforms: arm64,arm | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v3.4.0 | |
| with: | |
| extras: uv | |
| env: | |
| CIBW_ENVIRONMENT: "SENDSPIN_REQUIRE_C_EXT=1" | |
| CIBW_BUILD: cp312-* cp313-* | |
| CIBW_BUILD_FRONTEND: "uv" | |
| CIBW_ARCHS: ${{ matrix.archs }} | |
| CIBW_SKIP: "*-musllinux_*" | |
| - uses: actions/upload-artifact@v7.0.0 | |
| with: | |
| name: dist-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
| path: ./wheelhouse/*.whl | |
| publish: | |
| needs: ['build-sdist', 'build-wheels'] | |
| environment: 'publish' | |
| name: Upload release to PyPI | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v8.0.0 | |
| with: | |
| pattern: dist-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish release to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ |