.. meta:: :description: Design reusable GitHub Actions workflows for zero-secret PyPI OIDC Trusted Publishing and multi-architecture Docker Buildx releases to GHCR. :keywords: GitHub Actions, OIDC, PyPI, Docker, Shared Workflows, CI/CD, Security, Python, DevOps :author: Carlos Santos (@carlkidcrypto) :property=og:title: Automated PyPI & Docker Releases with OIDC Trusted Publishing :property=og:description: Design reusable GitHub Actions workflows for zero-secret PyPI OIDC Trusted Publishing and multi-architecture Docker Buildx releases to GHCR. :property=og:type: article :property=og:url: https://carlkidcrypto.github.io/blog/shared-workflows-oidc-pypi-docker-releases.html :property=og:image: https://carlkidcrypto.github.io/_static/logo.png :name=twitter:card: summary :name=twitter:title: Automated PyPI & Docker Releases with OIDC Trusted Publishing :name=twitter:description: Design reusable GitHub Actions workflows for zero-secret PyPI OIDC Trusted Publishing and multi-architecture Docker Buildx releases to GHCR. :name=twitter:image: https://carlkidcrypto.github.io/_static/logo.png ============================================================= Automated PyPI & Docker Releases with OIDC Trusted Publishing ============================================================= .. note:: * **Published:** November 30, 2026 * **Authors:** Written by Gemini 3.8 Flash, Co-Authored & Reviewed by `Carlos Santos (@carlkidcrypto) `_ * **Estimated Reading Time:** 7 minutes * **Tags:** `GitHub Actions` • `OIDC` • `PyPI` • `Docker` • `Shared Workflows` • `CI/CD` • `Security` Publishing Python wheels to PyPI and multi-architecture container images to GitHub Container Registry (GHCR) traditionally relied on long-lived static API tokens stored in repository secrets. If a token leaked or expired, maintainers faced broken release pipelines or urgent credential rotation across every project in their portfolio. OpenID Connect (OIDC) **Trusted Publishing** eliminates static secrets altogether. Instead of storing passwords or ``PYPI_API_TOKEN`` values, a GitHub Actions workflow requests a short-lived, cryptographically signed OIDC JWT token scoped strictly to that repository, tag, and environment. By centralizing these release jobs inside `shared-workflows `_, every Python package (`ezsnmp `_, `purpleair_api `_) and containerized service (`purpleair_data_logger `_, `purpleair-matterbridge `_) inherits uniform, zero-secret release automation. In this tutorial, we will design a reusable OIDC PyPI release workflow, build a multi-architecture Docker Buildx publisher for GHCR, and configure environment protection rules for safe automated deployments. How GitHub OIDC Trusted Publishing Works ======================================== When a workflow declares ``permissions: id-token: write``, GitHub's OIDC provider issues a short-lived JSON Web Token (JWT) containing verified claims about the workflow run: - ``repository`` and ``repository_owner`` (e.g. ``carlkidcrypto/ezsnmp``) - ``ref`` (the exact git tag, such as ``refs/tags/v2026.11.9b0``) - ``environment`` (for example, ``pypi`` or ``testpypi``) - ``job_workflow_ref`` (pointing to the reusable workflow in ``shared-workflows``) PyPI validates those OIDC claims against your pre-configured **Trusted Publisher** policy and issues an ephemeral upload token valid only for that single job. For container images, GHCR authenticates directly via the ephemeral job-scoped ``GITHUB_TOKEN`` (with ``packages: write``), while ``id-token: write`` and ``attestations: write`` enable cryptographic SLSA build provenance attestations. Reusable PyPI OIDC Release Workflow =================================== Store the shared PyPI publisher in ``.github/workflows/pypi-oidc.yml`` inside ``shared-workflows``. Notice that ``permissions`` are scoped cleanly: ``id-token: write`` for OIDC exchange and ``contents: read`` for checking out artifacts: .. code-block:: yaml name: Reusable PyPI OIDC Publish on: workflow_call: inputs: environment-name: description: "GitHub deployment environment (pypi or testpypi)" required: false type: string default: "pypi" artifact-name: description: "Name of the uploaded dist artifact" required: false type: string default: "python-dist" skip-existing: description: "Skip files already published on PyPI" required: false type: boolean default: false jobs: publish-pypi: runs-on: ubuntu-latest environment: name: ${{ inputs.environment-name }} permissions: id-token: write contents: read steps: - name: Download built wheels and sdist uses: actions/download-artifact@v4 with: name: ${{ inputs.artifact-name }} path: dist/ - name: Publish distributions via OIDC Trusted Publishing uses: pypa/gh-action-pypi-publish@release/v1 with: skip-existing: ${{ inputs.skip-existing }} repository-url: >- ${{ inputs.environment-name == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }} Multi-Arch Docker Buildx & GHCR OIDC Publishing =============================================== For containerized tools like ``purpleair_data_logger`` and ``purpleair-matterbridge``, a reusable Docker workflow builds ``linux/amd64`` and ``linux/arm64`` manifests and pushes directly to GHCR using the ephemeral ``GITHUB_TOKEN`` (no personal access token required): .. code-block:: yaml name: Reusable Multi-Arch Docker Publish on: workflow_call: inputs: image-name: description: "GHCR image name (e.g. ghcr.io/org/app)" required: true type: string platforms: description: "Target platforms for Buildx" required: false type: string default: "linux/amd64,linux/arm64" jobs: docker-release: runs-on: ubuntu-latest permissions: contents: read packages: write attestations: write id-token: write steps: - name: Checkout caller repository uses: actions/checkout@v4 - name: Set up QEMU for ARM64 emulation uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Docker metadata and semver tags id: meta uses: docker/metadata-action@v5 with: images: ${{ inputs.image-name }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=raw,value=latest,enable={{is_default_branch}} - name: Build and push multi-arch image uses: docker/build-push-action@v6 with: context: . platforms: ${{ inputs.platforms }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max Calling Shared Release Workflows Safely ======================================= In a downstream repository's ``.github/workflows/release.yml``, invoke the shared workflows with explicit least-privilege permissions and tag triggers: .. code-block:: yaml name: Release on: release: types: [published] permissions: contents: read jobs: build-wheels: uses: carlkidcrypto/shared-workflows/.github/workflows/wheels.yml@v1 publish-pypi: needs: build-wheels permissions: id-token: write contents: read uses: carlkidcrypto/shared-workflows/.github/workflows/pypi-oidc.yml@v1 with: environment-name: "pypi" Security Hardening Checklist ============================ 1. **Bind Trusted Publishers to GitHub Environments**: - Configure PyPI's Trusted Publisher settings to require the ``pypi`` GitHub Environment. Enable manual reviewer approvals or tag-branch restrictions on that environment so pull requests from forks can never mint production PyPI tokens. 2. **Avoid ``workflow_call`` Secret Inheritance for Release Jobs**: - Because OIDC relies on ``id-token: write`` rather than stored secrets, you can omit ``secrets: inherit`` completely on release jobs. 3. **Generate Build Provenance Attestations**: - Include ``attestations: write`` on Docker and wheel release jobs to attach cryptographic SLSA provenance directly to your GitHub Releases. Summary & What's Next ===================== Centralizing OIDC Trusted Publishing inside `shared-workflows `_ removes static API secrets across every repository while standardizing wheel and multi-arch container releases. In our next blog post, we will rotate back to `purpleair_api `_, exploring how to export normalized PurpleAir telemetry into GeoJSON FeatureCollections and Pandas DataFrames for spatial mapping and smoke plume analysis. ---- .. warning:: AI-generated content may contain misinformation or mistakes. A human does review this, but we are only human.