Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a script to automatically set the version in Cargo.toml #111

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/scripts/cargo_version_bumper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# From https://github.com/Intreecom/scyllapy/blob/05fdab32dd7468c26533de5fdfe9627fa3e38445/scripts/version_bumper.py

import argparse
import re
from pathlib import Path


def parse_args() -> argparse.Namespace:
"""Parse command line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument(
"--target",
"-t",
dest="target",
type=Path,
default="Cargo.toml",
)
parser.add_argument("version", type=str)
return parser.parse_args()


def main() -> None:
"""Main function."""
args = parse_args()
with args.target.open("r") as f:
contents = f.read()

contents = re.sub(
r"version\s*=\s*\"(.*)\"",
f'version = "{args.version}"',
contents,
count=1,
)

with args.target.open("w") as f:
f.write(contents)


if __name__ == "__main__":
main()
5 changes: 4 additions & 1 deletion .github/workflows/release_pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
with:
python-version: '3.10'

- name: Bump Cargo version
run: |
python ./.github/scripts/cargo_version_bumper.py --target Cargo.toml "${{ github.ref_name }}"

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -69,7 +73,6 @@ jobs:
CIBW_TEST_COMMAND: python -c "import outlines_core; print(outlines_core.__version__)"
CMAKE_PREFIX_PATH: ./dist


- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release_rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Bump Cargo version
run: |
python ./.github/scripts/cargo_version_bumper.py --target Cargo.toml "${{ github.ref_name }}"

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "outlines-core"
version = "0.1.21"
version = "0.0.0"
edition = "2021"
description = "Structured Generation"
license = "Apache-2.0"
Expand Down
Loading