Skip to content

Commit dfaf58a

Browse files
Merge pull request #4 from databricks/elenagaljak-db-release2
Fixing release actions
2 parents 4f2f569 + 7c29da9 commit dfaf58a

File tree

2 files changed

+132
-22
lines changed

2 files changed

+132
-22
lines changed

.github/workflows/check.yml

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,34 @@ on:
88

99
jobs:
1010
check-rust-ffi:
11-
name: Check Rust Build (${{ matrix.os }}-${{ matrix.arch }})
12-
runs-on: ${{ matrix.os }}
11+
name: Check Rust Build (${{ matrix.target }})
12+
runs-on:
13+
group: databricks-protected-runner-group
14+
labels: ${{ matrix.os-label }}
1315
strategy:
1416
fail-fast: false
1517
matrix:
1618
include:
17-
- os: ubuntu-latest
19+
- os-label: linux-ubuntu-latest
1820
arch: amd64
1921
target: x86_64-unknown-linux-gnu
20-
- os: ubuntu-latest
22+
use-zig: false
23+
- os-label: linux-ubuntu-latest
2124
arch: arm64
2225
target: aarch64-unknown-linux-gnu
23-
- os: macos-latest
26+
use-zig: false
27+
- os-label: linux-ubuntu-latest
2428
arch: amd64
2529
target: x86_64-apple-darwin
26-
- os: macos-latest
30+
use-zig: true
31+
- os-label: linux-ubuntu-latest
2732
arch: arm64
2833
target: aarch64-apple-darwin
29-
- os: windows-latest
34+
use-zig: true
35+
- os-label: windows-server-latest
3036
arch: amd64
3137
target: x86_64-pc-windows-gnu
38+
use-zig: false
3239

3340
steps:
3441
- uses: actions/checkout@v4
@@ -44,16 +51,56 @@ jobs:
4451
sudo apt-get update
4552
sudo apt-get install -y gcc-aarch64-linux-gnu
4653
47-
- name: Check Rust Compilation
54+
- name: Install Zig and cargo-zigbuild (for macOS cross-compilation)
55+
if: matrix.use-zig == true
56+
shell: bash
57+
run: |
58+
# Determine architecture
59+
ARCH=$(uname -m)
60+
case "$ARCH" in
61+
x86_64) ZIG_ARCH="x86_64" ;;
62+
aarch64) ZIG_ARCH="aarch64" ;;
63+
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
64+
esac
65+
66+
ZIG_VERSION="0.13.0"
67+
ZIG_URL="https://ziglang.org/download/${ZIG_VERSION}/zig-linux-${ZIG_ARCH}-${ZIG_VERSION}.tar.xz"
68+
69+
echo "Downloading Zig from $ZIG_URL"
70+
wget -q "$ZIG_URL"
71+
tar -xf "zig-linux-${ZIG_ARCH}-${ZIG_VERSION}.tar.xz"
72+
73+
# Install to a local directory and add to PATH
74+
mkdir -p $HOME/.local/bin
75+
rm -rf $HOME/.local/zig
76+
mv "zig-linux-${ZIG_ARCH}-${ZIG_VERSION}" $HOME/.local/zig
77+
ln -sf $HOME/.local/zig/zig $HOME/.local/bin/zig
78+
echo "$HOME/.local/bin" >> $GITHUB_PATH
79+
80+
# Install cargo-zigbuild if not present
81+
if ! command -v cargo-zigbuild &> /dev/null; then
82+
cargo install cargo-zigbuild
83+
fi
84+
85+
- name: Check Rust Compilation (Standard)
86+
if: matrix.use-zig == false
4887
working-directory: zerobus-ffi
4988
run: |
5089
cargo check --release --target ${{ matrix.target }}
5190
env:
5291
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
5392

93+
- name: Check Rust Compilation (Zig Cross-Compile)
94+
if: matrix.use-zig == true
95+
working-directory: zerobus-ffi
96+
run: |
97+
cargo zigbuild --release --target ${{ matrix.target }}
98+
5499
check-go:
55100
name: Check Go SDK
56-
runs-on: ubuntu-latest
101+
runs-on:
102+
group: databricks-protected-runner-group
103+
labels: linux-ubuntu-latest
57104
steps:
58105
- uses: actions/checkout@v4
59106

.github/workflows/release.yml

Lines changed: 76 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,34 @@ on:
77

88
jobs:
99
build-rust:
10-
name: Build Rust (${{ matrix.os }}-${{ matrix.arch }})
11-
runs-on: ${{ matrix.os }}
10+
name: Build Rust (${{ matrix.target }})
11+
runs-on:
12+
group: databricks-protected-runner-group
13+
labels: ${{ matrix.os-label }}
1214
strategy:
1315
fail-fast: false
1416
matrix:
1517
include:
16-
- os: ubuntu-latest
18+
- os-label: linux-ubuntu-latest
1719
arch: amd64
1820
target: x86_64-unknown-linux-gnu
19-
- os: ubuntu-latest
21+
use-zig: false
22+
- os-label: linux-ubuntu-latest
2023
arch: arm64
2124
target: aarch64-unknown-linux-gnu
22-
- os: macos-latest
25+
use-zig: false
26+
- os-label: linux-ubuntu-latest
2327
arch: amd64
2428
target: x86_64-apple-darwin
25-
- os: macos-latest
29+
use-zig: true
30+
- os-label: linux-ubuntu-latest
2631
arch: arm64
2732
target: aarch64-apple-darwin
28-
- os: windows-latest
33+
use-zig: true
34+
- os-label: windows-server-latest
2935
arch: amd64
3036
target: x86_64-pc-windows-gnu
37+
use-zig: false
3138

