Skip to content

Commit f679dc1

Browse files
committed
CI: Download sqlite
1 parent 8995a4e commit f679dc1

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Download and compile SQLite
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
artifact_id:
7+
description: "ID of the artifact containing prebuilt SQLite libraries"
8+
value: "todo"
9+
push:
10+
branches:
11+
- v3
12+
13+
jobs:
14+
download_sqlite:
15+
runs-on: ubuntu-latest
16+
name: Download SQLite sources
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/cache@v4
20+
id: cache_build
21+
with:
22+
path: out/
23+
key: sqlite-src-${{ hashFiles('tool/') }}
24+
25+
- uses: dart-lang/setup-dart@v1
26+
if: steps.cache_build.outputs.cache-hit != 'true'
27+
28+
- name: Download sqlite3
29+
if: steps.cache_build.outputs.cache-hit != 'true'
30+
run: |
31+
dart run tool/download_sqlite.dart
32+
33+
- name: Upload sqlite3 sources
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: sqlite3-src
37+
path: out/
38+
if-no-files-found: error
39+
retention-days: 1

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: CI
22

33
on:
4-
push:
5-
branches: ['**']
4+
# push:
5+
# branches: ['**']
66
pull_request:
77
branches: [ main ]
88

tool/download_sqlite.dart

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import 'dart:io';
2+
3+
const sqlitePath = 'sqlite-amalgamation-3500400';
4+
const sqliteSource = 'https://sqlite.org/2025/$sqlitePath.zip';
5+
const sqliteMultipleCiphersSource =
6+
'https://github.com/utelle/SQLite3MultipleCiphers/releases/download/v2.2.4/sqlite3mc-2.2.4-sqlite-3.50.4-amalgamation.zip';
7+
8+
const tmpDir = 'tmp';
9+
10+
void main(List<String> args) async {
11+
await Directory(tmpDir).create();
12+
13+
await _downloadAndExtract(sqliteSource, 'sqlite3');
14+
await _downloadAndExtract(sqliteMultipleCiphersSource, 'sqlite3mc');
15+
16+
await Directory('out').create();
17+
await Directory('out/sqlite3mc').create();
18+
await File('$tmpDir/sqlite3mc_amalgamation.h')
19+
.copy('out/sqlite3mc/sqlite3mc_amalgamation.h');
20+
await File('$tmpDir/sqlite3mc_amalgamation.c')
21+
.copy('out/sqlite3mc/sqlite3mc_amalgamation.c');
22+
23+
await Directory('out/sqlite3').create();
24+
await File('$tmpDir/$sqlitePath/sqlite3.h').copy('out/sqlite3/sqlite3.h');
25+
await File('$tmpDir/$sqlitePath/sqlite3.c').copy('out/sqlite3/sqlite3.c');
26+
await File('$tmpDir/$sqlitePath/sqlite3ext.h')
27+
.copy('out/sqlite3/sqlite3ext.h');
28+
}
29+
30+
Future<void> _downloadAndExtract(String url, String filename) async {
31+
await _run('curl -L $url --output $filename.zip', workingDirectory: tmpDir);
32+
await _run('unzip $filename.zip', workingDirectory: tmpDir);
33+
}
34+
35+
Future<void> _run(String command, {String? workingDirectory}) async {
36+
print('Running $command');
37+
38+
final proc = await Process.start(
39+
'sh',
40+
['-c', command],
41+
mode: ProcessStartMode.inheritStdio,
42+
workingDirectory: workingDirectory,
43+
);
44+
final exitCode = await proc.exitCode;
45+
46+
if (exitCode != 0) {
47+
exit(exitCode);
48+
}
49+
}

0 commit comments

Comments
 (0)