[CI] Moves publishing logic to be a conditional sequence of jobs in t… #26
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: dev_test_project | ||
|
Check failure on line 1 in .github/workflows/tests.yaml
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: ["**.py", "**.c", "**.h", "**.toml", "*languages.json", "*MANIFEST.in"] | ||
| pull_request: | ||
| branches: [main] | ||
| paths: ["**.py", "**.c", "**.h", "**.toml", "*languages.json", "*MANIFEST.in"] | ||
| types: ["opened", "reopened", "synchronize"] | ||
| env: | ||
| OUTPUT_DIRECTORY: "/tmp/wheelhouse" | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.11", "3.12", "3.13", "3.14"] | ||
| container: | ||
| image: python:${{ matrix.python-version }} | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - name: Setup Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Build Python | ||
| run: | | ||
| python3 -m pip install --upgrade pip | ||
| pip install build pytest | ||
| pip install -e . --force-reinstall | ||
| - run: pytest -s | ||
| build-wheels: | ||
| if: startsWith(github.ref, "refs/tags/v") | ||
| name: Build wheels for ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| needs: test | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, ubuntu-22.04-arm, windows-latest, windows-11-arm, macos-12, macos-14] | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - run: mkdir $OUTPUT_DIRECTORY | ||
| - name: Run cibuildwheels | ||
| uses: pypa/cibuildwheel@v3.3.1 | ||
| with: | ||
| output-dir: ${{ env.OUTPUT_DIRECTORY }} | ||
| - name: Persist files for publish jobs | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wheels-${{ matrix.os }} | ||
| path: ${{ env.OUTPUT_DIRECTORY }} | ||
| build-sdist: | ||
| if: startsWith(github.ref, "refs/tags/v") | ||
| name: Build source distribution | ||
| runs-on: ubuntu-latest | ||
| needs: test | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - run: mkdir $OUTPUT_DIRECTORY | ||
| - name: Build sdist | ||
| run: pipx run build --sdist -o $OUTPUT_DIRECTORY | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: sdist | ||
| path: ${{ env.OUTPUT_DIRECTORY }} | ||
| publish: | ||
| name: Publish release to Pypi | ||
| runs-on: ubuntu-latest | ||
| needs: [build-wheels, build-sdist] | ||
| permissions: | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| path: dist | ||
| merge-multiple: true | ||
| - name: Upload to Pypi | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| # Temporary argument to test uploads to TestPyPI | ||
| with: | ||
| repository-url: https://test.pypi.org/legacy/ | ||