Publish to PyPI #2
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: Publish to PyPI | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| sdist: | |
| name: Build sdist | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Build sdist | |
| run: | | |
| python -m pip install --upgrade pip build | |
| python -m build --sdist --outdir dist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-sdist | |
| path: dist/*.tar.gz | |
| wheels: | |
| name: Build wheels (py${{ matrix.python-version }}) | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up MSYS2 (MinGW toolchain) | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: UCRT64 | |
| update: true | |
| install: >- | |
| mingw-w64-ucrt-x86_64-toolchain | |
| mingw-w64-ucrt-x86_64-cmake | |
| mingw-w64-ucrt-x86_64-make | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Add MinGW to PATH | |
| shell: pwsh | |
| run: | | |
| Add-Content $env:GITHUB_PATH "C:\\msys64\\ucrt64\\bin" | |
| - name: Build + install (MinGW Makefiles) [smoke] | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install . -v --config-settings=cmake.args="-G MinGW Makefiles" | |
| - name: Build wheel (MinGW Makefiles) | |
| run: | | |
| python -m pip wheel . -w dist --no-deps -v --config-settings=cmake.args="-G MinGW Makefiles" | |
| - name: Import check | |
| run: | | |
| python -c "import truegraphics as tg; print('truegraphics', tg.__version__)" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-wheels-${{ matrix.python-version }} | |
| path: dist/*.whl | |
| publish: | |
| name: Publish (Trusted Publishing) | |
| needs: [sdist, wheels] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/truegraphics/ | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist-sdist | |
| path: dist | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: dist-wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist |