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

Added deployment workflow for rust API #1800

Merged
merged 1 commit into from
Jul 11, 2023
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
27 changes: 27 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,33 @@ jobs:
with:
password: ${{ secrets.PYPI_TOKEN }}

deploy-rust:
runs-on: kuzu-self-hosted-testing
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v3

- name: Update Cargo.toml version
run: python3 update_version.py
working-directory: tools/rust_api

- name: Deploy crate to Crates.io
run: cargo publish --allow-dirty
if: ${{ github.event.inputs.isDeploy == 'true' }}
working-directory: tools/rust_api

- name: Test publishing crate
run: cargo publish --dry-run --allow-dirty
if: ${{ github.event.inputs.isDeploy != 'true' }}
working-directory: tools/rust_api

- name: Upload crate
uses: actions/upload-artifact@v3
with:
name: kuzu-deploy-crate
path: tools/rust_api/target/package/*.crate

build-precompiled-bin-mac:
uses: ./.github/workflows/mac-precompiled-bin-workflow.yml
secrets: inherit
Expand Down
2 changes: 1 addition & 1 deletion tools/rust_api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kuzu"
version = "0.0.4"
version = "0.0.5"
description = "An in-process property graph database management system built for query speed and scalability"
# Note: 1.63 required for building tests
rust-version = "1.51"
Expand Down
42 changes: 42 additions & 0 deletions tools/rust_api/update_version.py
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)
Loading