-
Notifications
You must be signed in to change notification settings - Fork 0
410 lines (357 loc) · 12.8 KB
/
Copy pathflutter-release.yml
File metadata and controls
410 lines (357 loc) · 12.8 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
name: Flutter Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.0)'
required: true
default: '0.1.0'
skip_publish:
description: 'Skip publishing (for testing)'
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
jobs:
# ==========================================================================
# Step 1: Generate Dart bindings
# ==========================================================================
generate-bindings:
name: Generate Dart Bindings
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}" # Remove 'v' prefix if present
else
VERSION="${{ github.event.inputs.version }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.0'
channel: 'stable'
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
- name: Install flutter_rust_bridge_codegen
run: cargo install flutter_rust_bridge_codegen
- name: Create Flutter package structure
run: |
mkdir -p packages/fula_client/lib/src
mkdir -p packages/fula_client/android/src/main/jniLibs
mkdir -p packages/fula_client/ios
- name: Install dependencies
working-directory: packages/fula_client
run: flutter pub get
- name: Generate Dart bindings
run: |
# flutter_rust_bridge v2 - use config file from repo root
flutter_rust_bridge_codegen generate
- name: Update version in pubspec.yaml
run: |
sed -i "s/version: .*/version: ${{ steps.version.outputs.version }}/" packages/fula_client/pubspec.yaml
- name: Upload Flutter package
uses: actions/upload-artifact@v4
with:
name: flutter-package
path: packages/fula_client/
retention-days: 1
# ==========================================================================
# Step 2: Build native libraries for all platforms
# ==========================================================================
build-android:
name: Build Android
needs: generate-bindings
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: aarch64-linux-android
abi: arm64-v8a
- target: armv7-linux-androideabi
abi: armeabi-v7a
- target: x86_64-linux-android
abi: x86_64
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25c
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
key: android-${{ matrix.target }}
- name: Configure Cargo for Android
run: |
mkdir -p ~/.cargo
cat >> ~/.cargo/config.toml << EOF
[target.${{ matrix.target }}]
linker = "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.target }}24-clang"
EOF
- name: Build
run: |
# Set CC and AR for ring/rustls cross-compilation
# Convert target name to env var format (replace - with _)
TARGET_ENV=$(echo "${{ matrix.target }}" | tr '-' '_')
export CC_${TARGET_ENV}="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.target }}24-clang"
export AR_${TARGET_ENV}="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
cargo build -p fula-flutter --target ${{ matrix.target }} --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: android-${{ matrix.abi }}
path: target/${{ matrix.target }}/release/libfula_flutter.so
retention-days: 1
build-ios:
name: Build iOS
needs: generate-bindings
runs-on: macos-latest
strategy:
matrix:
include:
- target: aarch64-apple-ios
artifact: ios-arm64
- target: x86_64-apple-ios
artifact: ios-x64-sim
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
key: ios-${{ matrix.target }}
- name: Build
run: cargo build -p fula-flutter --target ${{ matrix.target }} --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: target/${{ matrix.target }}/release/libfula_flutter.a
retention-days: 1
build-wasm:
name: Build WASM
needs: generate-bindings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
key: wasm
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Build WASM
run: |
cd crates/fula-flutter
wasm-pack build --release --target web --out-dir ../../packages/fula_client_npm
- name: Create npm package.json
run: |
VERSION="${{ needs.generate-bindings.outputs.version }}"
cat > packages/fula_client_npm/package.json << EOF
{
"name": "@functionland/fula-client",
"version": "$VERSION",
"description": "Fula encrypted storage SDK for JavaScript/WASM",
"main": "fula_flutter.js",
"types": "fula_flutter.d.ts",
"files": [
"*.js",
"*.wasm",
"*.d.ts",
"snippets/**/*"
],
"keywords": [
"fula",
"storage",
"encryption",
"wasm",
"decentralized"
],
"repository": {
"type": "git",
"url": "https://github.com/functionland/fula-api.git"
},
"homepage": "https://fx.land",
"license": "MIT",
"author": "Functionland <info@fx.land>"
}
EOF
- name: Upload WASM artifact
uses: actions/upload-artifact@v4
with:
name: wasm-package
path: packages/fula_client_npm/
retention-days: 1
# ==========================================================================
# Step 3: Publish to registries
# ==========================================================================
publish-pubdev:
name: Publish to pub.dev
needs: [generate-bindings, build-android, build-ios]
runs-on: ubuntu-latest
if: ${{ !inputs.skip_publish }}
# OIDC authentication - no manual tokens needed
permissions:
id-token: write # Required for pub.dev OIDC authentication
steps:
- uses: actions/checkout@v4
- name: Download Flutter package
uses: actions/download-artifact@v4
with:
name: flutter-package
path: packages/fula_client/
- name: Download Android arm64
uses: actions/download-artifact@v4
with:
name: android-arm64-v8a
path: packages/fula_client/android/src/main/jniLibs/arm64-v8a/
- name: Download Android armv7
uses: actions/download-artifact@v4
with:
name: android-armeabi-v7a
path: packages/fula_client/android/src/main/jniLibs/armeabi-v7a/
- name: Download Android x64
uses: actions/download-artifact@v4
with:
name: android-x86_64
path: packages/fula_client/android/src/main/jniLibs/x86_64/
- name: Download iOS arm64
uses: actions/download-artifact@v4
with:
name: ios-arm64
path: packages/fula_client/ios/
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.0'
- name: Setup pub.dev OIDC credentials
uses: dart-lang/setup-dart@v1
- name: Verify package
working-directory: packages/fula_client
run: |
flutter pub get
flutter pub publish --dry-run
- name: Publish to pub.dev
working-directory: packages/fula_client
run: flutter pub publish --force
publish-npm:
name: Publish to npm
needs: [generate-bindings, build-wasm]
runs-on: ubuntu-latest
if: ${{ !inputs.skip_publish }}
steps:
- name: Download WASM package
uses: actions/download-artifact@v4
with:
name: wasm-package
path: packages/fula_client_npm/
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
working-directory: packages/fula_client_npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# ==========================================================================
# Step 4: Create GitHub Release artifacts
# ==========================================================================
github-release:
name: Upload Release Artifacts
needs: [generate-bindings, build-android, build-ios, build-wasm]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Package Android libraries
run: |
mkdir -p release
cd artifacts
zip -r ../release/android-libs.zip android-*/
- name: Package iOS libraries
run: |
cd artifacts
zip -r ../release/ios-libs.zip ios-*/
- name: Package WASM
run: |
cd artifacts
zip -r ../release/wasm-package.zip wasm-package/
- name: Package Flutter source
run: |
cd artifacts
zip -r ../release/flutter-package-source.zip flutter-package/
- name: Upload to GitHub Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
release/android-libs.zip
release/ios-libs.zip
release/wasm-package.zip
release/flutter-package-source.zip
- name: Upload artifacts (workflow_dispatch)
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: release/
retention-days: 7
# ==========================================================================
# Summary job
# ==========================================================================
release-summary:
name: Release Summary
needs: [generate-bindings, publish-pubdev, publish-npm, github-release]
runs-on: ubuntu-latest
if: always()
steps:
- name: Summary
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ needs.generate-bindings.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Publish Status" >> $GITHUB_STEP_SUMMARY
echo "- pub.dev: ${{ needs.publish-pubdev.result }}" >> $GITHUB_STEP_SUMMARY
echo "- npm: ${{ needs.publish-npm.result }}" >> $GITHUB_STEP_SUMMARY
echo "- GitHub Release: ${{ needs.github-release.result }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Usage" >> $GITHUB_STEP_SUMMARY
echo '```yaml' >> $GITHUB_STEP_SUMMARY
echo "# Flutter (pubspec.yaml)" >> $GITHUB_STEP_SUMMARY
echo "dependencies:" >> $GITHUB_STEP_SUMMARY
echo " fula_client: ^${{ needs.generate-bindings.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "# JavaScript/WASM" >> $GITHUB_STEP_SUMMARY
echo "npm install @functionland/fula-client@${{ needs.generate-bindings.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY