|
| 1 | +on: |
| 2 | + push: |
| 3 | + tags: |
| 4 | + - "*" |
| 5 | + branches: |
| 6 | + - test-release |
| 7 | + |
| 8 | +jobs: |
| 9 | + release-build: |
| 10 | + name: Build distribution |
| 11 | + runs-on: ubuntu-latest |
| 12 | + needs: [format, typecheck] # Add format and typecheck as dependencies |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Install uv |
| 17 | + uses: astral-sh/setup-uv@v3 |
| 18 | + |
| 19 | + - name: "Set up Python" |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version-file: ".python-version" |
| 23 | + |
| 24 | + - name: Install the project |
| 25 | + run: uv sync --frozen --all-extras --dev |
| 26 | + |
| 27 | + - name: Build |
| 28 | + run: uv build |
| 29 | + |
| 30 | + - name: Upload artifacts |
| 31 | + uses: actions/upload-artifact@v4 |
| 32 | + with: |
| 33 | + name: release-dists |
| 34 | + path: dist/ |
| 35 | + |
| 36 | + format: # Add format check job |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Install uv |
| 42 | + uses: astral-sh/setup-uv@v3 |
| 43 | + with: |
| 44 | + enable-cache: true |
| 45 | + |
| 46 | + - name: "Set up Python" |
| 47 | + uses: actions/setup-python@v5 |
| 48 | + with: |
| 49 | + python-version-file: ".python-version" |
| 50 | + |
| 51 | + - name: Install the project |
| 52 | + run: uv sync --frozen --all-extras --dev |
| 53 | + |
| 54 | + - name: Run ruff format check |
| 55 | + run: uv run --frozen ruff check . |
| 56 | + |
| 57 | + typecheck: # Add type check job |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Install uv |
| 63 | + uses: astral-sh/setup-uv@v3 |
| 64 | + with: |
| 65 | + enable-cache: true |
| 66 | + |
| 67 | + - name: "Set up Python" |
| 68 | + uses: actions/setup-python@v5 |
| 69 | + with: |
| 70 | + python-version-file: ".python-version" |
| 71 | + |
| 72 | + - name: Install the project |
| 73 | + run: uv sync --frozen --all-extras --dev |
| 74 | + |
| 75 | + - name: Run pyright |
| 76 | + run: uv run --frozen pyright |
| 77 | + |
| 78 | + pypi-publish: |
| 79 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 80 | + name: Upload release to PyPI |
| 81 | + runs-on: ubuntu-latest |
| 82 | + environment: release |
| 83 | + needs: |
| 84 | + - release-build |
| 85 | + permissions: |
| 86 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 87 | + |
| 88 | + steps: |
| 89 | + - name: Retrieve release distributions |
| 90 | + uses: actions/download-artifact@v4 |
| 91 | + with: |
| 92 | + name: release-dists |
| 93 | + path: dist/ |
| 94 | + |
| 95 | + - name: Publish package distributions to PyPI |
| 96 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 97 | + |
| 98 | + test-pypi-publish: |
| 99 | + name: Upload release to TestPyPI |
| 100 | + runs-on: ubuntu-latest |
| 101 | + environment: release |
| 102 | + needs: |
| 103 | + - release-build |
| 104 | + permissions: |
| 105 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 106 | + |
| 107 | + steps: |
| 108 | + - name: Retrieve release distributions |
| 109 | + uses: actions/download-artifact@v4 |
| 110 | + with: |
| 111 | + name: release-dists |
| 112 | + path: dist/ |
| 113 | + |
| 114 | + - name: Publish package distributions to TestPyPI |
| 115 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 116 | + with: |
| 117 | + repository-url: https://test.pypi.org/legacy/ |
0 commit comments