| name: Build and Publish Wheels |
|
|
| on: |
| push: |
| branches: [ main ] |
| tags: [ 'v*' ] |
| pull_request: |
| branches: [ main ] |
| workflow_dispatch: |
|
|
| jobs: |
| build_wheels: |
| name: Build wheels on ${{ matrix.os }} |
| runs-on: ${{ matrix.os }} |
| strategy: |
| fail-fast: false |
| matrix: |
| |
| os: [ubuntu-latest, windows-latest, macos-latest] |
|
|
| steps: |
| - uses: actions/checkout@v4 |
|
|
| - name: Build wheels |
| uses: pypa/cibuildwheel@v2.19.1 |
| env: |
| |
| |
| CIBW_BUILD: cp312-* |
|
|
| |
| |
| |
| CIBW_ARCHS_LINUX: x86_64 |
| CIBW_ARCHS_WINDOWS: AMD64 |
| CIBW_ARCHS_MACOS: x86_64 arm64 |
| |
| |
| |
| CIBW_ENVIRONMENT: CRAYON_FORCE_CPU=1 |
|
|
| |
| |
| |
| CIBW_TEST_COMMAND: cd {project}/tests && python -m unittest discover . |
|
|
| - uses: actions/upload-artifact@v4 |
| with: |
| name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| path: ./wheelhouse/*.whl |
|
|
| build_sdist: |
| name: Build Source Distribution |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v4 |
| |
| - name: Build SDist |
| run: pipx run build --sdist |
|
|
| - uses: actions/upload-artifact@v4 |
| with: |
| name: sdist |
| path: dist/*.tar.gz |
|
|
| publish_to_pypi: |
| name: Publish to PyPI |
| |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| needs: [build_wheels, build_sdist] |
| runs-on: ubuntu-latest |
| environment: |
| name: pypi |
| url: https://pypi.org/p/xerv-crayon |
| permissions: |
| id-token: write |
|
|
| steps: |
| - name: Download all artifacts |
| uses: actions/download-artifact@v4 |
| with: |
| |
| pattern: '*' |
| path: dist |
| merge-multiple: true |
|
|
| - name: Publish package distributions to PyPI |
| uses: pypa/gh-action-pypi-publish@release/v1 |
| with: |
| |
| |
| verbose: true |