Ensure uv is available for sdist build #358
This file contains 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 wheel, release and publish on new tag | |
on: [push, pull_request] | |
jobs: | |
lint: | |
name: run Ruff | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Optional, use if you use setuptools_scm | |
submodules: false # Optional, use if you have submodules | |
name: Check out repo | |
- uses: astral-sh/ruff-action@v3 | |
with: | |
args: "check --verbose" | |
build: | |
name: Build and test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9, 3.10.9, 3.11, 3.12, 3.13] | |
steps: | |
- name: check out repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Optional, use if you use setuptools_scm | |
submodules: false # Optional, use if you have submodules | |
- name: Install uv and set the python version | |
uses: astral-sh/setup-uv@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install the project and deps | |
run: uv sync --all-extras --dev | |
- name: Run tests | |
run: uv run pytest | |
- name: Build wheel | |
run: uv build --no-sources --wheel -o dist | |
- uses: actions/upload-artifact@v4 | |
name: Upload wheel as artifact | |
with: | |
name: wheels-${{ strategy.job-index }} | |
path: | | |
./dist/*.whl | |
make_sdist: | |
name: Make SDist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Optional, use if you use setuptools_scm | |
submodules: true # Optional, use if you have submodules | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Build SDist | |
run: uv build --no-sources --sdist -o dist | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
status_check: | |
name: All Checks | |
needs: [lint, build] | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Check status | |
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | |
run: exit 1 | |
release_artifacts: | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
name: Release repaired and tested wheels | |
needs: [status_check, make_sdist] | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download compressed artifacts | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts | |
merge-multiple: true | |
- name: Create release and upload wheels | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
artifacts: "${{ steps.download.outputs.download-path }}/*.whl,${{ steps.download.outputs.download-path }}/*.gz,${{ steps.download.outputs.download-path }}/*.so,${{ steps.download.outputs.download-path }}/*.dylib,${{ steps.download.outputs.download-path }}/*.lib,${{ steps.download.outputs.download-path }}/*.dll" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: PyPI Publish | |
uses: pypa/[email protected] | |
with: | |
packages-dir: ${{ steps.download.outputs.download-path }} |