Skip to content

Commit 4f2f569

Browse files
Merge pull request #3 from databricks/elenagaljak-db-release
Add automatic releases
2 parents 1e5a026 + 6ce26eb commit 4f2f569

File tree

9 files changed

+273
-63
lines changed

9 files changed

+273
-63
lines changed

.github/workflows/check.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI Check
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
check-rust-ffi:
11+
name: Check Rust Build (${{ matrix.os }}-${{ matrix.arch }})
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- os: ubuntu-latest
18+
arch: amd64
19+
target: x86_64-unknown-linux-gnu
20+
- os: ubuntu-latest
21+
arch: arm64
22+
target: aarch64-unknown-linux-gnu
23+
- os: macos-latest
24+
arch: amd64
25+
target: x86_64-apple-darwin
26+
- os: macos-latest
27+
arch: arm64
28+
target: aarch64-apple-darwin
29+
- os: windows-latest
30+
arch: amd64
31+
target: x86_64-pc-windows-gnu
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Install Rust
37+
uses: dtolnay/rust-toolchain@stable
38+
with:
39+
targets: ${{ matrix.target }}
40+
41+
- name: Install Cross-Compilation Tools (Linux ARM64)
42+
if: matrix.target == 'aarch64-unknown-linux-gnu'
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y gcc-aarch64-linux-gnu
46+
47+
- name: Check Rust Compilation
48+
working-directory: zerobus-ffi
49+
run: |
50+
cargo check --release --target ${{ matrix.target }}
51+
env:
52+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
53+
54+
check-go:
55+
name: Check Go SDK
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Go
61+
uses: actions/setup-go@v5
62+
with:
63+
go-version: '1.21'
64+
cache: true
65+
66+
- name: Go Vet
67+
run: go vet ./...
68+
69+
- name: Go Format Check
70+
run: |
71+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
72+
echo "The following files are not formatted correctly:"
73+
gofmt -s -l .
74+
exit 1
75+
fi
76+

.github/workflows/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: go generate -v
2525

2626
- name: Verify library built
27-
run: test -f libzerobus_ffi.a
27+
run: test -f lib/linux_amd64/libzerobus_ffi.a
2828

2929
- name: Test go build works (user step 2)
3030
run: go build -v
@@ -53,7 +53,7 @@ jobs:
5353
shell: bash
5454

5555
- name: Verify library built
56-
run: test -f libzerobus_ffi.a
56+
run: test -f lib/windows_amd64/libzerobus_ffi.a
5757
shell: bash
5858

5959
- name: Test go build works (user step 2)

