1+ name : Build libsql libraries
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ libsql_tag :
7+ description : ' libsql repository tag to build (e.g. libsql-0.9.4)'
8+ required : true
9+ default : ' libsql-0.9.4'
10+
11+ jobs :
12+ build-linux :
13+ runs-on : ubuntu-latest
14+ strategy :
15+ matrix :
16+ target : [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu]
17+ include :
18+ - target : x86_64-unknown-linux-gnu
19+ output_dir : linux_amd64
20+ - target : aarch64-unknown-linux-gnu
21+ output_dir : linux_arm64
22+ steps :
23+ - name : Checkout go-libsql
24+ uses : actions/checkout@v4
25+ with :
26+ path : go-libsql
27+
28+ - name : Set libsql tag
29+ id : set-tag
30+ run : |
31+ TAG=${{ github.event.inputs.libsql_tag }}
32+ echo "Using tag: $TAG"
33+ echo "LIBSQL_TAG=$TAG" >> $GITHUB_ENV
34+
35+ - name : Checkout libsql at tag
36+ uses : actions/checkout@v4
37+ with :
38+ repository : tursodatabase/libsql
39+ ref : ${{ env.LIBSQL_TAG }}
40+ path : libsql
41+
42+ - name : Set up Rust
43+ uses : dtolnay/rust-toolchain@stable
44+ with :
45+ toolchain : stable
46+ override : true
47+
48+ - name : Install cross
49+ run : cargo install cross
50+
51+ - name : Build libsql for ${{ matrix.target }}
52+ working-directory : libsql/bindings/c
53+ run : |
54+ cross build --release --target ${{ matrix.target }}
55+
56+ - name : Create output directory
57+ run : |
58+ mkdir -p go-libsql/lib/${{ matrix.output_dir }}
59+
60+ - name : Copy library files
61+ run : |
62+ cp libsql/target/${{ matrix.target }}/release/libsql_experimental.a go-libsql/lib/${{ matrix.output_dir }}/
63+
64+ - name : Upload artifacts
65+ uses : actions/upload-artifact@v4
66+ with :
67+ name : libsql-${{ matrix.output_dir }}
68+ path : go-libsql/lib/${{ matrix.output_dir }}
69+
70+ build-macos :
71+ runs-on : macos-latest
72+ steps :
73+ - name : Checkout go-libsql
74+ uses : actions/checkout@v4
75+ with :
76+ path : go-libsql
77+
78+ - name : Set libsql tag
79+ id : set-tag
80+ run : |
81+ TAG=${{ github.event.inputs.libsql_tag }}
82+ echo "Using tag: $TAG"
83+ echo "LIBSQL_TAG=$TAG" >> $GITHUB_ENV
84+
85+ - name : Checkout libsql at tag
86+ uses : actions/checkout@v4
87+ with :
88+ repository : tursodatabase/libsql
89+ ref : ${{ env.LIBSQL_TAG }}
90+ path : libsql
91+
92+ - name : Set up Rust
93+ uses : dtolnay/rust-toolchain@stable
94+ with :
95+ targets : aarch64-apple-darwin
96+
97+ - name : Build libsql for macOS
98+ working-directory : libsql/bindings/c
99+ run : |
100+ cargo build --release
101+
102+ - name : Create output directory
103+ run : |
104+ mkdir -p go-libsql/lib/darwin_arm64
105+
106+ - name : Copy library files
107+ run : |
108+ cp libsql/target/release/libsql_experimental.a go-libsql/lib/darwin_arm64/
109+
110+ - name : Upload artifacts
111+ uses : actions/upload-artifact@v4
112+ with :
113+ name : libsql-darwin_arm64
114+ path : go-libsql/lib/darwin_arm64
115+
116+ verify-linux-amd64 :
117+ needs : [build-linux]
118+ runs-on : ubuntu-latest
119+ steps :
120+ - name : Checkout go-libsql
121+ uses : actions/checkout@v4
122+
123+ - name : Download Linux AMD64 artifact
124+ uses : actions/download-artifact@v4
125+ with :
126+ name : libsql-linux_amd64
127+ path : lib/linux_amd64
128+
129+ - name : Check binary details
130+ run : |
131+ echo "Linux AMD64 library size:"
132+ ls -la lib/linux_amd64/libsql_experimental.a
133+
134+ - name : Set up Go
135+ uses : actions/setup-go@v4
136+ with :
137+ go-version : ' 1.20'
138+
139+ - name : Verify Linux AMD64 build
140+ run : |
141+ echo "Building example/local/main.go for Linux AMD64..."
142+ cd example/local
143+ GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -v
144+ echo "Linux AMD64 build successful!"
145+
146+ verify-linux-arm64 :
147+ needs : [build-linux]
148+ runs-on : ubuntu-latest
149+ steps :
150+ - name : Checkout go-libsql
151+ uses : actions/checkout@v4
152+
153+ - name : Download Linux ARM64 artifact
154+ uses : actions/download-artifact@v4
155+ with :
156+ name : libsql-linux_arm64
157+ path : lib/linux_arm64
158+
159+ - name : Check binary details
160+ run : |
161+ echo "Linux ARM64 library size:"
162+ ls -la lib/linux_arm64/libsql_experimental.a
163+
164+ - name : Set up Go
165+ uses : actions/setup-go@v4
166+ with :
167+ go-version : ' 1.20'
168+
169+ - name : Install cross-compiler for ARM64
170+ run : |
171+ sudo apt-get update
172+ sudo apt-get install -y gcc-aarch64-linux-gnu
173+
174+ - name : Verify Linux ARM64 build
175+ run : |
176+ echo "Building example/local/main.go for Linux ARM64..."
177+ cd example/local
178+ CC=aarch64-linux-gnu-gcc GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -v
179+ echo "Linux ARM64 build successful!"
180+
181+ verify-darwin-arm64 :
182+ needs : [build-macos]
183+ runs-on : macos-latest
184+ steps :
185+ - name : Checkout go-libsql
186+ uses : actions/checkout@v4
187+
188+ - name : Download Darwin ARM64 artifact
189+ uses : actions/download-artifact@v4
190+ with :
191+ name : libsql-darwin_arm64
192+ path : lib/darwin_arm64
193+
194+ - name : Check binary details
195+ run : |
196+ echo "Darwin ARM64 library size:"
197+ ls -la lib/darwin_arm64/libsql_experimental.a
198+
199+ - name : Set up Go
200+ uses : actions/setup-go@v4
201+ with :
202+ go-version : ' 1.20'
203+
204+ - name : Verify Darwin ARM64 build
205+ run : |
206+ echo "Building example/local/main.go for Darwin ARM64..."
207+ cd example/local
208+ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -v
209+ echo "Darwin ARM64 build successful!"
210+
211+ update-repository :
212+ needs : [verify-linux-amd64, verify-linux-arm64, verify-darwin-arm64]
213+ runs-on : ubuntu-latest
214+ if : github.event_name != 'pull_request'
215+ steps :
216+ - name : Checkout go-libsql
217+ uses : actions/checkout@v4
218+
219+ - name : Download all artifacts
220+ uses : actions/download-artifact@v4
221+ with :
222+ path : artifacts
223+
224+ - name : Copy artifacts to repository
225+ run : |
226+ mkdir -p lib/linux_amd64 lib/linux_arm64 lib/darwin_arm64
227+ cp -r artifacts/libsql-linux_amd64/* lib/linux_amd64/
228+ cp -r artifacts/libsql-linux_arm64/* lib/linux_arm64/
229+ cp -r artifacts/libsql-darwin_arm64/* lib/darwin_arm64/
230+ # Clean up artifacts directory to prevent it from being included in the PR
231+ rm -rf artifacts
232+
233+ - name : Set libsql tag
234+ id : set-tag
235+ run : |
236+ TAG=${{ github.event.inputs.libsql_tag }}
237+ echo "LIBSQL_TAG=$TAG" >> $GITHUB_ENV
238+
239+ - name : Create Pull Request
240+ uses : peter-evans/create-pull-request@v5
241+ with :
242+ commit-message : " Update libsql libraries to `${{ env.LIBSQL_TAG }}`"
243+ title : " Update libsql libraries to `${{ env.LIBSQL_TAG }}`"
244+ body : |
245+ This PR updates the libsql static libraries to version `${{ env.LIBSQL_TAG }}`.
246+
247+ Libraries updated:
248+ - `linux_amd64/libsql_experimental.a`
249+ - `linux_arm64/libsql_experimental.a`
250+ - `darwin_arm64/libsql_experimental.a`
251+
252+ This update was generated automatically by the [update-libsql workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
253+ branch : update-${{ env.LIBSQL_TAG }}
254+ delete-branch : true
0 commit comments