Various CI and doc refactors #1
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: build and publish | |
| on: | |
| release: | |
| types: [published] | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| permissions: {} | |
| jobs: | |
| hatch: | |
| name: sdist + pure wheel | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: release | |
| url: https://pypi.org/p/black | |
| permissions: | |
| id-token: write # Required for PyPI trusted publishing | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Set up latest Python | |
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 | |
| with: | |
| python-version: "3.13" | |
| pip-version: "25.3" | |
| pip-install: --group build | |
| - name: Build wheel and source distributions | |
| run: python -m hatch build | |
| - if: github.event_name == 'release' | |
| name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 | |
| with: | |
| verbose: true | |
| configure: | |
| name: generate wheels matrix | |
| runs-on: ubuntu-latest | |
| outputs: | |
| include: ${{ steps.set-matrix.outputs.include }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Set up latest Python | |
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 | |
| with: | |
| python-version: "3.13" | |
| pip-version: "25.3" | |
| pip-install: --group wheels | |
| - name: generate matrix | |
| if: | | |
| github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci: build all wheels') | |
| run: | | |
| { | |
| cibuildwheel --print-build-identifiers --platform linux \ | |
| | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ | |
| && cibuildwheel --print-build-identifiers --platform macos \ | |
| | pyp 'json.dumps({"only": x, "os": "macos-latest"})' \ | |
| && cibuildwheel --print-build-identifiers --platform windows \ | |
| | pyp 'json.dumps({"only": x, "os": "windows-latest"})' \ | |
| && cibuildwheel --print-build-identifiers --platform windows --archs ARM64 \ | |
| | pyp 'json.dumps({"only": x, "os": "windows-11-arm"})' | |
| } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix | |
| env: | |
| CIBW_ARCHS_LINUX: x86_64 | |
| CIBW_ARCHS_MACOS: x86_64 arm64 | |
| CIBW_ARCHS_WINDOWS: AMD64 | |
| - name: generate matrix (PR) | |
| if: | | |
| github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci: build all wheels') | |
| run: | | |
| { | |
| CIBW_BUILD="cp310-*" cibuildwheel --print-build-identifiers --platform linux | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' | |
| CIBW_BUILD="cp314-*" cibuildwheel --print-build-identifiers --platform windows | pyp 'json.dumps({"only": x, "os": "windows-latest"})' | |
| } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix | |
| env: | |
| CIBW_ARCHS_LINUX: x86_64 | |
| - id: set-matrix | |
| run: echo "include=$(cat /tmp/matrix)" | tee -a $GITHUB_OUTPUT | |
| mypyc: | |
| name: mypyc wheels ${{ matrix.only }} | |
| needs: configure | |
| runs-on: ${{ matrix.os }} | |
| environment: | |
| name: release | |
| url: https://pypi.org/p/black | |
| permissions: | |
| id-token: write # Required for PyPI trusted publishing | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.configure.outputs.include) }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| # Keep cibuildwheel version in sync with pyproject.toml | |
| - uses: pypa/cibuildwheel@63fd63b352a9a8bdcc24791c9dbee952ee9a8abc # v3.3.0 | |
| with: | |
| only: ${{ matrix.only }} | |
| - name: Upload wheels as workflow artifacts | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: ${{ matrix.only }}-mypyc-wheels | |
| path: ./wheelhouse/*.whl | |
| - if: github.event_name == 'release' | |
| name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 | |
| with: | |
| packages-dir: wheelhouse/ | |
| verbose: true | |
| update-stable: | |
| name: update stable branch | |
| needs: [hatch, mypyc] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout stable branch | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: stable | |
| fetch-depth: 0 | |
| persist-credentials: true # needed for `git push` below | |
| - name: Update stable branch to release tag & push | |
| run: | | |
| git reset --hard "${TAG_NAME}" | |
| git push | |
| env: | |
| TAG_NAME: ${{ github.event.release.tag_name }} |