Skip to content

Commit f66c38e

Browse files
committed
update build workflow, with test and release of sqlite-sync
1 parent f1e70e9 commit f66c38e

File tree

1 file changed

+121
-9
lines changed

1 file changed

+121
-9
lines changed

.github/workflows/main.yml

Lines changed: 121 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
name: build sqlitesync
1+
name: build, test and release sqlite-sync
22
on:
33
push:
4-
branches:
5-
- main
4+
5+
permissions:
6+
contents: write
67

78
jobs:
89
build:
910
runs-on: ${{ matrix.os }}
10-
name: build for ${{ matrix.name }}-${{ matrix.arch }}
11+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'isim' && matrix.name != 'ios' && ' + test' || ''}}
1112
timeout-minutes: 20
1213
strategy:
1314
fail-fast: false
@@ -34,7 +35,7 @@ jobs:
3435
configure: --with-schannel
3536
name: windows
3637
- os: ubuntu-latest
37-
arch: arm64
38+
arch: arm64-v8a
3839
configure:
3940
--host aarch64-linux-android26
4041
--with-openssl=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr
@@ -47,6 +48,9 @@ jobs:
4748
RANLIB=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
4849
STRIP=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
4950
name: android
51+
make:
52+
PLATFORM=android
53+
CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang
5054
- os: ubuntu-latest
5155
arch: x86_64
5256
configure:
@@ -61,27 +65,34 @@ jobs:
6165
RANLIB=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
6266
STRIP=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
6367
name: android
68+
make:
69+
PLATFORM=android
70+
CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang
71+
sqlite-amalgamation-zip: https://sqlite.org/2025/sqlite-amalgamation-3490100.zip
6472
- os: macos-latest
6573
arch: arm64
6674
configure:
6775
--host=arm64-apple-darwin
6876
--with-secure-transport
6977
CFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=11.0"
7078
name: ios
79+
make: PLATFORM=ios
7180
- os: macos-latest
7281
arch: arm64
7382
configure:
7483
--host=arm64-apple-darwin
7584
--with-secure-transport
7685
CFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0"
7786
name: isim
87+
make: PLATFORM=isim
7888
- os: macos-latest
7989
arch: x86_64
8090
configure:
8191
--host=x86_64-apple-darwin
8292
--with-secure-transport
8393
CFLAGS="-arch x86_64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0"
8494
name: isim
95+
make: PLATFORM=isim
8596

8697
defaults:
8798
run:
@@ -208,12 +219,113 @@ jobs:
208219
mkdir -p network/curl/${{ matrix.name }}
209220
mv $folder/lib/.libs/libcurl.a network/curl/${{ matrix.name }}/lib${{matrix.arch}}.a
210221
222+
- name: build sqlite-sync
223+
run: make ${{ matrix.make && matrix.make || ''}}
224+
225+
- name: windows install sqlite3
226+
if: matrix.os == 'windows-latest'
227+
run: choco install sqlite -y
228+
229+
- name: macos install sqlite3 without SQLITE_OMIT_LOAD_EXTENSION
230+
if: matrix.name == 'macos'
231+
run: brew link sqlite --force
232+
233+
- name: android setup test environment
234+
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
235+
run: |
236+
237+
echo "::group::enable kvm group perms"
238+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
239+
sudo udevadm control --reload-rules
240+
sudo udevadm trigger --name-match=kvm
241+
echo "::endgroup::"
242+
243+
echo "::group::download and build sqlite3 without SQLITE_OMIT_LOAD_EXTENSION"
244+
curl -O ${{ matrix.sqlite-amalgamation-zip }}
245+
unzip sqlite-amalgamation-*.zip
246+
export ${{ matrix.make }}
247+
$CC sqlite-amalgamation-*/shell.c sqlite-amalgamation-*/sqlite3.c -o sqlite3 -ldl
248+
rm -rf sqlite-amalgamation-*.zip sqlite-amalgamation-*
249+
echo "::endgroup::"
250+
251+
echo "::group::prepare the test script"
252+
make test CC=$CC PLATFORM=$PLATFORM || echo "It should fail. Running remaining commands in the emulator"
253+
cat > commands.sh << EOF
254+
mv -f /data/local/tmp/sqlite3 /system/xbin
255+
cd /data/local/tmp
256+
$(make test CC=$CC PLATFORM=$PLATFORM -n)
257+
EOF
258+
echo "::endgroup::"
259+
260+
- name: android test sqlite-sync
261+
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
262+
uses: reactivecircus/[email protected]
263+
with:
264+
api-level: 26
265+
arch: ${{ matrix.arch }}
266+
script: |
267+
adb root
268+
adb remount
269+
adb push ${{ github.workspace }}/. /data/local/tmp/
270+
adb shell "sh /data/local/tmp/commands.sh"
271+
272+
- name: test sqlite-sync
273+
if: matrix.name == 'linux' || matrix.name == 'macos' || matrix.name == 'windows'
274+
run: make test
275+
211276
- uses: actions/[email protected]
212277
with:
213-
name: libcurl-${{ matrix.name }}-${{ matrix.arch }}
214-
path: network/curl/${{ matrix.name }}/lib${{matrix.arch}}.a
278+
name: cloudsync-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
279+
path: dist/cloudsync.*
215280
if-no-files-found: error
216281

217-
- name: build sqlitesync
282+
release:
283+
runs-on: ubuntu-latest
284+
name: release
285+
needs: build
286+
if: github.ref == 'refs/heads/main'
287+
288+
env:
289+
GH_TOKEN: ${{ github.token }}
290+
291+
steps:
292+
293+
- uses: actions/[email protected]
294+
295+
- uses: actions/[email protected]
296+
with:
297+
path: artifacts
298+
299+
- name: release tag version from cloudsync.h
300+
id: tag
301+
run: |
302+
FILE="src/cloudsync.h"
303+
VERSION=$(grep -oP '#define CLOUDSYNC_VERSION\s+"\K[^"]+' "$FILE")
304+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
305+
echo "version=$VERSION" >> $GITHUB_OUTPUT
306+
exit 0
307+
fi
308+
echo "❌ CLOUDSYNC_VERSION not found in cloudsync.h"
309+
exit 1
310+
311+
- name: zip artifacts
218312
run: |
219-
echo "TODO: build sqlitesync"
313+
for folder in "artifacts"/*; do
314+
if [ -d "$folder" ]; then
315+
name=$(basename "$folder")
316+
zip -jq "${name}-${{ steps.tag.outputs.version }}.zip" "$folder"/*
317+
tar -cJf "${name}-${{ steps.tag.outputs.version }}.tar.xz" -C "$folder" .
318+
tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" .
319+
fi
320+
done
321+
322+
- uses: softprops/[email protected]
323+
with:
324+
generate_release_notes: true
325+
tag_name: ${{ steps.tag.outputs.version }}
326+
files: |
327+
cloudsync-*-${{ steps.tag.outputs.version }}.zip
328+
cloudsync-*-${{ steps.tag.outputs.version }}.tar.xz
329+
cloudsync-*-${{ steps.tag.outputs.version }}.tar.gz
330+
make_latest: true
331+

0 commit comments

Comments
 (0)