Publish to PyPI #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to PyPI | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| description: 'Publish target' | |
| required: true | |
| default: 'testpypi' | |
| type: choice | |
| options: | |
| - testpypi | |
| - pypi | |
| permissions: | |
| id-token: write # Required for trusted publishing (OIDC) | |
| contents: read | |
| jobs: | |
| build: | |
| name: Build distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v1 | |
| with: | |
| version: "latest" | |
| - name: Set up Python | |
| run: uv python install 3.14 | |
| - name: Install dependencies | |
| run: uv sync --all-extras --dev | |
| - name: Run tests | |
| run: uv run pytest -v | |
| - name: Run linting | |
| run: | | |
| uv run ruff check . | |
| uv run pyrefly check . | |
| - name: Build package | |
| run: uv build | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| publish-to-testpypi: | |
| name: Publish to TestPyPI | |
| # Only run on manual workflow dispatch with testpypi target | |
| # OR when a pre-release is published (e.g., v0.1.1-beta.1) | |
| if: | | |
| (github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi') || | |
| (github.event_name == 'release' && github.event.release.prerelease) | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/code-trajectory-mcp | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| publish-to-pypi: | |
| name: Publish to PyPI | |
| # Only run on manual workflow dispatch with pypi target | |
| # OR when a stable release is published (not a pre-release) | |
| if: | | |
| (github.event_name == 'workflow_dispatch' && inputs.target == 'pypi') || | |
| (github.event_name == 'release' && !github.event.release.prerelease) | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/code-trajectory-mcp | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |