1- name : build, test and release sqlite-sync
1+ # # DELETE before merge to main branch
2+ name : build node and expo package for sqlite-sync (pg-extension)
23on :
34 push :
4- workflow_dispatch :
5+ branches :
6+ - wip-pg-extension
57
68permissions :
79 contents : write
1214 build :
1315 runs-on : ${{ matrix.os }}
1416 container : ${{ matrix.container && matrix.container || '' }}
15- name : ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.arch != 'armeabi-v7a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && matrix.name != 'android-aar' && ( matrix.name != 'macos' || matrix.arch != 'x86_64' ) && ' + test' || ''}}
17+ name : ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build
1618 timeout-minutes : 20
1719 strategy :
1820 fail-fast : false
3133 - os : ubuntu-22.04-arm
3234 arch : arm64
3335 name : linux-musl
34- - os : macos-15
35- name : macos
36- make : COVERAGE=ON
3736 - os : macos-15
3837 arch : x86_64
3938 name : macos
@@ -57,41 +56,18 @@ jobs:
5756 arch : x86_64
5857 name : android
5958 make : PLATFORM=android ARCH=x86_64
60- sqlite-amalgamation-zip : https://sqlite.org/2025/sqlite-amalgamation-3490100.zip
61- - os : macos-15
62- name : ios
63- make : PLATFORM=ios
64- - os : macos-15
65- name : ios-sim
66- make : PLATFORM=ios-sim
6759 - os : macos-15
6860 name : apple-xcframework
6961 make : xcframework
70- - os : ubuntu-22.04
71- name : android-aar
72- make : aar
7362
7463 defaults :
7564 run :
7665 shell : ${{ matrix.container && 'sh' || 'bash' }}
7766
78- env :
79- CONNECTION_STRING : ${{ secrets.CONNECTION_STRING }}
80- CONNECTION_STRING_OFFLINE_PROJECT : ${{ secrets.CONNECTION_STRING_OFFLINE_PROJECT }}
81- APIKEY : ${{ secrets.APIKEY }}
82- WEBLITE : ${{ secrets.WEBLITE }}
83-
8467 steps :
8568
8669 - uses : actions/checkout@v4.2.2
8770
88- - name : android setup java
89- if : matrix.name == 'android-aar'
90- uses : actions/setup-java@v4
91- with :
92- distribution : ' temurin'
93- java-version : ' 17'
94-
9571 - uses : msys2/setup-msys2@v2.27.0
9672 if : matrix.name == 'windows'
9773 with :
@@ -117,10 +93,6 @@ jobs:
11793 --platform linux/arm64 \
11894 -v ${{ github.workspace }}:/workspace \
11995 -w /workspace \
120- -e CONNECTION_STRING="${{ env.CONNECTION_STRING }}" \
121- -e CONNECTION_STRING_OFFLINE_PROJECT="${{ env.CONNECTION_STRING_OFFLINE_PROJECT }}" \
122- -e APIKEY="${{ env.APIKEY }}" \
123- -e WEBLITE="${{ env.WEBLITE }}" \
12496 alpine:latest \
12597 tail -f /dev/null
12698 docker exec alpine sh -c "apk update && apk add --no-cache gcc make curl sqlite openssl-dev musl-dev linux-headers"
@@ -166,59 +138,6 @@ jobs:
166138 rm certificate.p12
167139 security delete-keychain build.keychain
168140
169- - name : android setup test environment
170- if : matrix.name == 'android' && matrix.arch != 'arm64-v8a' && matrix.arch != 'armeabi-v7a'
171- run : |
172-
173- echo "::group::enable kvm group perms"
174- echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
175- sudo udevadm control --reload-rules
176- sudo udevadm trigger --name-match=kvm
177- echo "::endgroup::"
178-
179- echo "::group::download and build sqlite3 without SQLITE_OMIT_LOAD_EXTENSION"
180- curl -O ${{ matrix.sqlite-amalgamation-zip }}
181- unzip sqlite-amalgamation-*.zip
182- export ${{ matrix.make }}
183- $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.arch }}-linux-android26-clang sqlite-amalgamation-*/shell.c sqlite-amalgamation-*/sqlite3.c -o sqlite3 -ldl
184- # remove unused folders to save up space
185- rm -rf sqlite-amalgamation-*.zip sqlite-amalgamation-* openssl
186- echo "::endgroup::"
187-
188- echo "::group::prepare the test script"
189- make test PLATFORM=$PLATFORM ARCH=$ARCH || echo "It should fail. Running remaining commands in the emulator"
190- cat > commands.sh << EOF
191- mv -f /data/local/tmp/sqlite3 /system/xbin
192- cd /data/local/tmp
193- export CONNECTION_STRING="$CONNECTION_STRING"
194- export CONNECTION_STRING_OFFLINE_PROJECT="$CONNECTION_STRING_OFFLINE_PROJECT"
195- export APIKEY="$APIKEY"
196- export WEBLITE="$WEBLITE"
197- $(make test PLATFORM=$PLATFORM ARCH=$ARCH -n)
198- EOF
199- echo "::endgroup::"
200-
201- - name : android test sqlite-sync
202- if : matrix.name == 'android' && matrix.arch != 'arm64-v8a' && matrix.arch != 'armeabi-v7a'
203- uses : reactivecircus/android-emulator-runner@v2.34.0
204- with :
205- api-level : 26
206- arch : ${{ matrix.arch }}
207- script : |
208- adb root
209- adb remount
210- adb push ${{ github.workspace }}/. /data/local/tmp/
211- adb shell "sh /data/local/tmp/commands.sh"
212-
213- - name : test sqlite-sync
214- if : contains(matrix.name, 'linux') || matrix.name == 'windows' || ( matrix.name == 'macos' && matrix.arch != 'x86_64' )
215- run : ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make test ${{ matrix.make && matrix.make || ''}}
216-
217- - uses : actions/upload-pages-artifact@v3.0.1
218- if : matrix.name == 'macos' && !matrix.arch
219- with :
220- path : coverage
221-
222141 - uses : actions/upload-artifact@v4.6.2
223142 if : always()
224143 with :
@@ -230,7 +149,6 @@ jobs:
230149 runs-on : ubuntu-22.04
231150 name : release
232151 needs : build
233- if : github.ref == 'refs/heads/main'
234152
235153 env :
236154 GH_TOKEN : ${{ github.token }}
@@ -243,121 +161,9 @@ jobs:
243161 with :
244162 path : artifacts
245163
246- - name : setup GitHub Pages
247- uses : actions/configure-pages@v5
248-
249- - name : deploy coverage to GitHub Pages
250- uses : actions/deploy-pages@v4.0.5
251-
252- - name : zip artifacts
253- run : |
254- VERSION=$(make version)
255- for folder in "artifacts"/*; do
256- if [ -d "$folder" ]; then
257- name=$(basename "$folder")
258- if [[ "$name" != "github-pages" ]]; then
259- if [[ "$name" != "cloudsync-apple-xcframework" && "$name" != "cloudsync-android-aar" ]]; then
260- tar -czf "${name}-${VERSION}.tar.gz" -C "$folder" .
261- fi
262- if [[ "$name" != "cloudsync-android-aar" ]]; then
263- (cd "$folder" && zip -rq "../../${name}-${VERSION}.zip" .)
264- else
265- cp "$folder"/*.aar "${name}-${VERSION}.aar"
266- fi
267- fi
268- fi
269- done
270-
271164 - name : release tag version from cloudsync.h
272165 id : tag
273- run : |
274- VERSION=$(make version)
275- if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
276- LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest)
277- LATEST=$(echo "$LATEST_RELEASE" | jq -r '.name')
278- # Check artifact sizes against previous release
279- if [ -n "$LATEST" ] && [ "$LATEST" != "null" ]; then
280- echo "Checking artifact sizes against previous release: $LATEST"
281- FAILED=0
282- for artifact in cloudsync-*-${VERSION}.*; do
283- if [ ! -f "$artifact" ]; then
284- continue
285- fi
286- # Get current artifact size
287- NEW_SIZE=$(stat -c%s "$artifact" 2>/dev/null || stat -f%z "$artifact")
288- # Get artifact name for previous release
289- ARTIFACT_NAME=$(echo "$artifact" | sed "s/${VERSION}/${LATEST}/")
290- # Get previous artifact size from GitHub API
291- OLD_SIZE=$(echo "$LATEST_RELEASE" | jq -r ".assets[] | select(.name == \"$(basename "$ARTIFACT_NAME")\") | .size")
292- if [ -z "$OLD_SIZE" ] || [ "$OLD_SIZE" = "null" ]; then
293- echo "⚠️ Previous artifact not found: $(basename "$ARTIFACT_NAME"), skipping comparison"
294- continue
295- fi
296- # Calculate percentage increase
297- INCREASE=$(awk "BEGIN {printf \"%.2f\", (($NEW_SIZE - $OLD_SIZE) / $OLD_SIZE) * 100}")
298- echo "📦 $artifact: $OLD_SIZE → $NEW_SIZE bytes (${INCREASE}% change)"
299- # Check if increase is more than 5%
300- if (( $(echo "$INCREASE > 5" | bc -l) )); then
301- if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
302- echo "⚠️ WARNING: $artifact size increased by ${INCREASE}% (limit: 5%)"
303- else
304- echo "❌ ERROR: $artifact size increased by ${INCREASE}% (limit: 5%)"
305- FAILED=1
306- fi
307- fi
308- done
309- if [ $FAILED -eq 1 ]; then
310- echo ""
311- echo "❌ One or more artifacts exceeded the 5% size increase limit"
312- exit 1
313- fi
314- echo "✅ All artifacts within 5% size increase limit"
315- fi
316-
317- if [[ "$VERSION" != "$LATEST" || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
318- echo "version=$VERSION" >> $GITHUB_OUTPUT
319- else
320- echo "::warning file=src/cloudsync.h::To release a new version, please update the CLOUDSYNC_VERSION in src/cloudsync.h to be different than the latest $LATEST"
321- fi
322- exit 0
323- fi
324- echo "❌ CLOUDSYNC_VERSION not found in cloudsync.h"
325- exit 1
326-
327- - uses : actions/checkout@v4.2.2
328- if : steps.tag.outputs.version != ''
329- with :
330- repository : sqliteai/sqlite-wasm
331- path : sqlite-wasm
332- submodules : recursive
333- token : ${{ secrets.PAT }}
334-
335- - name : release sqlite-wasm
336- if : steps.tag.outputs.version != ''
337- run : |
338- cd sqlite-wasm
339- git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
340- git config --global user.name "$GITHUB_ACTOR"
341- cd modules/sqlite-sync
342- git checkout ${{ github.sha }}
343- cd ../..
344- git add modules/sqlite-sync
345- PKG=sqlite-wasm/package.json
346- TMP=sqlite-wasm/package.tmp.json
347- jq --arg version "$(cat modules/sqlite/VERSION)-sync.$(cd modules/sqlite-sync && make version)-vector.$(cd modules/sqlite-vector && make version)" '.version = $version' "$PKG" > "$TMP" && mv "$TMP" "$PKG"
348- git add "$PKG"
349- git commit -m "Bump sqlite-sync version to ${{ steps.tag.outputs.version }}"
350- git push origin main
351-
352- - uses : actions/setup-java@v4
353- if : steps.tag.outputs.version != ''
354- with :
355- distribution : ' temurin'
356- java-version : ' 17'
357-
358- - name : release android aar to maven central
359- if : steps.tag.outputs.version != ''
360- run : cd packages/android && ./gradlew publishAggregationToCentralPortal -PSIGNING_KEY="${{ secrets.SIGNING_KEY }}" -PSIGNING_PASSWORD="${{ secrets.SIGNING_PASSWORD }}" -PSONATYPE_USERNAME="${{ secrets.MAVEN_CENTRAL_USERNAME }}" -PSONATYPE_PASSWORD="${{ secrets.MAVEN_CENTRAL_TOKEN }}" -PVERSION="${{ steps.tag.outputs.version }}" -PAAR_PATH="../../artifacts/cloudsync-android-aar/cloudsync.aar"
166+ run : echo "version=$(make version)" >> $GITHUB_OUTPUT
361167
362168 - uses : actions/setup-node@v4
363169 if : steps.tag.outputs.version != ''
@@ -404,15 +210,15 @@ jobs:
404210 platform_name=$(basename "$platform_dir")
405211 echo " Publishing @sqliteai/sqlite-sync-${platform_name}..."
406212 cd "$platform_dir"
407- npm publish --provenance --access public
213+ npm publish --provenance --access public --tag pg
408214 cd ..
409215 echo " ✓ Published @sqliteai/sqlite-sync-${platform_name}"
410216 done
411217 cd ..
412218
413219 # Publish main package
414220 echo "Publishing main package to npm..."
415- npm publish --provenance --access public
221+ npm publish --provenance --access public --tag pg
416222 echo "✓ Published @sqliteai/sqlite-sync@${{ steps.tag.outputs.version }}"
417223
418224 echo ""
@@ -432,26 +238,5 @@ jobs:
432238
433239 echo "Publishing @sqliteai/sqlite-sync-expo to npm..."
434240 cd expo-package
435- npm publish --provenance --access public
436- echo "✓ Published @sqliteai/sqlite-sync-expo@${{ steps.tag.outputs.version }}"
437-
438- - uses : softprops/action-gh-release@v2.2.1
439- if : steps.tag.outputs.version != ''
440- with :
441- body : |
442- # Packages
443-
444- [**Node**](https://www.npmjs.com/package/@sqliteai/sqlite-sync): `npm install @sqliteai/sqlite-sync`
445- [**WASM**](https://www.npmjs.com/package/@sqliteai/sqlite-wasm): `npm install @sqliteai/sqlite-wasm`
446- [**Expo**](https://www.npmjs.com/package/@sqliteai/sqlite-sync-expo): `npm install @sqliteai/sqlite-sync-expo`
447- [**Android**](https://central.sonatype.com/artifact/ai.sqlite/sync): `ai.sqlite:sync:${{ steps.tag.outputs.version }}`
448- [**Swift**](https://github.com/sqliteai/sqlite-sync#swift-package): [Installation Guide](https://github.com/sqliteai/sqlite-sync#swift-package)
449-
450- ---
451-
452- generate_release_notes : true
453- tag_name : ${{ steps.tag.outputs.version }}
454- files : |
455- cloudsync-*-${{ steps.tag.outputs.version }}.*
456- CloudSync-*-${{ steps.tag.outputs.version }}.*
457- make_latest : true
241+ npm publish --provenance --access public --tag pg
242+ echo "✓ Published @sqliteai/sqlite-sync-expo@${{ steps.tag.outputs.version }}"
0 commit comments