Migrate Kolibri PyPI publishing to OIDC trusted publishing
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Migrate the existing Kolibri PyPI publishing pipeline (pypi_upload.yml and its callers in release_kolibri.yml) from API-token authentication to PyPI OIDC trusted publishing. Drop GPG signing of artifacts, which PyPI deprecated in May 2023 (the API accepts but ignores GPG signatures, and the website no longer displays them).
This brings Kolibri's main package publishing in line with our other Python package repos and is a prerequisite for the Python monorepo setup (#14663), which will introduce a separate OIDC-based workflow for member packages.
Complexity: Medium Target branch: develop
Context
.github/workflows/pypi_upload.yml is a reusable workflow (workflow_call) that uploads pre-built Kolibri wheel/tarball artifacts to PyPI or TestPyPI. It currently:
- Authenticates to PyPI/TestPyPI using long-lived API tokens (
PYPI_API_TOKEN,TESTPYPI_API_TOKEN) passed as secrets. - GPG-signs both the
.whland.tar.gzbefore upload usingGPG_SIGNING_KEYandGPG_PASSPHRASE. - Uploads via
twine.
It is called from .github/workflows/release_kolibri.yml twice:
- For TestPyPI after the wheel is built.
- For PyPI after a manual approval gate (
block_release_step).
Both call sites pass the four secrets above.
OIDC trusted publishing requires:
- The caller workflow to grant
permissions: id-token: writeat the appropriate level for the reusable workflow to inherit it. - A trusted publisher configuration registered in the PyPI and TestPyPI project settings, naming this repository, the workflow filename, and (optionally) an environment.
GitHub Actions reusable workflows in the same repository inherit OIDC tokens from the caller, but the permissions and environment scoping have some quirks worth verifying during implementation.
The Change
Reusable workflow (pypi_upload.yml):
- Replace
twine uploadwithpypa/gh-action-pypi-publish, configured for OIDC trusted publishing (nopasswordinput). - Remove the GPG signing steps and the
GPG_SIGNING_KEY/GPG_PASSPHRASEsecrets from the workflow signature. - Remove the
PYPI_API_TOKEN/TESTPYPI_API_TOKENsecrets from the workflow signature. - Add
permissions: id-token: writeto the publish job so OIDC tokens can be requested. - Keep the
testboolean input — TestPyPI continues to be supported via the publish action'srepository-urlparameter.
Caller (release_kolibri.yml):
- Update both call sites (the TestPyPI upload after build, and the PyPI upload after the release approval gate) to drop the now-unused secrets.
- Add
permissions: id-token: writeat the appropriate level so the reusable workflow inherits the OIDC token.
PyPI configuration (manual, out-of-band):
- Register a trusted publisher in the
kolibriproject's PyPI settings naming this repository and thepypi_upload.ymlworkflow filename. No environment scoping. - Register the equivalent trusted publisher in TestPyPI.
Out of Scope
- The new monorepo member-package PyPI publishing workflow — added by #14663.
- Changes to the
release_kolibri.ymlrelease flow beyond removing the now-unused secrets and addingid-token: writepermissions. - Re-signing or back-signing previously published Kolibri releases.
- Migration of any other repository's PyPI publishing.
Follow-up
After the next release publishes successfully under OIDC, the now-unused repository secrets (PYPI_API_TOKEN, TESTPYPI_API_TOKEN, GPG_SIGNING_KEY, GPG_PASSPHRASE) should be deleted from the learningequality/kolibri GitHub settings. A repo-wide search should first confirm no other workflow references them.
Acceptance Criteria
Reusable workflow
- [ ]
pypi_upload.ymlusespypa/gh-action-pypi-publishinstead oftwine. - [ ] OIDC trusted publishing is used; no PyPI/TestPyPI API tokens are passed as secrets.
- [ ]
permissions: id-token: writeis set on the publish job. - [ ] GPG signing steps are removed.
- [ ]
GPG_SIGNING_KEY,GPG_PASSPHRASE,PYPI_API_TOKEN,TESTPYPI_API_TOKENno longer appear in the workflow'ssecrets:block. - [ ] The
testboolean input still toggles between TestPyPI and PyPI (viarepository-url).
Caller workflow
- [ ] Both
pypi_upload.ymlcall sites inrelease_kolibri.ymlno longer pass the removed secrets. - [ ] The caller grants
permissions: id-token: writeat the level needed for the reusable workflow to inherit it.
PyPI / TestPyPI configuration
- [ ] A trusted publisher is registered for the
kolibriproject on PyPI naming this repository and thepypi_upload.ymlworkflow filename. - [ ] A trusted publisher is registered for the
kolibriproject on TestPyPI naming this repository and thepypi_upload.ymlworkflow filename.
References
- Current reusable workflow:
.github/workflows/pypi_upload.yml - Caller workflow:
.github/workflows/release_kolibri.yml(search forpypi_upload.yml) - PyPI publish action: https://github.com/pypa/gh-action-pypi-publish
- PyPI OIDC trusted publishing documentation: https://docs.pypi.org/trusted-publishers/
- PyPI GPG signature deprecation: https://blog.pypi.org/posts/2023-05-23-removing-pgp/
- Precedents in our other Python packages:
- https://github.com/learningequality/le-utils/blob/main/.github/workflows/pypi-publish.yml
- https://github.com/learningequality/morango/blob/main/.github/workflows/python-publish.yml
- https://github.com/learningequality/ricecooker/blob/main/.github/workflows/python-publish.yml
AI usage
Used Claude Code to draft this issue iteratively from a brief prompt. I drove scope and decisions throughout — confirming OIDC as the goal, dropping GPG signing, declining to scope the trusted publisher to a GitHub Actions environment (after Claude raised the option and the reusable-workflow quirk), and choosing to verify the migration on the next real release rather than via manual workflow_dispatch testing. Claude reviewed the existing workflow and its callers, surfaced the OIDC token inheritance behaviour for reusable workflows, and edited drafts before each was accepted.
Plan: Replace API-token + GPG signing in pypi_upload.yml with OIDC trusted publishing via pypa/gh-action-pypi-publish, and update release_kolibri.yml to grant the necessary OIDC permissions.
- [ ] Migrate
pypi_upload.ymlto OIDC - [ ] Update
release_kolibri.ymlcaller - [ ] Register Trusted Publishers on PyPI and TestPyPI (manual, out-of-band)
- [ ] Final Verification Against Acceptance Criteria
- [ ] Post-Release Secret Cleanup (follow-up, after first successful OIDC release)
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
- Ran the project's full test suite and linter before committing
- For UI changes: captured live screenshots to verify rendering
- For backend changes: verified with example API/CLI output
The code changes for this issue are complete and committed:
pypi_upload.ymlhas been rewritten to usepypa/gh-action-pypi-publishwith OIDC trusted publishing — no API tokens, no GPG signing,id-token: writeset on the deploy job.release_kolibri.ymlhas been updated to addid-token: writeat the top-level permissions and bothpypi_upload.ymlcall sites no longer pass the removed secrets.
Manual action required — Task 3:
Before the next release, a human with owner/maintainer access to the kolibri project on PyPI and TestPyPI needs to register trusted publishers:
TestPyPI: https://test.pypi.org/manage/project/kolibri/settings/publishing/
- Owner:
learningequality - Repository:
kolibri - Workflow:
pypi_upload.yml - Environment: (leave blank)
PyPI: https://pypi.org/manage/project/kolibri/settings/publishing/
- Owner:
learningequality - Repository:
kolibri - Workflow:
pypi_upload.yml - Environment: (leave blank)
Once those are registered, the workflow changes are ready to use on the next release. The four legacy secrets (PYPI_API_TOKEN, TESTPYPI_API_TOKEN, GPG_SIGNING_KEY, GPG_PASSPHRASE) can be deleted from repository settings after the first successful OIDC-authenticated publish.
Yes, we will do that - please open the pull request for this work now though!
Are you waiting for something else here? Please open the pull request.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
I've given you a response, you're just not doing anything about it!