chore: update pre-commit hooks #726
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
| # Reference: | |
| # - https://github.com/actions/checkout | |
| # - https://github.com/actions/download-artifact | |
| # - https://github.com/actions/upload-artifact | |
| # - https://github.com/pypa/cibuildwheel | |
| # - https://github.com/pypa/build | |
| # - https://github.com/pypa/gh-action-pypi-publish | |
| # - https://test.pypi.org/help/#apitoken | |
| name: ci-wheels | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - "main" | |
| - "v*x" | |
| - "!auto-update-lockfiles" | |
| - "!pre-commit-ci-update-config" | |
| - "!dependabot/*" | |
| tags: | |
| - "v*" | |
| jobs: | |
| build_bdist: | |
| name: "build ${{ matrix.os }} (${{ matrix.arch }}) wheels" | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
| arch: ["x86_64", "arm64"] | |
| exclude: | |
| - os: "ubuntu-latest" | |
| arch: "arm64" | |
| - os: "windows-latest" | |
| arch: "x86_64" | |
| - os: "windows-latest" | |
| arch: "arm64" | |
| include: | |
| - os: "windows-latest" | |
| arch: "AMD64" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: "build ${{ matrix.os }} (${{ matrix.arch }}) wheels" | |
| uses: pypa/cibuildwheel@v3.4.1 | |
| env: | |
| CIBW_SKIP: "cp39-* cp310-* cp311-* pp* *-musllinux*" | |
| CIBW_ARCHS: ${{ matrix.arch }} | |
| CIBW_BUILD_FRONTEND: "build" | |
| CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014" | |
| CIBW_TEST_SKIP: "*-macosx_arm64" | |
| CIBW_TEST_REQUIRES: "pytest" | |
| CIBW_TEST_COMMAND: > | |
| python -m pytest --pyargs stratify | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: pypi-${{ matrix.os }}-${{ matrix.arch }}-artifact | |
| path: ${{ github.workspace }}/wheelhouse/*.whl | |
| build_sdist: | |
| name: "Build sdist" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: "Building sdist" | |
| shell: bash | |
| run: | | |
| pipx run build --sdist | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: pypi-sdist | |
| path: ${{ github.workspace }}/dist/*.tar.gz | |
| show-artifacts: | |
| needs: [build_bdist, build_sdist] | |
| name: "Show artifacts" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| merge-multiple: true | |
| path: ${{ github.workspace }}/dist | |
| - shell: bash | |
| run: | | |
| ls -l ${{ github.workspace }}/dist | |
| publish-artifacts-test-pypi: | |
| needs: [build_bdist, build_sdist] | |
| name: "Publish to Test PyPI" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # Mandatory for PyPI Trusted Publishing OpenID Connect (OIDC) | |
| environment: test-pypi | |
| # upload to Test PyPI for every commit on main branch | |
| if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| merge-multiple: true | |
| path: ${{ github.workspace }}/dist | |
| - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b | |
| with: | |
| repository_url: https://test.pypi.org/legacy/ | |
| skip_existing: true | |
| print_hash: true | |
| publish-artifacts-pypi: | |
| needs: [build_bdist, build_sdist] | |
| name: "Publish to PyPI" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # Mandatory for PyPI Trusted Publishing OpenID Connect (OIDC) | |
| environment: pypi | |
| # upload to PyPI for every tag starting with 'v' | |
| if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| merge-multiple: true | |
| path: ${{ github.workspace }}/dist | |
| - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b | |
| with: | |
| print_hash: true |