From 1bed5e2e6959b0a8402d989dfeb784919d4f9e90 Mon Sep 17 00:00:00 2001 From: nickyoung-github Date: Mon, 30 Nov 2026 10:30:02 +0000 Subject: [PATCH] Take the crate's version from the tag when it is released --- .github/workflows/release.yml | 17 +++++++++-------- DESIGN.md | 6 +++--- src/dataclass_native/rust/Cargo.toml | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c93af1c..d11e246 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,11 +6,11 @@ on: jobs: version: - # The crate is of the version of the tag, which the package is of: else neither is released + # The package and the crate are both of the tag's version: which is to be one a crate may have, else + # neither is released runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - run: grep -qx "version = \"${GITHUB_REF_NAME#v}\"" src/dataclass_native/rust/Cargo.toml + - run: '[[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]' publish: needs: version @@ -20,11 +20,11 @@ jobs: id-token: write steps: - uses: actions/checkout@v4 - with: - # setuptools-scm derives the version from the tags - fetch-depth: 0 - uses: astral-sh/setup-uv@v6 - - run: uv build + # The crate within the package is of the tag's version. As that changes a file, the version is given + # to setuptools-scm, which would otherwise derive one of a changed tree + - run: sed -i "s/^version = .*/version = \"${GITHUB_REF_NAME#v}\"/" src/dataclass_native/rust/Cargo.toml + - run: SETUPTOOLS_SCM_PRETEND_VERSION="${GITHUB_REF_NAME#v}" uv build - uses: pypa/gh-action-pypi-publish@release/v1 crate: @@ -33,6 +33,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: cargo publish --manifest-path src/dataclass_native/rust/Cargo.toml + - run: sed -i "s/^version = .*/version = \"${GITHUB_REF_NAME#v}\"/" src/dataclass_native/rust/Cargo.toml + - run: cargo publish --allow-dirty --manifest-path src/dataclass_native/rust/Cargo.toml env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/DESIGN.md b/DESIGN.md index 73eb463..c3f1f47 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -215,9 +215,9 @@ modules may be anywhere in a crate. - The generated code uses the crate `dataclass_native`, which depends on nothing but for its features: pyo3 for `python`, serde for `json` and arrow-rs for `arrow`. It is released to crates.io with the Python package, - at its version, as what is generated and the crate are of each other: the release is refused if the crate's - version is not the tag's. It is also in the Python package, where `dataclass-native rust-dir` prints, to - depend on by path. + at its version, as what is generated and the crate are of each other: which is the tag's, written to its + `Cargo.toml` when it is released. It is also in the Python package, where `dataclass-native rust-dir` + prints, to depend on by path. - Names are Python's: a struct's, its fields', an enum's and its members', so `Currency::USD`. One which is a keyword of Rust has `_` after it. - A struct has the defaults of its class, as its `Default`: a field which has none has that of its type, as in C++. diff --git a/src/dataclass_native/rust/Cargo.toml b/src/dataclass_native/rust/Cargo.toml index 75470d8..cb9b5e0 100644 --- a/src/dataclass_native/rust/Cargo.toml +++ b/src/dataclass_native/rust/Cargo.toml @@ -2,8 +2,8 @@ # `dataclass-native rust-dir` prints: it depends on nothing itself, but for its features arrow, json and python. [package] name = "dataclass_native" -# That of the Python package it is released with, which is the tag's: the release is refused if they differ -version = "1.3.0" +# That of the Python package it is released with, which is the tag's: written here when it is released +version = "0.0.0" edition = "2021" description = "Types used by the Rust generated by dataclass-native" license = "MIT"