From 5c64a3500529fb1df28e68c0dad4eed191fadce9 Mon Sep 17 00:00:00 2001 From: Joseph Guhlin Date: Wed, 8 Jan 2025 09:13:12 +1300 Subject: [PATCH] Maturin default ci for release --- .github/workflows/create-python-release.yaml | 247 ++++++++++++------- 1 file changed, 159 insertions(+), 88 deletions(-) diff --git a/.github/workflows/create-python-release.yaml b/.github/workflows/create-python-release.yaml index ef358f6..046d300 100644 --- a/.github/workflows/create-python-release.yaml +++ b/.github/workflows/create-python-release.yaml @@ -1,105 +1,176 @@ -# Taken from Polar-rs github action - -name: Create Python release +# This file is autogenerated by maturin v1.8.1 +# To update, run +# +# maturin generate-ci github +# +name: CI on: + push: + branches: + - main + - master + tags: + - '*' + pull_request: workflow_dispatch: - inputs: - # Latest commit to include with the release. If omitted, use the latest commit on the main branch. - sha: - description: Commit SHA - type: string - # Create the sdist and build the wheels, but do not publish to PyPI / GitHub. - dry-run: - description: Dry run - type: boolean - default: false -env: - PYTHON_VERSION: '3.9' - PYTHON_VERSION_WIN_ARM64: '3.11' # ARM64 Windows doesn't have older versions - CARGO_INCREMENTAL: 0 - CARGO_NET_RETRY: 10 - RUSTUP_MAX_RETRIES: 10 - -defaults: - run: - shell: bash - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true +permissions: + contents: read jobs: - manylinux-x64_64: - runs-on: ubuntu-latest + linux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-22.04 + target: x86_64 + - runner: ubuntu-22.04 + target: x86 + - runner: ubuntu-22.04 + target: aarch64 + - runner: ubuntu-22.04 + target: armv7 + - runner: ubuntu-22.04 + target: s390x + - runner: ubuntu-22.04 + target: ppc64le steps: - uses: actions/checkout@v4 - with: - submodules: 'recursive' - uses: actions/setup-python@v5 with: - python-version: '3.7' - - - name: Publish wheel + python-version: 3.x + - name: Build wheels uses: PyO3/maturin-action@v1 - env: - MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - RUSTFLAGS: -C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma with: - rust-toolchain: nightly-2024-02-04 - maturin-version: '1.6.0' - command: publish - args: -m minimappers2/Cargo.toml --skip-existing -o wheels -u jguhlin - - # Needed for Docker on Apple M1 -# manylinux-aarch64: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/setup-python@v4 -# with: -# python-version: '3.7' -# -# - name: Publish wheel -# uses: messense/maturin-action@v1 -# env: -# MATURIN_PASSWORD: ${{ secrets.PYPI_PASS }} -# with: -# rust-toolchain: nightly-2023-01-19 -# target: aarch64-unknown-linux-gnu -# maturin-version: '0.14.10' -# command: publish -# args: -m minimappers2/Cargo.toml --skip-existing -o wheels -u jguhlin + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + manylinux: auto + - name: Build free-threaded wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist -i python3.13t + sccache: 'true' + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.platform.target }} + path: dist - # uncomment to build a universal2 wheel - # we don't run it because it is twice as big and not needed because we build for both architectures separately - # macos-aarch64-universal: - # runs-on: macos-latest - # steps: - # - uses: actions/checkout@v3 - # - uses: actions/setup-python@v4 - # with: - # python-version: '3.7' + musllinux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-22.04 + target: x86_64 + - runner: ubuntu-22.04 + target: x86 + - runner: ubuntu-22.04 + target: aarch64 + - runner: ubuntu-22.04 + target: armv7 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + manylinux: musllinux_1_2 + - name: Build free-threaded wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist -i python3.13t + sccache: 'true' + manylinux: musllinux_1_2 + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-musllinux-${{ matrix.platform.target }} + path: dist - # - name: Fix README symlink - # run: | - # rm py-polars/README.md - # cp README.md py-polars/README.md + # No support for minimap2 for windows - # - name: Set up Rust - # uses: dtolnay/rust-toolchain@master - # with: - # toolchain: nightly-2023-01-19 + macos: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: macos-13 + target: x86_64 + - runner: macos-14 + target: aarch64 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + - name: Build free-threaded wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist -i python3.13t + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-macos-${{ matrix.platform.target }} + path: dist - # - name: Set up Rust targets - # run: rustup target add aarch64-apple-darwin + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: dist - # - name: Publish wheel - # uses: messense/maturin-action@v1 - # env: - # MATURIN_PASSWORD: ${{ secrets.PYPI_PASS }} - # with: - # maturin-version: '0.14.10' - # command: publish - # args: -m py-polars/Cargo.toml --no-sdist --universal2 -o wheels -i python -u ritchie46 + release: + name: Release + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/py-') || github.event_name == 'workflow_dispatch' }} + needs: [linux, musllinux, macos, sdist] + permissions: + # Use to sign the release artifacts + id-token: write + # Used to upload release artifacts + contents: write + # Used to generate artifact attestation + attestations: write + steps: + - uses: actions/download-artifact@v4 + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-path: 'wheels-*/*' + - name: Publish to PyPI + if: ${{ startsWith(github.ref, 'refs/tags/') }} + uses: PyO3/maturin-action@v1 + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + with: + command: upload + args: --non-interactive --skip-existing wheels-*/* \ No newline at end of file