-
Notifications
You must be signed in to change notification settings - Fork 5
157 lines (136 loc) · 4.42 KB
/
build-native.yml
File metadata and controls
157 lines (136 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Build Native Bindings
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build-native:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS ARM (M1/M2) - macos-latest is now ARM
- os: macos-latest
platform: darwin-arm64
zig-target: aarch64-macos
# macOS x64 - use macos-13 which is the last x64 runner
- os: macos-13
platform: darwin-x64
zig-target: x86_64-macos
# Linux x64 - ubuntu-latest is x64
- os: ubuntu-latest
platform: linux-x64
zig-target: x86_64-linux
# Windows x64
- os: windows-latest
platform: win32-x64
zig-target: x86_64-windows
# NOTE: linux-arm64 requires ARM runners or cross-compilation
# Disabled until ARM runners available
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.1
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.platform }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Zig dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/zig
zig-cache/
key: ${{ runner.os }}-zig-${{ matrix.platform }}-${{ hashFiles('build.zig', 'build.zig.zon') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build Rust dependencies
run: cargo build --release
env:
CARGO_TARGET_DIR: target
- name: Build libwally-core dependency
shell: bash
run: |
cd packages/voltaire-zig/lib/libwally-core
zig build install
- name: Build native library
run: zig build build-native-${{ matrix.platform }}
- name: Verify build output
shell: bash
run: |
if [ "${{ matrix.platform }}" == "win32-x64" ]; then
ls -lh zig-out/native/${{ matrix.platform }}/*.dll || echo "No DLL found"
elif [ "${{ matrix.platform }}" == "darwin-arm64" ] || [ "${{ matrix.platform }}" == "darwin-x64" ]; then
ls -lh zig-out/native/${{ matrix.platform }}/*.dylib || echo "No dylib found"
else
ls -lh zig-out/native/${{ matrix.platform }}/*.so || echo "No so found"
fi
- name: Upload native library
uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.platform }}
path: zig-out/native/${{ matrix.platform }}/
retention-days: 7
package-natives:
name: Package native binaries
needs: build-native
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: List downloaded artifacts
run: |
echo "Downloaded artifacts:"
ls -R artifacts/
- name: Organize native binaries
run: |
mkdir -p native
for platform in darwin-arm64 darwin-x64 linux-x64 win32-x64; do
if [ -d "artifacts/native-$platform" ]; then
mkdir -p "native/$platform"
cp -r "artifacts/native-$platform/"* "native/$platform/"
fi
done
- name: List organized natives
run: |
echo "Organized native binaries:"
ls -R native/
- name: Upload combined artifact
uses: actions/upload-artifact@v4
with:
name: native-all-platforms
path: native/
retention-days: 30