3239
steps:
3340
- uses: actions/checkout@v4
@@ -43,34 +50,91 @@ jobs:
4350
sudo apt-get update
4451
sudo apt-get install -y gcc-aarch64-linux-gnu
4552
46-
- name: Build Rust Library
53+
- name: Install Zig and cargo-zigbuild (for macOS cross-compilation)
54+
if: matrix.use-zig == true
55+
shell: bash
56+
run: |
57+
# Determine architecture
58+
ARCH=$(uname -m)
59+
case "$ARCH" in
60+
x86_64) ZIG_ARCH="x86_64" ;;
61+
aarch64) ZIG_ARCH="aarch64" ;;
62+
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
63+
esac
64+
65+
ZIG_VERSION="0.13.0"
66+
ZIG_URL="https://ziglang.org/download/${ZIG_VERSION}/zig-linux-${ZIG_ARCH}-${ZIG_VERSION}.tar.xz"
67+
68+
echo "Downloading Zig from $ZIG_URL"
69+
wget -q "$ZIG_URL"
70+
tar -xf "zig-linux-${ZIG_ARCH}-${ZIG_VERSION}.tar.xz"
71+
72+
# Install to a local directory and add to PATH
73+
mkdir -p $HOME/.local/bin
74+
rm -rf $HOME/.local/zig
75+
mv "zig-linux-${ZIG_ARCH}-${ZIG_VERSION}" $HOME/.local/zig
76+
ln -sf $HOME/.local/zig/zig $HOME/.local/bin/zig
77+
echo "$HOME/.local/bin" >> $GITHUB_PATH
78+
79+
# Install cargo-zigbuild if not present
80+
if ! command -v cargo-zigbuild &> /dev/null; then
81+
cargo install cargo-zigbuild
82+
fi
83+
84+
- name: Build Rust Library (Standard)
85+
if: matrix.use-zig == false
4786
working-directory: zerobus-ffi
4887
run: |
4988
cargo build --release --target ${{ matrix.target }}
5089
env:
5190
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
5291

92+
- name: Build Rust Library (Zig Cross-Compile)
93+
if: matrix.use-zig == true
94+
working-directory: zerobus-ffi
95+
run: |
96+
cargo zigbuild --release --target ${{ matrix.target }}
97+
5398
- name: Prepare Artifact
5499
shell: bash
55100
run: |
56-
mkdir -p dist/${{ runner.os == 'macOS' && 'darwin' || (runner.os == 'Windows' && 'windows' || 'linux') }}_${{ matrix.arch }}
101+
# Determine OS name based on target
102+
case "${{ matrix.target }}" in
103+
*-apple-darwin)
104+
OS_NAME="darwin"
105+
;;
106+
*-pc-windows-*)
107+
OS_NAME="windows"
108+
;;
109+
*-linux-*)
110+
OS_NAME="linux"
111+
;;
112+
*)
113+
OS_NAME="unknown"
114+
;;
115+
esac
116+
117+
mkdir -p dist/${OS_NAME}_${{ matrix.arch }}
118+
57119
if [ "${{ runner.os }}" = "Windows" ]; then
58120
cp zerobus-ffi/target/${{ matrix.target }}/release/libzerobus_ffi.a dist/windows_${{ matrix.arch }}/libzerobus_ffi.a || \
59121
cp zerobus-ffi/target/${{ matrix.target }}/release/zerobus_ffi.lib dist/windows_${{ matrix.arch }}/libzerobus_ffi.a
60122
else
61-
cp zerobus-ffi/target/${{ matrix.target }}/release/libzerobus_ffi.a dist/${{ runner.os == 'macOS' && 'darwin' || 'linux' }}_${{ matrix.arch }}/libzerobus_ffi.a
123+
cp zerobus-ffi/target/${{ matrix.target }}/release/libzerobus_ffi.a dist/${OS_NAME}_${{ matrix.arch }}/libzerobus_ffi.a
62124
fi
63125
64126
- name: Upload Artifact
65127
uses: actions/upload-artifact@v4
66128
with:
67-
name: lib-${{ matrix.os }}-${{ matrix.arch }}
129+
name: lib-${{ matrix.target }}
68130
path: dist/
69131

70132
update-tag:
71133
name: Update Tag with Binaries
72134
needs: build-rust
73-
runs-on: ubuntu-latest
135+
runs-on:
136+
group: databricks-protected-runner-group
137+
labels: linux-ubuntu-latest
74138
permissions:
75139
contents: write
76140
steps:
@@ -104,4 +168,3 @@ jobs:
104168
# Force update the tag to this new commit
105169
git tag -f ${{ github.ref_name }}
106170
git push origin ${{ github.ref_name }} --force
107-

0 commit comments

Comments
 (0)