|
| 1 | +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI |
| 2 | + |
| 3 | +on: push |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: Build distribution 📦 |
| 8 | + runs-on: ubuntu-latest |
| 9 | + defaults: |
| 10 | + run: |
| 11 | + working-directory: ./Server |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v6 |
| 15 | + |
| 16 | + - name: Install uv |
| 17 | + uses: astral-sh/setup-uv@v7 |
| 18 | + with: |
| 19 | + version: "latest" |
| 20 | + enable-cache: true |
| 21 | + cache-dependency-glob: "Server/uv.lock" |
| 22 | + |
| 23 | + - name: Build a binary wheel and a source tarball |
| 24 | + run: uv build |
| 25 | + |
| 26 | + - name: Store the distribution packages |
| 27 | + uses: actions/upload-artifact@v6 |
| 28 | + with: |
| 29 | + name: python-package-distributions |
| 30 | + path: Server/dist/ |
| 31 | + |
| 32 | + publish-to-pypi: |
| 33 | + name: >- |
| 34 | + Publish Python 🐍 distribution 📦 to PyPI |
| 35 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 36 | + needs: |
| 37 | + - build |
| 38 | + runs-on: ubuntu-latest |
| 39 | + environment: |
| 40 | + name: pypi |
| 41 | + url: https://pypi.org/p/mcpforunityserver |
| 42 | + permissions: |
| 43 | + id-token: write |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Download all the dists |
| 47 | + uses: actions/download-artifact@v7 |
| 48 | + with: |
| 49 | + name: python-package-distributions |
| 50 | + path: dist/ |
| 51 | + - name: Publish distribution 📦 to PyPI |
| 52 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 53 | + |
| 54 | + publish-to-testpypi: |
| 55 | + name: Publish Python 🐍 distribution 📦 to TestPyPI |
| 56 | + needs: |
| 57 | + - build |
| 58 | + runs-on: ubuntu-latest |
| 59 | + |
| 60 | + environment: |
| 61 | + name: testpypi |
| 62 | + url: https://test.pypi.org/p/mcpforunityserver |
| 63 | + |
| 64 | + permissions: |
| 65 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Download all the dists |
| 69 | + uses: actions/download-artifact@v7 |
| 70 | + with: |
| 71 | + name: python-package-distributions |
| 72 | + path: dist/ |
| 73 | + - name: Publish distribution 📦 to TestPyPI |
| 74 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 75 | + with: |
| 76 | + repository-url: https://test.pypi.org/legacy/ |
0 commit comments