-
Notifications
You must be signed in to change notification settings - Fork 1.1k
280 lines (236 loc) · 7.75 KB
/
Copy pathreact-native.yml
File metadata and controls
280 lines (236 loc) · 7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
name: Build & publish @tursodatabase/sync-react-native
on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
env:
CARGO_INCREMENTAL: "0"
CARGO_NET_RETRY: 10
working-directory: bindings/react-native
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-ios:
name: Build iOS libraries
runs-on: blacksmith-6vcpu-macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios,aarch64-apple-ios-sim
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust-ios"
cache-on-failure: true
- name: Build iOS libraries
run: make ios-build
working-directory: ${{ env.working-directory }}
- name: Package iOS xcframework
run: make package-dylibs
working-directory: ${{ env.working-directory }}
- name: Upload iOS artifacts
uses: actions/upload-artifact@v4
with:
name: ios-libs
path: |
bindings/react-native/libs/ios/
if-no-files-found: error
build-android:
name: Build Android libraries
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust-android"
cache-on-failure: true
- name: Set up Android NDK
uses: android-actions/setup-android@v3
- name: Install cargo-ndk
run: cargo install cargo-ndk
- name: Build Android libraries
run: make android
working-directory: ${{ env.working-directory }}
- name: Upload Android artifacts
uses: actions/upload-artifact@v4
with:
name: android-libs
path: |
bindings/react-native/libs/android/
if-no-files-found: error
build-typescript:
name: Build TypeScript
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install
working-directory: ${{ env.working-directory }}
- name: Build TypeScript
run: npm run build
working-directory: ${{ env.working-directory }}
- name: Type check
run: npm run typescript
working-directory: ${{ env.working-directory }}
- name: Upload TypeScript build
uses: actions/upload-artifact@v4
with:
name: typescript-build
path: |
bindings/react-native/lib/
if-no-files-found: error
build-example-ios:
name: Build example app (iOS)
runs-on: blacksmith-6vcpu-macos-latest
timeout-minutes: 45
needs:
- build-ios
- build-typescript
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
working-directory: examples/react-native
- name: Download iOS artifacts
uses: actions/download-artifact@v4
with:
name: ios-libs
path: bindings/react-native/libs/ios/
- name: Fix xcframework after artifact download
run: |
find bindings/react-native/libs/ios/turso-sync-sdk-kit.xcframework \
-name "turso-sync-sdk-kit" -type f | while read f; do
chmod +x "$f"
codesign -f -s - "$f"
done
- name: Download TypeScript build
uses: actions/download-artifact@v4
with:
name: typescript-build
path: bindings/react-native/lib/
- name: Install binding dependencies
run: npm install
working-directory: ${{ env.working-directory }}
- name: Install example app dependencies
run: npm install
working-directory: examples/react-native
- name: Install CocoaPods dependencies
run: bundle exec pod install
working-directory: examples/react-native/ios
- name: Verify xcframework
run: |
ls -la bindings/react-native/libs/ios/turso-sync-sdk-kit.xcframework/ios-arm64-simulator/turso-sync-sdk-kit.framework/
file bindings/react-native/libs/ios/turso-sync-sdk-kit.xcframework/ios-arm64-simulator/turso-sync-sdk-kit.framework/turso-sync-sdk-kit
- name: Build iOS example app
run: |
xcodebuild build \
-workspace TursoExample.xcworkspace \
-scheme TursoExample \
-sdk iphonesimulator \
-destination 'generic/platform=iOS Simulator' \
-configuration Debug \
CODE_SIGNING_ALLOWED=NO \
ARCHS=arm64 \
ONLY_ACTIVE_ARCH=YES
working-directory: examples/react-native/ios
publish:
name: Publish to npm
runs-on: ubuntu-latest
timeout-minutes: 15
needs:
- build-ios
- build-android
- build-typescript
- build-example-ios
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Update npm
run: npm install -g npm@11
- name: Download iOS artifacts
uses: actions/download-artifact@v4
with:
name: ios-libs
path: bindings/react-native/libs/ios/
- name: Download Android artifacts
uses: actions/download-artifact@v4
with:
name: android-libs
path: bindings/react-native/libs/android/
- name: Download TypeScript build
uses: actions/download-artifact@v4
with:
name: typescript-build
path: bindings/react-native/lib/
- name: Install dependencies
run: npm install
working-directory: ${{ env.working-directory }}
- name: List package contents
run: |
echo "=== Package contents ==="
ls -la
echo "=== libs/ios ==="
ls -laR libs/ios/ || echo "No iOS libs"
echo "=== libs/android ==="
ls -laR libs/android/ || echo "No Android libs"
echo "=== lib (TypeScript) ==="
ls -laR lib/ || echo "No lib"
working-directory: ${{ env.working-directory }}
- name: Publish
if: startsWith(github.ref, 'refs/tags/v')
run: |
if git log -1 --pretty=%B | grep "^Turso [0-9]\+\.[0-9]\+\.[0-9]\+$";
then
npm publish --access public --provenance
elif git log -1 --pretty=%B | grep "^Turso [0-9]\+\.[0-9]\+\.[0-9]\+";
then
npm publish --access public --provenance --tag next
else
echo "git log structure is unexpected, skip publishing"
npm publish --dry-run
fi
working-directory: ${{ env.working-directory }}
- name: Publish (dry-run)
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: npm pack
working-directory: ${{ env.working-directory }}
- name: Upload package tarball
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v4
with:
name: npm-package
path: bindings/react-native/*.tgz