Skip to content

ci: make the release workflow safe to trigger - #45

Open
vkruoso wants to merge 1 commit into
leads2b:masterfrom
vkruoso:fix/release-workflow-safety
Open

ci: make the release workflow safe to trigger#45
vkruoso wants to merge 1 commit into
leads2b:masterfrom
vkruoso:fix/release-workflow-safety

Conversation

@vkruoso

@vkruoso vkruoso commented Sep 3, 2026

Copy link
Copy Markdown
Member

The release workflow needed fixing before 3.0.0 is tagged. Each item below would have caused a broken or unrecoverable release.

The tag pattern did not match this project

The workflow triggered on v*, but every tag in this repository is bare: 1.0, 2.0.2, 2.0.3, 2.1.1, 2.2.0. Tagging 3.0.0 would have matched nothing and the release would have been silently skipped, with no run and no error. It now triggers on [0-9]* and v[0-9]*, so either form works.

The tag was not checked against the packaged version

The version is read from receita/__init__.py through [tool.setuptools.dynamic], so the tag has no effect on what gets built. Tagging v3.0.0-rc1 as a trial run would have uploaded the real 3.0.0 to PyPI, and that version could never be uploaded again. The test job now compares the tag against the file and fails before anything is published:

v3.0.0     -> allowed
3.0.0      -> allowed
v3.0.1     -> blocked (version is 3.0.0)
v3.0.0-rc1 -> blocked (version is 3.0.0)

The irreversible step could run before the reversible one

publish and docker both depended only on test, so they ran in parallel. If PyPI succeeded and the image push failed, 3.0.0 could not be published again and the only way forward would be a version bump for a problem unrelated to the package. publish now depends on docker: an image tag can be overwritten, a PyPI version cannot, so the step that cannot be repeated runs last.

The latest image tag moved for pre-releases

type=raw,value=latest applied to any tag, so a pre-release would have become latest on Docker Hub. It is now limited to tags without a suffix.

A version can only be uploaded to PyPI once, so the release has to be
ordered and guarded around that step.

- trigger on the bare tags this project has always used, as well as on
  prefixed ones, so a release is not silently skipped
- check that the tag matches the version in receita/__init__.py before
  anything is published, since the version comes from that file and not
  from the tag
- publish to PyPI only after the image is pushed, as an image tag can be
  replaced but a PyPI version cannot
- keep the latest image tag on final releases only
Copilot AI lite review requested due to automatic review settings September 3, 2026 21:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The workflow changes match the stated release-safety requirements and do not introduce any clear functional or operational blockers.

Pull request overview

This PR hardens the GitHub Actions release pipeline so tagging 3.0.0 reliably triggers a release, validates the tag against the packaged version, and prevents irreversible publishing from happening before reversible steps (Docker push).

Changes:

  • Expand tag trigger patterns to support both bare tags (3.0.0) and v-prefixed tags (v3.0.0).
  • Add a CI check that fails early when the pushed tag doesn’t match receita/__init__.py’s __version__.
  • Serialize release steps by making PyPI publish depend on the Docker job, and prevent latest from moving on pre-release tags.
File summaries
File Description
.github/workflows/release.yml Makes release triggering/version validation stricter and orders Docker before PyPI to avoid unrecoverable releases.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +27 to +33
version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' receita/__init__.py)
tag=${GITHUB_REF_NAME#v}
echo "tag: $GITHUB_REF_NAME package version: $version"
if [ "$tag" != "$version" ]; then
echo "::error::tag $GITHUB_REF_NAME does not match the version $version in receita/__init__.py"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants