Skip to content

Commit 2be8e44

Browse files
cleaning up and adding cross compilation release
1 parent 2c50e26 commit 2be8e44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+172
-2196
lines changed

.dockerignore

-5
This file was deleted.

.github/workflows/build_all.yml

-80
This file was deleted.
+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Release to Github
2+
3+
on:
4+
workflow_dispatch: # Allows manual triggering of the workflow
5+
inputs:
6+
type:
7+
description: 'Type of release (major/minor/patch)'
8+
required: true
9+
default: 'minor'
10+
dry_run:
11+
description: 'Dry run (true/false)' # Allows a test run without making actual changes
12+
required: true
13+
default: true
14+
# skip_tests:
15+
# description: 'Skip tests (true/false)' # Allows skipping tests if needed
16+
# required: true
17+
# default: false
18+
19+
env:
20+
CARGO_TERM_COLOR: always # Ensures cargo outputs colored logs
21+
22+
jobs:
23+
build:
24+
strategy:
25+
matrix:
26+
platform:
27+
- os: ubuntu-latest
28+
linux-override: false
29+
- os: macos-13
30+
linux-override: false
31+
- os: macos-14
32+
linux-override: false
33+
- os: windows-latest
34+
linux-override: false
35+
- os: ubuntu-latest # Extra Ubuntu build for ARM support
36+
linux-override: true
37+
runs-on: ${{ matrix.platform.os }}
38+
steps:
39+
- name: Checkout source code
40+
uses: actions/checkout@v3 # Fetches the repository
41+
42+
- name: Ensure Cargo Directories Exist for Cache Restore
43+
run: |
44+
mkdir -p ~/.cargo/registry ~/.cargo/index target
45+
shell: bash # Prevents cache failures due to missing directories
46+
47+
- name: Cache Cargo Registry, Index, Build
48+
uses: actions/cache@v3
49+
with:
50+
path: |
51+
~/.cargo/registry
52+
~/.cargo/index
53+
target
54+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }}
55+
restore-keys: |
56+
cargo-build-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/Cargo.toml') }}
57+
cargo-build-${{ runner.os }}-${{ runner.arch }}-
58+
59+
- name: Set up Rust
60+
uses: actions-rs/toolchain@v1
61+
with:
62+
toolchain: stable # Installs stable Rust toolchain
63+
64+
- name: Build project
65+
run: cargo build --verbose # Builds the Rust project
66+
67+
prepare-release:
68+
needs: [build] # Runs only after build job completes
69+
runs-on: ubuntu-latest # Ensures consistent release process
70+
outputs:
71+
rr_cargo_version: ${{ steps.get-version.outputs.VERSION }}
72+
workflow_git_tag: ${{ steps.get-version.outputs.WORKFLOW_GIT_TAG }}
73+
steps:
74+
- name: Checkout repository with full history
75+
uses: actions/checkout@v3
76+
with:
77+
fetch-depth: 0 # Required for versioning
78+
token: ${{ secrets.RELEASE_TOKEN }} # Uses a token with release permissions
79+
80+
- name: Install Rust Target for Linux Arm if needed
81+
shell: bash
82+
run: |
83+
if [ "${{ matrix.platform.linux-override }}" = "true" ]; then
84+
rustup target add aarch64-unknown-linux-gnu
85+
fi
86+
87+
- name: Cache Cargo dependencies
88+
uses: actions/cache@v3
89+
with:
90+
path: |
91+
~/.cargo/registry
92+
~/.cargo/index
93+
target
94+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }}
95+
96+
- name: Install cargo-release
97+
run: |
98+
if ! command -v cargo-release &> /dev/null; then
99+
cargo install cargo-release
100+
fi
101+
102+
- name: Configure Git
103+
run: |
104+
git config --global user.name "GitHub Action"
105+
git config --global user.email "[email protected]"
106+
107+
- name: Update Cargo.toml version and push to GitHub
108+
run: |
109+
if [ "${{ github.event.inputs.dry_run }}" = "false" ]; then
110+
cargo release --verbose --execute --no-confirm ${{ github.event.inputs.type }} --no-publish --no-verify
111+
else
112+
cargo release --verbose ${{ github.event.inputs.type }} --no-publish --no-verify
113+
fi
114+
115+
- name: Extract Version from Cargo.toml
116+
id: get-version
117+
run: |
118+
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
119+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
120+
echo "WORKFLOW_GIT_TAG=v$VERSION" >> "$GITHUB_OUTPUT"
121+
122+
release:
123+
needs: [prepare-release]
124+
if: ${{ github.event.inputs.dry_run == 'false' }} # Only run if not a dry run
125+
strategy:
126+
matrix:
127+
platform:
128+
- os: ubuntu-latest
129+
linux-override: false
130+
- os: macos-13
131+
linux-override: false
132+
- os: macos-14
133+
linux-override: false
134+
- os: windows-latest
135+
linux-override: false
136+
- os: ubuntu-latest
137+
linux-override: true
138+
runs-on: ${{ matrix.platform.os }}
139+
steps:
140+
- name: Checkout repository
141+
uses: actions/checkout@v3
142+
143+
- name: Build release binary
144+
run: |
145+
if [[ "${{ matrix.platform.linux-override }}" == "true" ]]; then
146+
rustup target add aarch64-unknown-linux-gnu
147+
cargo build -p c-wrapper --release --target aarch64-unknown-linux-gnu --verbose
148+
else
149+
cargo build -p c-wrapper --release --verbose
150+
fi
151+
152+
- name: Archive binary
153+
uses: ksm2/archive-action@v1
154+
with:
155+
name: "surrealml-${{ needs.prepare-release.outputs.rr_cargo_version }}"
156+
format: "tar.gz"
157+
include: "{libc_wrapper.so, libc_wrapper.dll,libc_wrapper.dylib,README.md}"
158+
159+
- name: Create GitHub Release
160+
uses: ncipollo/release-action@v1
161+
with:
162+
artifacts: "surrealml-${{ needs.prepare-release.outputs.rr_cargo_version }}.tar.gz"
163+
allowUpdates: true
164+
generateReleaseNotes: true
165+
token: ${{ secrets.RELEASE_TOKEN }}
166+
tag: ${{ needs.prepare-release.outputs.workflow_git_tag }}

