ci: add release workflow with PyPI Trusted Publishing#5
Merged
Conversation
Pipeline triggered on push of a vX.Y.Z (or X.Y.Z) tag and via workflow_dispatch. Builds sdist+wheel, validates with twine check --strict, smoke-imports the wheel in a clean venv, creates a GitHub Release with the artifacts attached, and publishes to PyPI via Trusted Publishing (OIDC) with a PYPI_API_TOKEN fallback gated by the USE_PYPI_TOKEN repo variable. Refs #4
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что меняем
Добавляем единый workflow
.github/workflows/release.ymlдля публикации релизов в PyPI и GitHub Releases по push тега.Refs #4.
Триггеры
pushтега видаvX.Y.ZилиX.Y.Z(с поддержкой pre-release-суффиксов:1.2.0rc1,1.2.0a1,1.2.0b2).workflow_dispatchс обязательнымversionи опциональнымpublish_to_pypi.Структура pipeline
build
project.versionвpyproject.tomlс целевой версией (фейлит сборку при рассинхроне).python -m build→ sdist + wheel.twine check --strict dist/*.import fastapi_viewsets.dist/как artifactpython-package-distributions.github-release (только для push тега)
RELEASE_<version>.md(если есть), иначе изRELEASE_NOTES.md, иначе авто-генерация.prerelease: trueдля версий сa/b/rc.pypi-publish
id-token: write) черезpypa/gh-action-pypi-publish@release/v1.USE_PYPI_TOKEN=true, используется secretPYPI_API_TOKEN.environment: pypi— после первого релиза в этом окружении можно включить required reviewers / branch protection.Что нужно сделать перед первым релизом
Один из двух путей (см.
TRUSTED_PUBLISHER_SETUP.md):A. Trusted Publisher (рекомендуется):
fastapi-viewsets, ownersvalench, repofastapi_viewsets, workflowrelease.yml, environmentpypi.B. API-токен:
USE_PYPI_TOKEN=trueв Settings → Variables → Actions.PYPI_API_TOKEN.После мерджа достаточно запушить тег
1.2.0:git tag -a 1.2.0 -m "Release 1.2.0" git push origin 1.2.0…и весь pipeline отработает автоматически.
Соотношение со старыми workflow
Старые
publish.ymlиpublish-manual.ymlоставлены без изменений — их можно удалить отдельным PR после успешного релиза1.2.0через новый workflow, чтобы избежать двойной публикации.Чек-лист
concurrencyгруппа предотвращает параллельные запуски на одном тегеpyproject.tomlсверяется с тегом