|
| 1 | +name: extapi |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + test: |
| 7 | + strategy: |
| 8 | + matrix: |
| 9 | + os: [ ubuntu-latest, macos-latest ] |
| 10 | + python-version: ['3.10', '3.11', '3.12'] |
| 11 | + |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + submodules: recursive |
| 18 | + |
| 19 | + - name: Install uv |
| 20 | + uses: astral-sh/setup-uv@v3 |
| 21 | + |
| 22 | + - name: Set up Python ${{ matrix.python-version }} |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + |
| 27 | + - name: Install the project |
| 28 | + run: uv sync --all-extras --dev |
| 29 | + |
| 30 | + - name: Run style check |
| 31 | + run: uv run ruff format --check --diff $(package) |
| 32 | + |
| 33 | + - name: Run ruff |
| 34 | + run: uv run ruff check $(package) |
| 35 | + |
| 36 | + - name: Run mypy |
| 37 | + run: uv run mypy --enable-error-code ignore-without-code $(package) |
| 38 | + |
| 39 | + - name: Run deptry |
| 40 | + run: uv run deptry . -e 'env|\.env|venv|\.venv|\..+' |
| 41 | + |
| 42 | + - name: Run tests |
| 43 | + run: uv run pytest . |
| 44 | + |
| 45 | + build-wheels: |
| 46 | + name: Build wheels on ${{ matrix.os }} |
| 47 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + strategy: |
| 50 | + matrix: |
| 51 | + os: [ ubuntu-latest, windows-latest, macos-latest ] |
| 52 | + needs: |
| 53 | + - test |
| 54 | + |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + submodules: recursive |
| 59 | + |
| 60 | + - name: Install uv |
| 61 | + uses: astral-sh/setup-uv@v3 |
| 62 | + |
| 63 | + - uses: actions/setup-python@v5 |
| 64 | + |
| 65 | + - name: Install the project |
| 66 | + run: uv sync --all-extras --dev |
| 67 | + env: |
| 68 | + UV_SYSTEM_PYTHON: 1 |
| 69 | + |
| 70 | + - name: Install cibuildwheel |
| 71 | + run: pip install --upgrade cibuildwheel |
| 72 | + |
| 73 | + - name: Build wheels |
| 74 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 75 | + env: |
| 76 | + CIBW_BUILD: "cp310-* cp311-* cp312-*" |
| 77 | + |
| 78 | + - uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: wheels-${{ matrix.os }} |
| 81 | + path: ./wheelhouse/*.whl |
| 82 | + |
| 83 | + publish: |
| 84 | + name: Publish wheels |
| 85 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 86 | + needs: |
| 87 | + - build-wheels |
| 88 | + runs-on: ubuntu-latest |
| 89 | + steps: |
| 90 | + - name: Get tag |
| 91 | + id: get_tag |
| 92 | + run: echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//} |
| 93 | + |
| 94 | + - run: echo "Current tag is ${{ steps.get_tag.outputs.TAG }}" |
| 95 | + |
| 96 | + - uses: actions/checkout@v4 |
| 97 | + with: |
| 98 | + submodules: recursive |
| 99 | + |
| 100 | + - name: Set up Python |
| 101 | + uses: actions/setup-python@v5 |
| 102 | + with: |
| 103 | + python-version: '3.12' |
| 104 | + |
| 105 | + - name: Install dependencies |
| 106 | + run: | |
| 107 | + python -m pip install --upgrade pip setuptools wheel twine build |
| 108 | +
|
| 109 | + - uses: actions/download-artifact@v4 |
| 110 | + with: |
| 111 | + name: wheels-ubuntu-latest |
| 112 | + path: wheels-ubuntu |
| 113 | + |
| 114 | + - uses: actions/download-artifact@v4 |
| 115 | + with: |
| 116 | + name: wheels-macos-latest |
| 117 | + path: wheels-macos |
| 118 | + |
| 119 | + - uses: actions/download-artifact@v4 |
| 120 | + with: |
| 121 | + name: wheels-windows-latest |
| 122 | + path: wheels-windows |
| 123 | + |
| 124 | + - name: Publish dist |
| 125 | + run: | |
| 126 | + python -m build . -s |
| 127 | + tree dist wheels-ubuntu wheels-macos wheels-windows |
| 128 | + twine upload dist/* wheels-ubuntu/*.whl wheels-macos/*.whl wheels-windows/*.whl |
| 129 | + env: |
| 130 | + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} |
| 131 | + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} |
| 132 | + |
| 133 | + - uses: marvinpinto/action-automatic-releases@latest |
| 134 | + with: |
| 135 | + repo_token: "${{ secrets.GITHUB_TOKEN }}" |
| 136 | + prerelease: false |
| 137 | + title: ${{ steps.get_tag.outputs.TAG }} |
| 138 | + files: | |
| 139 | + wheels-ubuntu/*.whl |
| 140 | + wheels-macos/*.whl |
| 141 | + wheels-windows/*.whl |
| 142 | + dist/* |
0 commit comments