Skip to content

Commit 18dfb8b

Browse files
committed
Use a script to automatically set the version in Cargo.toml
1 parent 24c1274 commit 18dfb8b

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# From https://github.com/Intreecom/scyllapy/blob/05fdab32dd7468c26533de5fdfe9627fa3e38445/scripts/version_bumper.py
2+
3+
import argparse
4+
import re
5+
from pathlib import Path
6+
7+
8+
def parse_args() -> argparse.Namespace:
9+
"""Parse command line arguments."""
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument(
12+
"--target",
13+
"-t",
14+
dest="target",
15+
type=Path,
16+
default="Cargo.toml",
17+
)
18+
parser.add_argument("version", type=str)
19+
return parser.parse_args()
20+
21+
22+
def main() -> None:
23+
"""Main function."""
24+
args = parse_args()
25+
with args.target.open("r") as f:
26+
contents = f.read()
27+
28+
contents = re.sub(
29+
r"version\s*=\s*\"(.*)\"",
30+
f'version = "{args.version}"',
31+
contents,
32+
count=1,
33+
)
34+
35+
with args.target.open("w") as f:
36+
f.write(contents)
37+
38+
39+
if __name__ == "__main__":
40+
main()

.github/workflows/release_pypi.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ jobs:
2121
with:
2222
python-version: '3.10'
2323

24+
- name: Bump Cargo version
25+
run: |
26+
python ./.github/scripts/cargo_version_bumper.py --target Cargo.toml "${{ github.ref_name }}"
27+
2428
- name: Set up QEMU
2529
if: runner.os == 'Linux'
2630
uses: docker/setup-qemu-action@v3
@@ -69,7 +73,6 @@ jobs:
6973
CIBW_TEST_COMMAND: python -c "import outlines_core; print(outlines_core.__version__)"
7074
CMAKE_PREFIX_PATH: ./dist
7175

72-
7376
- uses: actions/upload-artifact@v3
7477
with:
7578
path: ./wheelhouse/*.whl

.github/workflows/release_rust.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v2
1515

16+
- name: Bump Cargo version
17+
run: |
18+
python ./.github/scripts/cargo_version_bumper.py --target Cargo.toml "${{ github.ref_name }}"
19+
1620
- name: Install Rust
1721
uses: actions-rs/toolchain@v1
1822
with:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "outlines-core"
3-
version = "0.1.21"
3+
version = "0.0.0"
44
edition = "2021"
55
description = "Structured Generation"
66
license = "Apache-2.0"

0 commit comments

Comments
 (0)