Skip to content

Commit 6ae98d9

Browse files
committed
change versioning mechanism
1 parent e842bca commit 6ae98d9

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ jobs:
3030
with:
3131
submodules: recursive
3232

33-
- name: Set version from tag
33+
- name: Verify version matches tag
3434
if: startsWith(github.ref, 'refs/tags/v')
3535
shell: bash
3636
run: |
3737
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
38-
echo "Updating version in Cargo.toml to $TAG_VERSION"
39-
if [[ "${{ runner.os }}" == "macOS" ]]; then
40-
sed -i '' 's/^version = ".*"/version = "'$TAG_VERSION'"/' native_fisher_py/Cargo.toml
41-
else
42-
sed -i 's/^version = ".*"/version = "'$TAG_VERSION'"/' native_fisher_py/Cargo.toml
38+
# Extract version from Cargo.toml
39+
CARGO_VERSION=$(grep -m1 '^version =' native_fisher_py/Cargo.toml | cut -d '"' -f 2)
40+
echo "Tag version: $TAG_VERSION"
41+
echo "Cargo version: $CARGO_VERSION"
42+
if [[ "$TAG_VERSION" != "$CARGO_VERSION" ]]; then
43+
echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
44+
exit 1
4345
fi
4446
4547
- name: Install NativeAOT Dependencies (Linux)

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,22 @@ maturin develop
9090
This project is powered by the [**Thermo Fisher Scientific RawFileReader**](https://github.com/thermofisherlsms/RawFileReader) (copyright © 2016-2026 Thermo Fisher Scientific, Inc.). All rights reserved.
9191

9292
The `native-fisher-py` package includes the official RawFileReader libraries, which remain the property of Thermo Fisher Scientific. By using this software, you agree to the terms specified in their [license](https://github.com/thermofisherlsms/RawFileReader/blob/main/License.doc).
93+
94+
## Releasing a New Version
95+
Releases are fully automated via GitHub Actions (`release.yml`), but the workflow **requires** that the git tag strictly matches the version in `native_fisher_py/Cargo.toml`.
96+
97+
To trigger a new release and publish to PyPI:
98+
99+
1. Update the version in `native_fisher_py/Cargo.toml`.
100+
2. Commit the version bump.
101+
3. Create and push a matching git tag:
102+
103+
```bash
104+
git tag vX.Y.Z
105+
git push origin vX.Y.Z
106+
```
107+
108+
The GitHub Action will automatically:
109+
1. Verify that the git tag version matches the `Cargo.toml` version (failing otherwise).
110+
2. Build the native wheels across all platforms (macOS, Linux, Windows).
111+
3. Publish the final artifacts to PyPI.

native_fisher_py/python/native_fisher_py/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
import os
2020
import sys
2121
import platform
22+
from importlib.metadata import version, PackageNotFoundError
23+
24+
try:
25+
__version__ = version("native-fisher-py")
26+
except PackageNotFoundError:
27+
# package is not installed
28+
__version__ = "unknown"
2229

2330
# Find and initialize the native library
2431

0 commit comments

Comments
 (0)