A version that works on windows
This commit is contained in:
parent
9873241eab
commit
ee546cd788
10
.github/workflows/build_wheels.yml
vendored
10
.github/workflows/build_wheels.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
- name: Set cargo version from tag
|
- name: Set cargo version from tag
|
||||||
run: .github/workflows/update_version.sh
|
run: python .github/workflows/update_version.py
|
||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
@ -70,7 +70,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
- name: Set cargo version from tag
|
- name: Set cargo version from tag
|
||||||
run: .github/workflows/update_version.sh
|
run: python .github/workflows/update_version.py
|
||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
@ -101,7 +101,7 @@ jobs:
|
|||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
architecture: ${{ matrix.platform.target }}
|
architecture: ${{ matrix.platform.target }}
|
||||||
- name: Set cargo version from tag
|
- name: Set cargo version from tag
|
||||||
run: .github/workflows/update_version.sh
|
run: python .github/workflows/update_version.py
|
||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
@ -130,7 +130,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
- name: Set cargo version from tag
|
- name: Set cargo version from tag
|
||||||
run: .github/workflows/update_version.sh
|
run: python .github/workflows/update_version.py
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
@ -148,7 +148,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Set cargo version from tag
|
- name: Set cargo version from tag
|
||||||
run: .github/workflows/update_version.sh
|
run: python .github/workflows/update_version.py
|
||||||
- name: Build sdist
|
- name: Build sdist
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
|
30
.github/workflows/update_version.py
vendored
Executable file
30
.github/workflows/update_version.py
vendored
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
CARGO_TOML_PATH = Path("Cargo.toml")
|
||||||
|
|
||||||
|
# Get the latest Git tag and strip the leading 'v' if present
|
||||||
|
def get_git_version():
|
||||||
|
try:
|
||||||
|
version = subprocess.check_output(["git", "describe", "--tags", "--always"], text=True).strip()
|
||||||
|
version = re.sub(r"^v", "", version) # Remove leading 'v'
|
||||||
|
return version
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
raise RuntimeError("Failed to get Git tag. Make sure you have at least one tag in the repository.")
|
||||||
|
|
||||||
|
# Update version in Cargo.toml
|
||||||
|
def update_cargo_version(new_version):
|
||||||
|
cargo_toml = CARGO_TOML_PATH.read_text()
|
||||||
|
|
||||||
|
# Replace version in [package] section
|
||||||
|
updated_toml = re.sub(r'^version = "[^"]+"', f'version = "{new_version}"', cargo_toml, flags=re.MULTILINE)
|
||||||
|
|
||||||
|
CARGO_TOML_PATH.write_text(updated_toml)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
version = get_git_version()
|
||||||
|
print(f"Parsed version: {version}")
|
||||||
|
|
||||||
|
update_cargo_version(version)
|
||||||
|
print(f"Updated Cargo.toml with version: {version}")
|
2
.github/workflows/update_version.sh
vendored
2
.github/workflows/update_version.sh
vendored
@ -1,2 +0,0 @@
|
|||||||
VERSION=$(git describe --tags --always | awk '{gsub(/^v/, ""); print}')
|
|
||||||
perl -pi -e "s/^version = \"[^\"]+\"/version = \"$VERSION\"/" Cargo.toml
|
|
Loading…
x
Reference in New Issue
Block a user