.github/workflows/release.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Seamless Release (CI-Augmented Tag)
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build-rust:
10+
name: Build Rust (${{ matrix.os }}-${{ matrix.arch }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- os: ubuntu-latest
17+
arch: amd64
18+
target: x86_64-unknown-linux-gnu
19+
- os: ubuntu-latest
20+
arch: arm64
21+
target: aarch64-unknown-linux-gnu
22+
- os: macos-latest
23+
arch: amd64
24+
target: x86_64-apple-darwin
25+
- os: macos-latest
26+
arch: arm64
27+
target: aarch64-apple-darwin
28+
- os: windows-latest
29+
arch: amd64
30+
target: x86_64-pc-windows-gnu
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Install Rust
36+
uses: dtolnay/rust-toolchain@stable
37+
with:
38+
targets: ${{ matrix.target }}
39+
40+
- name: Install Cross-Compilation Tools (Linux ARM64)
41+
if: matrix.target == 'aarch64-unknown-linux-gnu'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y gcc-aarch64-linux-gnu
45+
46+
- name: Build Rust Library
47+
working-directory: zerobus-ffi
48+
run: |
49+
cargo build --release --target ${{ matrix.target }}
50+
env:
51+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
52+
53+
- name: Prepare Artifact
54+
shell: bash
55+
run: |
56+
mkdir -p dist/${{ runner.os == 'macOS' && 'darwin' || (runner.os == 'Windows' && 'windows' || 'linux') }}_${{ matrix.arch }}
57+
if [ "${{ runner.os }}" = "Windows" ]; then
58+
cp zerobus-ffi/target/${{ matrix.target }}/release/libzerobus_ffi.a dist/windows_${{ matrix.arch }}/libzerobus_ffi.a || \
59+
cp zerobus-ffi/target/${{ matrix.target }}/release/zerobus_ffi.lib dist/windows_${{ matrix.arch }}/libzerobus_ffi.a
60+
else
61+
cp zerobus-ffi/target/${{ matrix.target }}/release/libzerobus_ffi.a dist/${{ runner.os == 'macOS' && 'darwin' || 'linux' }}_${{ matrix.arch }}/libzerobus_ffi.a
62+
fi
63+
64+
- name: Upload Artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: lib-${{ matrix.os }}-${{ matrix.arch }}
68+
path: dist/
69+
70+
update-tag:
71+
name: Update Tag with Binaries
72+
needs: build-rust
73+
runs-on: ubuntu-latest
74+
permissions:
75+
contents: write
76+
steps:
77+
- uses: actions/checkout@v4
78+
with:
79+
fetch-depth: 0
80+
81+
- name: Download all artifacts
82+
uses: actions/download-artifact@v4
83+
with:
84+
path: lib-artifacts
85+
merge-multiple: true
86+
87+
- name: Prepare lib directory
88+
run: |
89+
mkdir -p lib
90+
cp -r lib-artifacts/* lib/
91+
rm -rf lib-artifacts
92+
93+
- name: Commit and Force-Push Tag
94+
run: |
95+
git config --global user.name "github-actions[bot]"
96+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
97+
98+
# Add the lib directory even though it's gitignored
99+
git add -f lib/
100+
101+
# Create an augmented commit
102+
git commit -m "Release ${{ github.ref_name }} with pre-built binaries"
103+
104+
# Force update the tag to this new commit
105+
git tag -f ${{ github.ref_name }}
106+
git push origin ${{ github.ref_name }} --force
107+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Build artifacts - DO NOT COMMIT
22
zerobus-ffi/target/
3+
lib/
34
libzerobus_ffi.a
45
*.dylib
56
*.so

Makefile

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,37 @@ build: build-rust build-go
2525

2626
build-rust:
2727
@echo "Building Rust FFI layer..."
28-
@# On Windows with MinGW, we need to build for the GNU target
29-
@if [ "$$OS" = "Windows_NT" ]; then \
28+
@# Detect OS and Arch for the target directory
29+
@OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); \
30+
ARCH=$$(uname -m); \
31+
case "$$OS" in \
32+
darwin*) GOOS="darwin" ;; \
33+
linux*) GOOS="linux" ;; \
34+
msys*|mingw*|cygwin*) GOOS="windows" ;; \
35+
*) GOOS="$$OS" ;; \
36+
esac; \
37+
case "$$ARCH" in \
38+
x86_64) GOARCH="amd64" ;; \
39+
aarch64|arm64) GOARCH="arm64" ;; \
40+
*) GOARCH="$$ARCH" ;; \
41+
esac; \
42+
LIB_DIR="lib/$${GOOS}_$${GOARCH}"; \
43+
echo "Target directory: $$LIB_DIR"; \
44+
mkdir -p $$LIB_DIR; \
45+
if [ "$$OS" = "Windows_NT" ] || [[ "$$OS" == *"mingw"* ]] || [[ "$$OS" == *"msys"* ]]; then \
3046
echo "Detected Windows - building for x86_64-pc-windows-gnu target"; \
3147
cd zerobus-ffi && cargo build --release --target x86_64-pc-windows-gnu; \
48+
cd ..; \
49+
if [ -f zerobus-ffi/target/x86_64-pc-windows-gnu/release/libzerobus_ffi.a ]; then \
50+
cp zerobus-ffi/target/x86_64-pc-windows-gnu/release/libzerobus_ffi.a $$LIB_DIR/; \
51+
elif [ -f zerobus-ffi/target/release/zerobus_ffi.lib ]; then \
52+
cp zerobus-ffi/target/release/zerobus_ffi.lib $$LIB_DIR/libzerobus_ffi.a; \
53+
fi; \
3254
else \
3355
cd zerobus-ffi && cargo build --release; \
34-
fi
35-
@echo "Copying static library and header..."
36-
@if [ -f zerobus-ffi/target/release/libzerobus_ffi.a ]; then \
37-
cp zerobus-ffi/target/release/libzerobus_ffi.a .; \
38-
elif [ -f zerobus-ffi/target/x86_64-pc-windows-gnu/release/libzerobus_ffi.a ]; then \
39-
cp zerobus-ffi/target/x86_64-pc-windows-gnu/release/libzerobus_ffi.a .; \
40-
elif [ -f zerobus-ffi/target/release/zerobus_ffi.lib ]; then \
41-
cp zerobus-ffi/target/release/zerobus_ffi.lib libzerobus_ffi.a; \
42-
else \
43-
echo "Error: Could not find Rust library"; \
44-
exit 1; \
45-
fi
56+
cd ..; \
57+
cp zerobus-ffi/target/release/libzerobus_ffi.a $$LIB_DIR/; \
58+
fi; \
4659
cp zerobus-ffi/zerobus.h .
4760
@echo "✓ Rust FFI layer built successfully"
4861

@@ -54,6 +67,7 @@ build-go: build-rust
5467
clean:
5568
@echo "Cleaning build artifacts..."
5669
cd zerobus-ffi && cargo clean
70+
rm -rf lib/
5771
rm -f libzerobus_ffi.a
5872
rm -rf releases
5973
@echo "✓ Clean complete"

README.md

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -85,42 +85,28 @@ Choose your installation path:
8585

8686
| Path | When to Use |
8787
|------|-------------|
88-
| **[For SDK Users](#for-sdk-users-install-from-pkggodev)** | You want to use the SDK in your project (via `go get`) |
89-
| **[For Contributors](#for-contributors-build-from-source)** | You want to contribute or build from source (via `git clone`) |
88+
| **[Standard Installation](#installation)** | You want to use the SDK in your project (via `go get`) |
89+
| **[Development Setup](#development-setup)** | You want to contribute or build from source (via `git clone`) |
9090

91-
### For SDK Users (Install from pkg.go.dev)
91+
### Installation
92+
93+
The Zerobus Go SDK is a CGO-based wrapper around a high-performance Rust core. For the best experience, use a tagged release which includes pre-built binaries.
9294

9395
**Prerequisites:**
9496

95-
*System Requirements:*
9697
- **Go 1.21+**
9798
- **CGO enabled** (enabled by default)
98-
- **Rust 1.75+** ([install from rustup.rs](https://rustup.rs))
99-
- **C compiler** (gcc on Linux, clang on macOS, MinGW-w64 on Windows)
100-
101-
*Supported Platforms:*
102-
- **Linux** (x86_64, ARM64)
103-
- **macOS** (Intel, Apple Silicon)
104-
- **Windows** (x86_64 with MinGW-w64)
105-
106-
*Databricks Requirements:*
107-
- **Databricks workspace** with Zerobus access enabled (AWS, Azure, or GCP)
108-
- **OAuth 2.0 client credentials** (client ID and secret)
109-
- **Unity Catalog endpoint** access
99+
- **C compiler** (gcc or clang)
110100

111-
**Installation:**
101+
**Installation Steps:**
112102

113103
```bash
114-
# 1. Add the SDK to your project
115-
go get github.com/databricks/zerobus-sdk-go
116-
117-
# 2. Build the Rust FFI library (one-time setup, takes 2-5 minutes)
118-
go generate github.com/databricks/zerobus-sdk-go
119-
120-
# 3. Build your project normally
121-
go build
104+
# Add the SDK to your project (use a tagged version for pre-built binaries)
105+
go get github.com/databricks/zerobus-sdk-go@latest
122106
```
123107

108+
> **Note:** Tagged releases (e.g., `v1.0.0`) come with pre-built Rust libraries for Linux, macOS, and Windows. If you use `@main` or a commit hash, you will need to have Rust installed and run `go generate` to build the library yourself.
109+
124110
**In your code:**
125111

126112
```go
@@ -141,7 +127,7 @@ func main() {
141127

142128
> **Note:** After the initial `go generate` step, regular `go build` works normally. The Rust library is statically linked into your binary.
143129
144-
### For Contributors (Build from Source)
130+
### Development Setup
145131

146132
**Prerequisites:**
147133
- Same as above (Go, CGO, Rust, C compiler, Databricks workspace)

build.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func init() {
2121
return
2222
}
2323
sdkDir := filepath.Dir(filename)
24-
libPath := filepath.Join(sdkDir, "libzerobus_ffi.a")
24+
libPath := filepath.Join(sdkDir, "lib", fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH), "libzerobus_ffi.a")
2525

2626
if _, err := os.Stat(libPath); os.IsNotExist(err) {
2727
fmt.Fprintf(os.Stderr, "\n"+
@@ -56,7 +56,7 @@ func ensureRustLibrary() error {
5656
return fmt.Errorf("failed to determine source directory")
5757
}
5858
sdkDir := filepath.Dir(filename)
59-
libPath := filepath.Join(sdkDir, "libzerobus_ffi.a")
59+
libPath := filepath.Join(sdkDir, "lib", fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH), "libzerobus_ffi.a")
6060

6161
// Check if library already exists
6262
if _, err := os.Stat(libPath); err == nil {
@@ -128,7 +128,11 @@ func buildRustLibrary(sdkDir string) error {
128128
}
129129

130130
// Copy library to SDK directory (handle multiple possible locations)
131-
dstLib := filepath.Join(sdkDir, "libzerobus_ffi.a")
131+
dstDir := filepath.Join(sdkDir, "lib", fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH))
132+
if err := os.MkdirAll(dstDir, 0755); err != nil {
133+
return fmt.Errorf("failed to create library directory: %w", err)
134+
}
135+
dstLib := filepath.Join(dstDir, "libzerobus_ffi.a")
132136

133137
// Try different possible locations
134138
possiblePaths := []string{

0 commit comments

Comments
 (0)