Skip to content

Commit 2ebfe40

Browse files
committed
fix: android and ios binaries to be downloaded using version from package.json
1 parent d0b5b0c commit 2ebfe40

File tree

4 files changed

+94
-11
lines changed

4 files changed

+94
-11
lines changed

.github/workflows/main.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
should_publish: ${{ steps.version_check.outputs.should_publish }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
- name: Enable Corepack
23+
run: corepack enable
24+
25+
- name: Install dependencies
26+
run: yarn install --immutable
27+
28+
- name: Typecheck
29+
run: yarn typecheck
30+
31+
- name: Lint
32+
run: yarn lint
33+
34+
- name: Build
35+
run: yarn prepare
36+
37+
- name: Check version
38+
id: version_check
39+
run: |
40+
PACKAGE_NAME=$(node -p "require('./package.json').name")
41+
LOCAL_VERSION=$(node -p "require('./package.json').version")
42+
NPM_VERSION=$(npm view "$PACKAGE_NAME" version 2>/dev/null || echo "0.0.0")
43+
44+
echo "Local version: $LOCAL_VERSION"
45+
echo "npm version: $NPM_VERSION"
46+
47+
if [ "$LOCAL_VERSION" != "$NPM_VERSION" ]; then
48+
echo "Version changed, will publish"
49+
echo "should_publish=true" >> $GITHUB_OUTPUT
50+
else
51+
echo "Version unchanged, skipping publish"
52+
echo "should_publish=false" >> $GITHUB_OUTPUT
53+
fi
54+
55+
publish:
56+
needs: build
57+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.build.outputs.should_publish == 'true'
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: read
61+
id-token: write
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
66+
- name: Setup Node.js
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: 20
70+
registry-url: 'https://registry.npmjs.org'
71+
72+
- name: Enable Corepack
73+
run: corepack enable
74+
75+
- name: Install dependencies
76+
run: yarn install --immutable
77+
78+
- name: Build
79+
run: yarn prepare
80+
81+
- name: Publish to npm
82+
run: npm publish --provenance --access public
83+
env:
84+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

android/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import groovy.json.JsonSlurper
2+
13
buildscript {
24
repositories {
35
google()
@@ -11,6 +13,10 @@ buildscript {
1113

1214
apply plugin: 'com.android.library'
1315

16+
// Read version from package.json
17+
def packageJson = new JsonSlurper().parse(file("$projectDir/../package.json"))
18+
def cloudsyncVersion = packageJson.version
19+
1420
def safeExtGet(prop, fallback) {
1521
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
1622
}
@@ -37,5 +43,5 @@ repositories {
3743
dependencies {
3844
implementation 'com.facebook.react:react-native:+'
3945
// SQLite Cloud Sync from Maven Central
40-
implementation 'ai.sqlite:sync:0.8.57'
46+
implementation "ai.sqlite:sync.dev:${cloudsyncVersion}"
4147
}

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sqliteai/sqlite-sync-react-native",
3-
"version": "0.1.0",
3+
"version": "0.9.96",
44
"description": "Offline-first React Native library with automatic sqlite-sync powered by SQLite Cloud",
55
"main": "./lib/module/index.js",
66
"types": "./lib/typescript/src/index.d.ts",
@@ -21,11 +21,9 @@
2121
"src",
2222
"lib",
2323
"android",
24-
"ios",
2524
"cpp",
2625
"*.podspec",
2726
"react-native.config.js",
28-
"!ios/build",
2927
"!android/build",
3028
"!android/gradle",
3129
"!android/gradlew",

sqlite-sync-react-native.podspec

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ Pod::Spec.new do |s|
1111
s.authors = package["author"]
1212

1313
s.platforms = { :ios => "13.0" }
14-
s.source = { :git => package["repository"]["url"], :tag => "v#{s.version}" }
14+
s.source = { :http => "https://github.com/sqliteai/sqlite-sync-dev/releases/download/v#{s.version}/cloudsync-apple-xcframework-#{s.version}.zip" }
1515

16-
s.source_files = "ios/**/*.{h,m,mm,swift}"
17-
18-
# Vendor the CloudSync xcframework
19-
s.vendored_frameworks = "ios/CloudSync.xcframework"
16+
s.vendored_frameworks = "CloudSync.xcframework"
2017

2118
# Dependencies
2219
s.dependency "React-Core"
23-
24-
# Required for op-sqlite integration
2520
s.dependency "React"
2621
end

0 commit comments

Comments
 (0)