Skip to content

Take the crate's version from the tag when it is released - #30

Merged
nickyoung-github merged 1 commit into
feature/skip-defaultsfrom
feature/crate-version-of-tag
Nov 30, 2026
Merged

nickyoung-github merged 1 commit into
feature/skip-defaultsfrom
feature/crate-version-of-tag

Conversation

@nickyoung-github

Copy link
Copy Markdown
Owner

Stacked on #29: merge that first, and this then targets master.

The crate's Cargo.toml no longer holds a version to be changed by hand before each release. It holds 0.0.0, and the release workflow writes the tag's version there:

  • PyPI job: writes the version before building, so the crate within the wheel and the sdist has it. As that changes a tracked file, setuptools-scm is given the version (SETUPTOOLS_SCM_PRETEND_VERSION): it would otherwise derive 1.3.1.dev0+g….d20261130 from the changed tree. It no longer needs the history, so the checkout is shallow.
  • crates.io job: writes the version, then cargo publish --allow-dirty.
  • Check before both: was that the crate's version is the tag's; is now that the tag is vX.Y.Z, as a crate's version is semver, which v1.3.0rc1 is not. Neither is released otherwise.

The =1.3.0 in the README's dependency line and the examples' comments is still changed by hand.

Tested

In a shallow clone tagged v1.3.0, running the workflow's own commands:

  • uv build made dataclass_native-1.3.0.tar.gz and dataclass_native-1.3.0-py3-none-any.whl, each with version = "1.3.0" in the crate's Cargo.toml and 1.3.0 in the metadata.
  • cargo publish --dry-run --allow-dirty packaged and compiled dataclass_native v1.3.0.
  • The check refuses v1.3, v1.3.0rc1, v1.3.0-rc1 and 1.3.0.

The workflow itself runs only on a tag, so its first real run is the 1.3.0 release.

@nickyoung-github
nickyoung-github merged commit 0709cd0 into feature/skip-defaults Nov 30, 2026
6 checks passed
@nickyoung-github
nickyoung-github deleted the feature/crate-version-of-tag branch November 30, 2026 11:06
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