Skip to content

ci: build and publish a release when a tag is pushed - #3

Merged
Marcus778899 merged 1 commit into
mainfrom
ci/release-workflow
Aug 10, 2026
Merged

Marcus778899 merged 1 commit into
mainfrom
ci/release-workflow

Conversation

@Marcus778899

Copy link
Copy Markdown
Owner

Needed before v2.0.0 can be tagged: a workflow file only runs if it exists in the commit the tag points at, so this has to land on main first.

What pushing a tag does

git tag -a v2.0.0 -m "v2.0.0"
git push origin v2.0.0

.github/workflows/release.yml then:

  1. checks the tag against __version__ and stops before building if they differ
  2. runs the tests
  3. uv build
  4. imports the built wheel in an empty environment
  5. publishes a GitHub Release with both distributions attached

Steps 1 and 2 are there because a tag can point at any commit — nothing else keeps the version in the artefact matching the version people install by, or guarantees the tagged commit ever passed CI.

Why the release, and not just the tag

A bare tag gives you only what GitHub generates:

Asset What it is
loggerhelper-2.0.0-py3-none-any.whl The wheel — attached by this workflow
loggerhelper-2.0.0.tar.gz The sdist — attached by this workflow
Source code (zip) / (tar.gz) Added by GitHub for free; a snapshot of the repository, not a built package

The last row is the one worth knowing about: those archives are the repo at that commit, so installing from one builds from source rather than installing a wheel.

After a release, the wheel is directly installable:

pip install https://github.com/Marcus778899/LoggerPackage/releases/download/v2.0.0/loggerhelper-2.0.0-py3-none-any.whl

Implementation notes

gh release create rather than a third-party action — the CLI is already on the runner, and it is one less thing holding write access to the repository. permissions: contents: write is scoped to this job only.

uv publish stays manual and documented, since it needs a token.

Also: .gitattributes

Unrelated to releases, but it has been generating noise all along. Git checks out CRLF on Windows while the mixed-line-ending hook rewrites to LF, so the two undo each other on every pre-commit run --all-files and every commit prints a wall of LF will be replaced by CRLF warnings. * text=auto eol=lf settles it. Drop this file if you would rather keep the current behaviour — it is the one change here that is not about releasing.

Content was already stored as LF, so git add --renormalize . was a no-op; the diff is three files.

Verification

  • Both workflow files parse as YAML; the tag-vs-__version__ extraction was run against the real __init__.py and matches 2.0.0
  • 161 tests, pre-commit run --all-files clean, uv build produces a wheel that imports from a clean environment
  • The workflow itself cannot be exercised until a tag is pushed

🤖 Generated with Claude Code

Pushing a tag matching v* now builds the wheel and the sdist and attaches both
to a GitHub Release. A bare tag gives you only the "Source code" archives GitHub
generates, which are snapshots of the repository rather than built packages, so
installing from one means building from source.

The workflow refuses to build when the tag does not match __version__. A tag can
point at any commit, so nothing else keeps the version in the artefact and the
version people install by from drifting apart. It runs the tests for the same
reason, and imports the built wheel in an empty environment before publishing.

`gh release create` rather than a third-party action: the CLI is already on the
runner, and this is one less thing with write access to the repository.

Also adds .gitattributes. Without it git checks out CRLF on Windows while the
mixed-line-ending hook rewrites to LF, so the two undo each other on every run
and every commit warns about it. Drop this file if the churn is preferable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Marcus778899
Marcus778899 merged commit 5c584f4 into main Aug 10, 2026
6 checks passed
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.

1 participant