Cargo.toml

+6-33
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,7 @@
11

2-
[package]
3-
name = "surrealml"
4-
version = "0.1.0"
5-
edition = "2021"
6-
7-
description = "A machine learning python library written in Rust for SurrealDB"
8-
license-file = "LICENSE"
9-
10-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
11-
12-
[dependencies]
13-
pyo3 = "0.20.0"
14-
uuid = { version = "1.4.1", features = ["v4"] }
15-
once_cell = "1.18.0"
16-
ndarray = "0.15.6"
17-
hyper = { version = "0.14.27", features = ["full"] }
18-
tokio = { version = "1.34.0", features = ["full"] }
19-
base64 = "0.13"
20-
surrealml-core = { path = "./modules/core" }
21-
22-
[dev-dependencies]
23-
axum = "0.6.20"
24-
serde = "1.0.183"
25-
serde_json = "1.0.105"
26-
actix-web = "4.3.1"
27-
futures-util = "0.3.29"
28-
29-
[lib]
30-
name = "surrealml"
31-
path = "src/lib.rs"
32-
33-
[build-dependencies]
34-
ort = { version = "1.16.2", default-features = true }
2+
[workspace]
3+
members = [
4+
"modules/c-wrapper",
5+
"modules/core",
6+
"modules/pipelines/data_access"
7+
]

Dockerfile

-35
This file was deleted.

build.rs

-37
This file was deleted.

docker-compose.yml

-7
This file was deleted.

0 commit comments

Comments
 (0)