@@ -0,0 +1,142 @@ |
| 1 | +name: release |
| 2 | + |
| 3 | +# Tag-driven release: push a `v*` tag, the workflow builds the wheel + |
| 4 | +# sdist and publishes to PyPI via trusted-publisher OIDC (configure |
| 5 | +# the publisher under the project's PyPI settings before the first |
| 6 | +# real run). The docs site is deployed separately via `docs.yml`. |
| 7 | +# |
| 8 | +# Dry-run to test.pypi.org by pushing a `v*-rc*` tag (e.g. `v1.0.0-rc1`). |
| 9 | +# The publish step routes to the test index when the tag ends in `-rc*`. |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + tags: |
| 14 | + - "v*" |
| 15 | + |
| 16 | +permissions: |
| 17 | + # Required for trusted-publisher OIDC flow. |
| 18 | + id-token: write |
| 19 | + # Required so the workflow can read the repo on a tag push. |
| 20 | + contents: read |
| 21 | + |
| 22 | +env: |
| 23 | + UV_VERSION: "0.11.6" |
| 24 | + PYTHON_VERSION: "3.11" |
| 25 | + |
| 26 | +jobs: |
| 27 | + ci-gate: |
| 28 | + name: full CI must pass |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Install uv |
| 34 | + uses: astral-sh/setup-uv@v4 |
| 35 | + with: |
| 36 | + version: ${{ env.UV_VERSION }} |
| 37 | + |
| 38 | + - name: Sync (all groups) |
| 39 | + run: uv sync --all-extras --dev |
| 40 | + |
| 41 | + - name: Ruff |
| 42 | + run: uv run ruff check . |
| 43 | + |
| 44 | + - name: Ruff format |
| 45 | + run: uv run ruff format --check . |
| 46 | + |
| 47 | + - name: Mypy |
| 48 | + run: uv run mypy src/dlm |
| 49 | + |
| 50 | + - name: Pytest (non-slow) |
| 51 | + run: uv run pytest -m "not slow and not online and not gpu" |
| 52 | + |
| 53 | + build: |
| 54 | + name: build wheel + sdist |
| 55 | + needs: ci-gate |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Install uv |
| 61 | + uses: astral-sh/setup-uv@v4 |
| 62 | + with: |
| 63 | + version: ${{ env.UV_VERSION }} |
| 64 | + |
| 65 | + - name: Build |
| 66 | + run: uv build |
| 67 | + |
| 68 | + - name: Upload artifacts |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: dist |
| 72 | + path: dist/ |
| 73 | + |
| 74 | + publish-testpypi: |
| 75 | + name: publish to test.pypi.org (RC tags only) |
| 76 | + needs: build |
| 77 | + if: contains(github.ref, '-rc') |
| 78 | + runs-on: ubuntu-latest |
| 79 | + environment: |
| 80 | + name: test-pypi |
| 81 | + url: https://test.pypi.org/project/dlm/ |
| 82 | + steps: |
| 83 | + - uses: actions/download-artifact@v4 |
| 84 | + with: |
| 85 | + name: dist |
| 86 | + path: dist/ |
| 87 | + |
| 88 | + - name: Publish |
| 89 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 90 | + with: |
| 91 | + repository-url: https://test.pypi.org/legacy/ |
| 92 | + |
| 93 | + publish-pypi: |
| 94 | + name: publish to pypi.org (release tags) |
| 95 | + needs: build |
| 96 | + if: ${{ !contains(github.ref, '-rc') }} |
| 97 | + runs-on: ubuntu-latest |
| 98 | + environment: |
| 99 | + name: pypi |
| 100 | + url: https://pypi.org/project/dlm/ |
| 101 | + steps: |
| 102 | + - uses: actions/download-artifact@v4 |
| 103 | + with: |
| 104 | + name: dist |
| 105 | + path: dist/ |
| 106 | + |
| 107 | + - name: Publish |
| 108 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 109 | + |
| 110 | + deploy-docs: |
| 111 | + name: deploy docs for release |
| 112 | + needs: publish-pypi |
| 113 | + runs-on: ubuntu-latest |
| 114 | + permissions: |
| 115 | + contents: read |
| 116 | + pages: write |
| 117 | + id-token: write |
| 118 | + environment: |
| 119 | + name: github-pages |
| 120 | + url: ${{ steps.deployment.outputs.page_url }} |
| 121 | + steps: |
| 122 | + - uses: actions/checkout@v4 |
| 123 | + |
| 124 | + - name: Install uv |
| 125 | + uses: astral-sh/setup-uv@v4 |
| 126 | + with: |
| 127 | + version: ${{ env.UV_VERSION }} |
| 128 | + |
| 129 | + - name: Sync docs group |
| 130 | + run: uv sync --group docs |
| 131 | + |
| 132 | + - name: Build site |
| 133 | + run: uv run mkdocs build --clean --site-dir site/ |
| 134 | + |
| 135 | + - name: Upload Pages artifact |
| 136 | + uses: actions/upload-pages-artifact@v3 |
| 137 | + with: |
| 138 | + path: site/ |
| 139 | + |
| 140 | + - name: Deploy |
| 141 | + id: deployment |
| 142 | + uses: actions/deploy-pages@v4 |