Skip to content

Commit 5217d71

Browse files
committed
Add Flutter multi-platform package; add Android 16kb page size support; fix broken npmjs packages workflow
1 parent 864fa27 commit 5217d71

File tree

16 files changed

+367
-10
lines changed

16 files changed

+367
-10
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: publish flutter package
2+
on:
3+
push:
4+
tags:
5+
- '*.*.*'
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-22.04
14+
name: publish to pub.dev
15+
16+
steps:
17+
18+
- uses: actions/checkout@v4.2.2
19+
20+
- name: download release assets
21+
run: |
22+
VERSION=${GITHUB_REF#refs/tags/}
23+
echo "VERSION=$VERSION" >> $GITHUB_ENV
24+
25+
mkdir -p artifacts
26+
cd artifacts
27+
28+
# Download all platform binaries from the GitHub release
29+
gh release download "$VERSION" --pattern "cloudsync-*.tar.gz"
30+
31+
# Extract all archives
32+
for archive in cloudsync-*.tar.gz; do
33+
name=$(basename "$archive" "-$VERSION.tar.gz")
34+
mkdir -p "$name"
35+
tar -xzf "$archive" -C "$name"
36+
rm "$archive"
37+
done
38+
39+
ls -la
40+
env:
41+
GH_TOKEN: ${{ github.token }}
42+
43+
- uses: dart-lang/setup-dart@v1.7.1
44+
45+
- name: assemble and publish flutter package
46+
run: |
47+
FLUTTER_DIR=packages/flutter
48+
49+
# Android
50+
mkdir -p $FLUTTER_DIR/native_libraries/android
51+
cp artifacts/cloudsync-android-arm64-v8a/cloudsync.so $FLUTTER_DIR/native_libraries/android/cloudsync_android_arm64.so
52+
cp artifacts/cloudsync-android-armeabi-v7a/cloudsync.so $FLUTTER_DIR/native_libraries/android/cloudsync_android_arm.so
53+
cp artifacts/cloudsync-android-x86_64/cloudsync.so $FLUTTER_DIR/native_libraries/android/cloudsync_android_x64.so
54+
55+
# iOS device
56+
mkdir -p $FLUTTER_DIR/native_libraries/ios
57+
cp artifacts/cloudsync-ios/cloudsync.dylib $FLUTTER_DIR/native_libraries/ios/cloudsync_ios_arm64.dylib
58+
59+
# iOS simulator (keep universal/fat binary as-is)
60+
mkdir -p $FLUTTER_DIR/native_libraries/ios-sim
61+
cp artifacts/cloudsync-ios-sim/cloudsync.dylib $FLUTTER_DIR/native_libraries/ios-sim/cloudsync_ios-sim.dylib
62+
63+
# macOS (separate arch-specific dylibs)
64+
mkdir -p $FLUTTER_DIR/native_libraries/mac
65+
cp artifacts/cloudsync-macos-arm64/cloudsync.dylib $FLUTTER_DIR/native_libraries/mac/cloudsync_mac_arm64.dylib
66+
cp artifacts/cloudsync-macos-x86_64/cloudsync.dylib $FLUTTER_DIR/native_libraries/mac/cloudsync_mac_x64.dylib
67+
68+
# Linux
69+
mkdir -p $FLUTTER_DIR/native_libraries/linux
70+
cp artifacts/cloudsync-linux-x86_64/cloudsync.so $FLUTTER_DIR/native_libraries/linux/cloudsync_linux_x64.so
71+
cp artifacts/cloudsync-linux-arm64/cloudsync.so $FLUTTER_DIR/native_libraries/linux/cloudsync_linux_arm64.so
72+
73+
# Windows
74+
mkdir -p $FLUTTER_DIR/native_libraries/windows
75+
cp artifacts/cloudsync-windows-x86_64/cloudsync.dll $FLUTTER_DIR/native_libraries/windows/cloudsync_windows_x64.dll
76+
77+
# Update version
78+
sed -i "s/^version: .*/version: $VERSION/" $FLUTTER_DIR/pubspec.yaml
79+
80+
# Publish to pub.dev
81+
cd $FLUTTER_DIR
82+
dart pub get
83+
dart pub publish --dry-run
84+
dart pub publish --force

.github/workflows/main.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: build, test and release sqlite-sync
22
on:
33
push:
4+
branches:
5+
- '**'
6+
tags-ignore:
7+
- '**'
48
workflow_dispatch:
59

610
permissions:
@@ -362,13 +366,9 @@ jobs:
362366
- uses: actions/setup-node@v4
363367
if: steps.tag.outputs.version != ''
364368
with:
365-
node-version: '20'
369+
node-version: '24'
366370
registry-url: 'https://registry.npmjs.org'
367371

368-
- name: update npm
369-
if: steps.tag.outputs.version != ''
370-
run: npm install -g npm@11.5.1
371-
372372
- name: build and publish npm packages
373373
if: steps.tag.outputs.version != ''
374374
run: |
@@ -438,9 +438,11 @@ jobs:
438438
- uses: softprops/action-gh-release@v2.2.1
439439
if: steps.tag.outputs.version != ''
440440
with:
441+
token: ${{ secrets.RELEASE_PAT }}
441442
body: |
442443
# Packages
443444
445+
[**Flutter/Dart**](https://pub.dev/packages/sqlite_sync): `flutter pub add sqlite_sync:${{ steps.tag.outputs.version }}` or `dart pub add sqlite_sync:${{ steps.tag.outputs.version }}`
444446
[**Node**](https://www.npmjs.com/package/@sqliteai/sqlite-sync): `npm install @sqliteai/sqlite-sync`
445447
[**WASM**](https://www.npmjs.com/package/@sqliteai/sqlite-wasm): `npm install @sqliteai/sqlite-wasm`
446448
[**Expo**](https://www.npmjs.com/package/@sqliteai/sqlite-sync-expo): `npm install @sqliteai/sqlite-sync-expo`

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,11 @@ jniLibs/
4949

5050
# System
5151
.DS_Store
52-
Thumbs.db
52+
Thumbs.db
53+
54+
# Dart/Flutter
55+
.dart_tool/
56+
pubspec.lock
57+
.flutter-plugins
58+
.flutter-plugins-dependencies
59+
packages/flutter/native_libraries/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ else ifeq ($(PLATFORM),android)
120120
CURL_CONFIG = --host $(ARCH)-linux-$(ANDROID_ABI) --with-openssl=$(CURDIR)/$(OPENSSL_INSTALL_DIR) LDFLAGS="-L$(CURDIR)/$(OPENSSL_INSTALL_DIR)/lib" LIBS="-lssl -lcrypto" AR=$(BIN)/llvm-ar AS=$(BIN)/llvm-as CC=$(CC) CXX=$(BIN)/$(ARCH)-linux-$(ANDROID_ABI)-clang++ LD=$(BIN)/ld RANLIB=$(BIN)/llvm-ranlib STRIP=$(BIN)/llvm-strip
121121
TARGET := $(DIST_DIR)/cloudsync.so
122122
CFLAGS += -fPIC -I$(OPENSSL_INSTALL_DIR)/include
123-
LDFLAGS += -shared -fPIC -L$(OPENSSL_INSTALL_DIR)/lib -lssl -lcrypto
123+
LDFLAGS += -shared -fPIC -L$(OPENSSL_INSTALL_DIR)/lib -lssl -lcrypto -Wl,-z,max-page-size=16384
124124
STRIP = $(BIN)/llvm-strip --strip-unneeded $@
125125
else ifeq ($(PLATFORM),ios)
126126
TARGET := $(DIST_DIR)/cloudsync.dylib

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,27 @@ if (Platform.OS === 'ios') {
217217
}
218218
```
219219

220+
### Flutter Package
221+
222+
Add the [sqlite_sync](https://pub.dev/packages/sqlite_sync) package to your project:
223+
224+
```bash
225+
flutter pub add sqlite_sync # Flutter projects
226+
dart pub add sqlite_sync # Dart projects
227+
```
228+
229+
Usage with `sqlite3` package:
230+
```dart
231+
import 'package:sqlite3/sqlite3.dart';
232+
import 'package:sqlite_sync/sqlite_sync.dart';
233+
234+
sqlite3.loadSqliteSyncExtension();
235+
final db = sqlite3.openInMemory();
236+
print(db.select('SELECT cloudsync_version()'));
237+
```
238+
239+
For a complete example, see the [Flutter example](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/flutter/README.md).
240+
220241
## Getting Started
221242

222243
Here's a quick example to get started with SQLite Sync:

packages/flutter/.pubignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Only ignore development files, NOT native_libraries
2+
.dart_tool/
3+
pubspec.lock
4+
5+
# Explicitly include native_libraries (override any parent .gitignore)
6+
!native_libraries/
7+
!native_libraries/**

packages/flutter/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
## 0.8.64
4+
5+
- Initial Flutter package release
6+
- Added support for Android 16kb page size devices

packages/flutter/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../LICENSE.md

packages/flutter/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# sqlite_sync
2+
3+
SQLite Sync is a multi-platform extension that brings a true local-first experience to your applications with minimal effort. It extends standard SQLite tables with built-in support for offline work and automatic synchronization, allowing multiple devices to operate independently—even without a network connection—and seamlessly stay in sync.
4+
5+
## Installation
6+
7+
```
8+
dart pub add sqlite_sync
9+
```
10+
11+
Requires Dart 3.10+ / Flutter 3.38+.
12+
13+
## Usage
14+
15+
### With `sqlite3`
16+
17+
```dart
18+
import 'package:sqlite3/sqlite3.dart';
19+
import 'package:sqlite_sync/sqlite_sync.dart';
20+
21+
void main() {
22+
// Load once at startup.
23+
sqlite3.loadSqliteSyncExtension();
24+
25+
final db = sqlite3.openInMemory();
26+
27+
// Check version.
28+
final result = db.select('SELECT cloudsync_version() AS version');
29+
print(result.first['version']);
30+
31+
db.dispose();
32+
}
33+
```
34+
35+
### With `drift`
36+
37+
```dart
38+
import 'package:sqlite3/sqlite3.dart';
39+
import 'package:sqlite_sync/sqlite_sync.dart';
40+
import 'package:drift/native.dart';
41+
42+
Sqlite3 loadExtensions() {
43+
sqlite3.loadSqliteSyncExtension();
44+
return sqlite3;
45+
}
46+
47+
// Use when creating the database:
48+
NativeDatabase.createInBackground(
49+
File(path),
50+
sqlite3: loadExtensions,
51+
);
52+
```
53+
54+
## Supported platforms
55+
56+
| Platform | Architectures |
57+
|----------|---------------|
58+
| Android | arm64, arm, x64 |
59+
| iOS | arm64 (device + simulator) |
60+
| macOS | arm64, x64 |
61+
| Linux | arm64, x64 |
62+
| Windows | x64 |
63+
64+
## API
65+
66+
See the full [sqlite-sync API documentation](https://github.com/sqliteai/sqlite-sync/blob/main/API.md).
67+
68+
## License
69+
70+
See [LICENSE](LICENSE).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:lints/recommended.yaml

0 commit comments

Comments
 (0)