Skip to content

Publish threadplane-middleware (Python) #1

Publish threadplane-middleware (Python)

Publish threadplane-middleware (Python) #1

# Staged PyPI publish workflow for threadplane-middleware (Python package).
#
# This workflow uses PyPI TRUSTED PUBLISHING (OIDC) — no API token secret is
# required. GitHub exchanges its OIDC token for a short-lived PyPI upload
# credential automatically when the job has `id-token: write`.
#
# To enable trusted publishing on PyPI:
# 1. Log into PyPI under the **cacheplane** organization.
# 2. Navigate to threadplane-middleware → Settings → "Trusted Publishers".
# 3. Add a **Pending Publisher** with:
# Repository: cacheplane/angular-agent-framework
# Workflow: publish-middleware-python.yml
# Environment: (leave blank, or set to "pypi" if you create one)
# 4. The FIRST-EVER publish must be bootstrapped locally by a maintainer
# using a PyPI API token (`uv publish --token <tok> dist/*`). After that
# initial upload creates the project on PyPI, all subsequent releases use
# OIDC from this workflow — no secret needed.
#
# This workflow is MANUALLY TRIGGERED ONLY — it will never run automatically
# on push or pull_request. A maintainer must dispatch it from the Actions tab
# (or via `gh workflow run`) after verifying the release is ready.
#
# Inputs:
# dry_run (default: true) — when true, `uv publish --dry-run` is used and
# nothing is uploaded to PyPI. Set to false only for a real release.
name: Publish threadplane-middleware (Python)
on:
# STAGED: dispatch manually only. Never add push: or pull_request: triggers.
workflow_dispatch:
inputs:
dry_run:
description: "Dry run — skip actual upload to PyPI (default: true)"
type: boolean
default: true
concurrency:
group: publish-middleware-python
cancel-in-progress: false
jobs:
build-and-publish:
name: Build and publish threadplane-middleware
runs-on: ubuntu-latest
permissions:
id-token: write # Required for OIDC trusted publishing to PyPI
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "latest"
- name: Run tests before publishing
working-directory: packages/threadplane-middleware
run: |
uv venv
uv pip install -e '.[test]'
uv run pytest -q
- name: Build distribution
working-directory: packages/threadplane-middleware
run: uv build
- name: Publish to PyPI (dry run)
if: ${{ inputs.dry_run == true }}
working-directory: packages/threadplane-middleware
run: uv publish --dry-run dist/*
- name: Publish to PyPI (real release — OIDC trusted publishing)
if: ${{ inputs.dry_run == false }}
working-directory: packages/threadplane-middleware
run: uv publish dist/*