-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added deployment workflow for rust API
- Loading branch information
1 parent
7ec4007
commit 8696cff
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Updates the version in Cargo.toml to match the version in the main CMakeLists.txt""" | ||
|
||
import os | ||
import re | ||
from pathlib import Path | ||
|
||
KUZU_RS_ROOT = Path(__file__).parent | ||
KUZU_ROOT = KUZU_RS_ROOT.parent.parent | ||
|
||
|
||
def get_kuzu_version(): | ||
cmake_file = KUZU_ROOT / "CMakeLists.txt" | ||
with open(cmake_file) as f: | ||
for line in f: | ||
if line.startswith("project(Kuzu VERSION"): | ||
return line.split(" ")[2].strip() | ||
|
||
|
||
if __name__ == "__main__": | ||
version = get_kuzu_version() | ||
version_changed = False | ||
with open(KUZU_RS_ROOT / "Cargo.toml", encoding="utf-8") as file: | ||
data = file.readlines() | ||
section = None | ||
for index, line in enumerate(data): | ||
if line.startswith("["): | ||
section = line.strip().strip("[]") | ||
if line.startswith("version = ") and section == "package": | ||
toml_version = re.match('version = "(.*)"', line).group(1) | ||
if toml_version != version: | ||
version_changed = True | ||
print( | ||
f"Updating version in Cargo.toml from {toml_version} to {version}" | ||
) | ||
data[index] = re.sub( | ||
'version = ".*"', f'version = "{version}"', line | ||
) | ||
break | ||
|
||
if version_changed: | ||
with open("Cargo.toml", "w", encoding="utf-8") as file: | ||
file.writelines(data) |