-
Notifications
You must be signed in to change notification settings - Fork 34
315 lines (265 loc) · 9.09 KB
/
update-libsql.yml
File metadata and controls
315 lines (265 loc) · 9.09 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
name: Build libsql libraries
on:
workflow_dispatch:
inputs:
libsql_tag:
description: 'libsql repository tag to build (e.g. libsql-0.9.4)'
required: true
default: 'libsql-0.9.4'
jobs:
extract-headers:
runs-on: ubuntu-latest
steps:
- name: Set libsql tag
run: |
TAG=${{ github.event.inputs.libsql_tag }}
echo "Using tag: $TAG"
echo "LIBSQL_TAG=$TAG" >> $GITHUB_ENV
- name: Checkout libsql at tag
uses: actions/checkout@v4
with:
repository: tursodatabase/libsql
ref: ${{ env.LIBSQL_TAG }}
path: libsql
- name: Extract headers
run: |
mkdir -p include
cp libsql/bindings/c/include/libsql.h include/
- name: Upload header artifact
uses: actions/upload-artifact@v4
with:
name: libsql-headers
path: include/
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu]
include:
- target: x86_64-unknown-linux-gnu
output_dir: linux_amd64
- target: aarch64-unknown-linux-gnu
output_dir: linux_arm64
steps:
- name: Checkout go-libsql
uses: actions/checkout@v4
with:
path: go-libsql
- name: Set libsql tag
id: set-tag
run: |
TAG=${{ github.event.inputs.libsql_tag }}
echo "Using tag: $TAG"
echo "LIBSQL_TAG=$TAG" >> $GITHUB_ENV
- name: Checkout libsql at tag
uses: actions/checkout@v4
with:
repository: tursodatabase/libsql
ref: ${{ env.LIBSQL_TAG }}
path: libsql
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
- name: Install cross
run: cargo install cross
- name: Build libsql for ${{ matrix.target }}
working-directory: libsql/bindings/c
run: |
cross build --release --target ${{ matrix.target }}
- name: Create output directory
run: |
mkdir -p go-libsql/lib/${{ matrix.output_dir }}
- name: Copy library files
run: |
cp libsql/target/${{ matrix.target }}/release/libsql_experimental.a go-libsql/lib/${{ matrix.output_dir }}/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libsql-${{ matrix.output_dir }}
path: go-libsql/lib/${{ matrix.output_dir }}
build-macos:
runs-on: macos-latest
steps:
- name: Checkout go-libsql
uses: actions/checkout@v4
with:
path: go-libsql
- name: Set libsql tag
id: set-tag
run: |
TAG=${{ github.event.inputs.libsql_tag }}
echo "Using tag: $TAG"
echo "LIBSQL_TAG=$TAG" >> $GITHUB_ENV
- name: Checkout libsql at tag
uses: actions/checkout@v4
with:
repository: tursodatabase/libsql
ref: ${{ env.LIBSQL_TAG }}
path: libsql
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
- name: Build libsql for macOS
working-directory: libsql/bindings/c
run: |
cargo build --release
- name: Create output directory
run: |
mkdir -p go-libsql/lib/darwin_arm64
- name: Copy library files
run: |
cp libsql/target/release/libsql_experimental.a go-libsql/lib/darwin_arm64/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libsql-darwin_arm64
path: go-libsql/lib/darwin_arm64
verify-linux-amd64:
needs: [build-linux, extract-headers]
runs-on: ubuntu-latest
steps:
- name: Checkout go-libsql
uses: actions/checkout@v4
- name: Download Linux AMD64 artifact
uses: actions/download-artifact@v4
with:
name: libsql-linux_amd64
path: lib/linux_amd64
- name: Download headers
uses: actions/download-artifact@v4
with:
name: libsql-headers
path: lib/include
- name: Check binary details
run: |
echo "Linux AMD64 library size:"
ls -la lib/linux_amd64/libsql_experimental.a
echo "Header file:"
ls -la lib/include/libsql.h
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Verify Linux AMD64 build
run: |
echo "Building example/local/main.go for Linux AMD64..."
cd example/local
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -v
echo "Linux AMD64 build successful!"
verify-linux-arm64:
needs: [build-linux, extract-headers]
runs-on: ubuntu-latest
steps:
- name: Checkout go-libsql
uses: actions/checkout@v4
- name: Download Linux ARM64 artifact
uses: actions/download-artifact@v4
with:
name: libsql-linux_arm64
path: lib/linux_arm64
- name: Download headers
uses: actions/download-artifact@v4
with:
name: libsql-headers
path: lib/include
- name: Check binary details
run: |
echo "Linux ARM64 library size:"
ls -la lib/linux_arm64/libsql_experimental.a
echo "Header file:"
ls -la lib/include/libsql.h
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Install cross-compiler for ARM64
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Verify Linux ARM64 build
run: |
echo "Building example/local/main.go for Linux ARM64..."
cd example/local
CC=aarch64-linux-gnu-gcc GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -v
echo "Linux ARM64 build successful!"
verify-darwin-arm64:
needs: [build-macos, extract-headers]
runs-on: macos-latest
steps:
- name: Checkout go-libsql
uses: actions/checkout@v4
- name: Download Darwin ARM64 artifact
uses: actions/download-artifact@v4
with:
name: libsql-darwin_arm64
path: lib/darwin_arm64
- name: Download headers
uses: actions/download-artifact@v4
with:
name: libsql-headers
path: lib/include
- name: Check binary details
run: |
echo "Darwin ARM64 library size:"
ls -la lib/darwin_arm64/libsql_experimental.a
echo "Header file:"
ls -la lib/include/libsql.h
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Verify Darwin ARM64 build
run: |
echo "Building example/local/main.go for Darwin ARM64..."
cd example/local
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -v
echo "Darwin ARM64 build successful!"
update-repository:
needs: [verify-linux-amd64, verify-linux-arm64, verify-darwin-arm64]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout go-libsql
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Copy artifacts to repository
run: |
mkdir -p lib/linux_amd64 lib/linux_arm64 lib/darwin_arm64 lib/include
cp -r artifacts/libsql-linux_amd64/* lib/linux_amd64/
cp -r artifacts/libsql-linux_arm64/* lib/linux_arm64/
cp -r artifacts/libsql-darwin_arm64/* lib/darwin_arm64/
# only copy header if it changed
if ! cmp -s artifacts/libsql-headers/libsql.h lib/include/libsql.h 2>/dev/null; then
cp artifacts/libsql-headers/libsql.h lib/include/
echo "Header file updated"
else
echo "Header file unchanged, skipping"
fi
# Clean up artifacts directory to prevent it from being included in the PR
rm -rf artifacts
- name: Set libsql tag
id: set-tag
run: |
TAG=${{ github.event.inputs.libsql_tag }}
echo "LIBSQL_TAG=$TAG" >> $GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "Update libsql libraries to `${{ env.LIBSQL_TAG }}`"
title: "Update libsql libraries to `${{ env.LIBSQL_TAG }}`"
body: |
This PR updates the libsql static libraries to version `${{ env.LIBSQL_TAG }}`.
Libraries updated:
- `linux_amd64/libsql_experimental.a`
- `linux_arm64/libsql_experimental.a`
- `darwin_arm64/libsql_experimental.a`
- `include/libsql.h` (if changed)
This update was generated automatically by the [update-libsql workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
branch: update-${{ env.LIBSQL_TAG }}
delete-branch: true