Repository navigation
3. Publish clear-your-tools to PyPI #190
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
| # Publish clear-your-tools to PyPI after cyt-indexer-sdk is on PyPI. | |
| # | |
| # One-time setup (repository maintainer with admin access): | |
| # | |
| # 1. PyPI — Trusted Publisher (https://pypi.org/manage/account/publishing/): | |
| # - PyPI project: clear-your-tools | |
| # - Owner: qdrddr | |
| # - Repository: clear-your-tools | |
| # - Workflow: publish-pypi.yml | |
| # - Environment name: pypi | |
| # | |
| # 2. GitHub — Environment (Settings → Environments → New environment): | |
| # - Name: pypi (approval gate on the publish job only; build/wait run without it) | |
| # - Optional: required reviewers, wait timer, deployment branch rule (main only) | |
| # - No secrets needed when using PyPI trusted publishing (OIDC) | |
| # | |
| # 3. Push tag vX.Y.Z (publish-crates.yml), then SDK PyPI publish; this workflow | |
| # runs when publish-pypi-sdk.yml succeeds. | |
| # When that workflow succeeds, this workflow runs automatically (workflow_run). | |
| # The version comes from the SDK publish run artifact; pyproject.toml is | |
| # updated in CI before the build. | |
| # | |
| # Manual runs: workflow_dispatch (optional version input to wait on PyPI only). | |
| name: 3. Publish clear-your-tools to PyPI | |
| on: | |
| workflow_run: | |
| workflows: ["2. Publish cyt-indexer-sdk to PyPI"] | |
| types: [completed] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Semver to wait for on PyPI (cyt-indexer-sdk; manual runs only) | |
| required: false | |
| permissions: | |
| contents: read | |
| actions: read | |
| jobs: | |
| build: | |
| name: Build clear-your-tools | |
| if: | | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Resolve version | |
| id: parse | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| PARENT_RUN_ID: ${{ github.event.workflow_run.id }} | |
| run: sdk/e2e/scripts/resolve-version-from-parent.sh | |
| - name: Wait for PyPI (cyt-indexer-sdk) | |
| if: steps.parse.outputs.version != '' | |
| env: | |
| CYT_RELEASE_VERSION: ${{ steps.parse.outputs.version }} | |
| run: sdk/e2e/scripts/wait-registry.sh pypi-sdk | |
| - name: Prepare Cargo workspace for CI | |
| run: bash scripts/ci/prepare-cargo-workspace.sh | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 | |
| with: | |
| python-version: "3.13" | |
| enable-cache: true | |
| - name: Set version for build | |
| if: steps.parse.outputs.version != '' | |
| run: uv version "${{ steps.parse.outputs.version }}" | |
| - name: Build sdist and wheel | |
| run: uv build | |
| - name: Upload dist artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist/ | |
| if-no-files-found: error | |
| publish: | |
| name: Upload to PyPI | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/clear-your-tools | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download dist artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ |