Skip to content

ci: publish package to PyPI on release tags - #30

Merged
JAugusto42 merged 5 commits into
mainfrom
chore/publish-pypi
Oct 14, 2026
Merged

JAugusto42 merged 5 commits into
mainfrom
chore/publish-pypi

Conversation

@JAugusto42

@JAugusto42 JAugusto42 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Automates publishing conviso-cli to PyPI when a release tag is pushed, restricts who can trigger a release, and fixes a packaging issue that would break the published package.

Changes

  • New workflow .github/workflows/publish-pypi.yml, triggered only by tags matching vX.Y.Z:
    1. authorize – both the user who pushed the tag (github.actor) and the user who started the run (github.triggering_actor, which differs on re-runs) must have admin or maintain role on the repository.
    2. tests – installs the package and runs pytest.
    3. version-check – fails if the tag (minus v) differs from src/conviso/VERSION.
    4. build-and-publish-pypi – python -m build, twine check, twine upload using the SRE_PYPI_TOKEN secret.
  • Packaging fix (pyproject.toml): security_gate_rules_schema.json was not included in the wheel, so conviso security-gate would fail when installed from PyPI. VERSION and *.json are now declared as package data.
  • Docs (CONTRIBUTING.md): new "Releases" section describing the SemVer + vX.Y.Z tag convention.

Security

Since this is a public repository, publishing is restricted:

  • The authorize job checks the role of both the tag pusher and the run initiator (granted through the convisolabs organization), so a maintainer re-running the workflow cannot publish a tag pushed by an unauthorized user.

  • Workflow token permissions are limited to contents: read.

  • Concurrent releases are prevented.

Direct org/team membership is not checked because the default GITHUB_TOKEN cannot read private organization membership; doing so would require an extra token with read:org.

Known limitation: SRE_PYPI_TOKEN is a repository secret, so a user with write access could still expose it through another workflow. Recommended follow-ups:

  • Add a tag ruleset restricting creation/update/deletion of v* tags to the release team.
  • Move to PyPI Trusted Publishing (OIDC) to remove the long-lived token.

Release convention

New releases are tagged vX.Y.Z. Existing bare tags (0.3.9, …) remain untouched. Tags in any other format do not trigger publishing.

How to test

  • pip wheel --no-deps . -w dist && unzip -l dist/*.whl | grep -E "VERSION|\.json" – both files should be listed.
  • After merge, bump src/conviso/VERSION and push a matching tag (e.g. v0.5.2) as a maintainer to trigger the first publish.

@JAugusto42 JAugusto42 self-assigned this Oct 14, 2026
@firedragon9511

Copy link
Copy Markdown

[P1] Authorize the original tag pusher on re-runs

github.triggering_actor changes to the user who initiates a re-run, while github.actor remains the user who triggered the original workflow run. Therefore, a user with write access can push a release tag and fail authorization, but if a maintainer later re-runs the workflow, this check sees the maintainer and allows the tagged code to reach the publish job.

Please validate github.actor to authorize the original tag push. If re-runs must also be restricted to maintainers, validate both github.actor and github.triggering_actor.

GitHub documents this distinction here: https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#github-context

Resumo em português

A checagem atual valida quem clicou para reexecutar o workflow, não necessariamente quem criou a tag. Assim, uma tag criada por alguém sem permissão de release pode acabar sendo publicada caso um mantenedor reexecute o workflow.

Como reproduzir

  1. Com um usuário que tenha write, mas não maintain ou admin, envie uma tag válida, como v0.5.2, apontando para um commit cuja versão seja 0.5.2.
  2. Confirme que o job authorize falha na primeira execução.
  3. Com uma conta de mantenedor, use a opção para reexecutar todos os jobs desse workflow.
  4. No re-run, github.triggering_actor será o mantenedor, enquanto github.actor continuará sendo o usuário que criou a execução original.
  5. O job authorize passará e os jobs de teste, build e publicação poderão continuar para a tag criada pelo usuário não autorizado.

@firedragon9511

Copy link
Copy Markdown

Confirmed fixed. The workflow now validates both github.actor (the original tag pusher) and github.triggering_actor (the user initiating a re-run), requiring admin or maintain for both. An unauthorized tag therefore remains blocked even when a maintainer re-runs the workflow. This resolves the blocking issue.

Comment thread .github/workflows/publish-pypi.yml Resolved
Comment thread .github/workflows/publish-pypi.yml Resolved
@JAugusto42
JAugusto42 merged commit 2b9e82d into main Oct 14, 2026
6 checks passed
@JAugusto42
JAugusto42 deleted the chore/publish-pypi branch October 14, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants