|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Triggers on a published GitHub release (the normal flow) and on pushing a |
| 4 | +# `v*` tag directly (useful for testing the build/test-wheel jobs without |
| 5 | +# cutting a full GitHub release). Publishing to PyPI only runs for the |
| 6 | +# `release: published` event — see the `publish` job's `if:` condition. |
| 7 | +on: |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + push: |
| 11 | + tags: |
| 12 | + - "v*" |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: release-${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +env: |
| 20 | + PIP_DISABLE_PIP_VERSION_CHECK: "1" |
| 21 | + |
| 22 | +jobs: |
| 23 | + # --------------------------------------------------------------------------- |
| 24 | + # Build sdist + wheel, validate metadata with twine, upload as artifacts |
| 25 | + # for the downstream jobs (and for manual inspection on tag-only runs). |
| 26 | + # --------------------------------------------------------------------------- |
| 27 | + build: |
| 28 | + name: Build distribution |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: "3.11" |
| 35 | + cache: pip |
| 36 | + - name: Install build tools |
| 37 | + run: | |
| 38 | + python -m pip install --upgrade pip |
| 39 | + pip install build twine |
| 40 | + - name: Build sdist + wheel |
| 41 | + run: python -m build |
| 42 | + - name: Validate distribution metadata (twine check) |
| 43 | + run: twine check dist/* |
| 44 | + - name: Upload distribution artifacts |
| 45 | + uses: actions/upload-artifact@v4 |
| 46 | + with: |
| 47 | + name: dist |
| 48 | + path: dist/ |
| 49 | + if-no-files-found: error |
| 50 | + |
| 51 | + # --------------------------------------------------------------------------- |
| 52 | + # Install the *built wheel* (not the editable/source checkout) in a clean |
| 53 | + # environment and run a small smoke subset — this is what actually catches |
| 54 | + # packaging mistakes (missing package-data, wrong `packages.find` excludes, |
| 55 | + # etc.) that `pip install -e .` in CI would never surface. |
| 56 | + # --------------------------------------------------------------------------- |
| 57 | + test-wheel: |
| 58 | + name: Test built wheel |
| 59 | + runs-on: ubuntu-latest |
| 60 | + needs: [build] |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + - uses: actions/setup-python@v5 |
| 64 | + with: |
| 65 | + python-version: "3.11" |
| 66 | + cache: pip |
| 67 | + - name: Download distribution artifacts |
| 68 | + uses: actions/download-artifact@v4 |
| 69 | + with: |
| 70 | + name: dist |
| 71 | + path: dist/ |
| 72 | + - name: Install the built wheel (+ test runner only, no editable install) |
| 73 | + run: | |
| 74 | + python -m pip install --upgrade pip |
| 75 | + python -m pip install dist/*.whl |
| 76 | + python -m pip install "pytest>=9.0.3" "pytest-asyncio>=0.21.0" |
| 77 | + - name: Import smoke test |
| 78 | + run: python -c "import multimind; print('multimind', multimind.__version__)" |
| 79 | + - name: Run smoke test subset against the installed wheel |
| 80 | + run: | |
| 81 | + pytest tests/test_import.py tests/test_basic.py -v --tb=short \ |
| 82 | + -m "not integration and not slow and not requires_api_key" |
| 83 | +
|
| 84 | + # --------------------------------------------------------------------------- |
| 85 | + # Publish to PyPI via OIDC trusted publishing — no long-lived API token |
| 86 | + # secrets are stored or referenced. Requires a one-time trusted-publisher |
| 87 | + # registration on pypi.org (see docs/releasing.md). Only runs for an |
| 88 | + # actual published GitHub release, never for a bare tag push or |
| 89 | + # workflow_dispatch, so tag-based testing of build/test-wheel can't |
| 90 | + # accidentally publish. |
| 91 | + # --------------------------------------------------------------------------- |
| 92 | + publish: |
| 93 | + name: Publish to PyPI |
| 94 | + runs-on: ubuntu-latest |
| 95 | + needs: [test-wheel] |
| 96 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 97 | + environment: |
| 98 | + name: pypi |
| 99 | + url: https://pypi.org/project/multimind-sdk/ |
| 100 | + permissions: |
| 101 | + id-token: write # required for OIDC trusted publishing — no API token needed |
| 102 | + steps: |
| 103 | + - name: Download distribution artifacts |
| 104 | + uses: actions/download-artifact@v4 |
| 105 | + with: |
| 106 | + name: dist |
| 107 | + path: dist/ |
| 108 | + - name: Publish to PyPI |
| 109 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 110 | + with: |
| 111 | + packages-dir: dist/ |
| 112 | + |
| 113 | + # --- TestPyPI variant (commented out) --------------------------------- |
| 114 | + # Useful while setting up trusted publishing for the first time, or for |
| 115 | + # dry-running a release without touching the real index. Requires its |
| 116 | + # own trusted-publisher registration on test.pypi.org and a separate |
| 117 | + # `testpypi` environment (see docs/releasing.md). |
| 118 | + # |
| 119 | + # - name: Publish to TestPyPI |
| 120 | + # uses: pypa/gh-action-pypi-publish@release/v1 |
| 121 | + # with: |
| 122 | + # repository-url: https://test.pypi.org/legacy/ |
| 123 | + # packages-dir: dist/ |
0 commit comments