diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ac4545..31a56ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,59 +3,135 @@ on: workflow_dispatch: push: branches: [ "main" ] - tags-ignore: [ "**" ] + tags: [ "*" ] pull_request: schedule: - cron: "0 8 * * *" concurrency: group: build-${{ github.ref }} cancel-in-progress: true + +permissions: + contents: read + jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} + linux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-latest + target: x86_64 + - runner: ubuntu-latest + target: x86 + - runner: ubuntu-latest + target: aarch64 + - runner: ubuntu-latest + target: armv7 + - runner: ubuntu-latest + target: s390x + - runner: ubuntu-latest + target: ppc64le + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.platform.target }} + path: dist + + windows: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: windows-latest + target: x64 + - runner: windows-latest + target: x86 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + architecture: ${{ matrix.platform.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-windows-${{ matrix.platform.target }} + path: dist + + macos: + runs-on: ${{ matrix.platform.runner }} strategy: - fail-fast: false matrix: - os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] - env: - CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y - CIBW_BEFORE_ALL_WINDOWS: rustup target add i686-pc-windows-msvc - CIBW_ENVIRONMENT_LINUX: "PATH=$HOME/.cargo/bin:$PATH" + platform: + - runner: macos-latest + target: x86_64 + - runner: macos-14 + target: aarch64 steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' - name: Build wheels - uses: pypa/cibuildwheel@v2.17.0 - - uses: actions/upload-artifact@v4 + uses: PyO3/maturin-action@v1 with: - name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} - path: ./wheelhouse/*.whl + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-macos-${{ matrix.platform.target }} + path: dist - build_sdist: - name: Build SDist + sdist: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Build SDist - run: pipx run build --sdist - - uses: actions/upload-artifact@v4 + - name: Build sdist + uses: PyO3/maturin-action@v1 with: - name: cibw-sdist - path: dist/*.tar.gz + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: dist - upload_pypi: - needs: [ build_wheels, build_sdist ] + release: + name: Release runs-on: ubuntu-latest environment: name: release url: https://pypi.org/p/pyproject-fmt permissions: id-token: write - if: github.event_name == 'release' && github.event.action == 'published' + if: "startsWith(github.ref, 'refs/tags/')" + needs: [ linux, windows, macos, sdist ] steps: - uses: actions/download-artifact@v4 + - name: Publish to PyPI + uses: PyO3/maturin-action@v1 with: - pattern: cibw-* - path: dist - merge-multiple: true - - uses: pypa/gh-action-pypi-publish@release/v1 + command: upload + args: --non-interactive --skip-existing wheels-*/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 137b809..f54e0c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,11 +30,21 @@ repos: - id: ruff-format - id: ruff args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix" ] - - repo: https://github.com/doublify/pre-commit-rust - rev: v1.0 + - repo: local hooks: - id: fmt + name: cargo fmt + description: Check if all files follow the rust fmt style + entry: cargo fmt --all -- --check --color always + language: rust + types: [ "rust" ] - id: clippy + name: cargo clippy + description: Check if all files follow the cargo clippy + entry: cargo clippy --fix --allow-dirty + language: rust + types: [ "rust" ] + pass_filenames: false - repo: meta hooks: - id: check-hooks-apply