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
name: Deploy P2P Apps
on:
push:
tags:
- 'v*' # Deploy on version tags (e.g., v1.0.0)
branches:
- main # Auto-deploy main branch to beta
pull_request:
branches:
- main # Test builds on PRs
workflow_dispatch: # Manual trigger
inputs:
app_name:
description: 'Specific app to deploy (or "all")'
required: true
default: 'all'
type: choice
options:
- all
- ant-connect
platform:
description: 'Platform to deploy to'
required: true
default: 'both'
type: choice
options:
- both
- ios
- android
deployment_type:
description: 'Deployment type'
required: true
default: 'beta'
type: choice
options:
- beta
- production
- dev_build
env:
FLUTTER_VERSION: '3.19.0'
RUST_VERSION: 'stable'
jobs:
changes:
runs-on: ubuntu-latest
outputs:
rust: ${{ steps.changes.outputs.rust }}
ant-connect: ${{ steps.changes.outputs.ant-connect }}
fastlane: ${{ steps.changes.outputs.fastlane }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for change detection
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
rust:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
ant-connect:
- 'apps/ant-connect/**'
fastlane:
- 'fastlane/**'
- '.github/workflows/deploy.yml'
build-rust:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.rust == 'true' || github.event_name == 'workflow_dispatch' || github.ref_type == 'tag'
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: rust-build-${{ runner.os }}
workspaces: "."
- name: Install cross-compilation tools
run: |
cargo install cargo-lipo cross --force
- name: Add Rust targets
run: |
rustup target add aarch64-apple-ios x86_64-apple-ios
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
- name: Build Rust backend
run: |
# Main release build
cargo build --release
# iOS targets (universal library)
cargo lipo --release
# Android targets
cross build --target aarch64-linux-android --release || echo "Android aarch64 build failed"
cross build --target armv7-linux-androideabi --release || echo "Android armv7 build failed"
cross build --target i686-linux-android --release || echo "Android i686 build failed"
cross build --target x86_64-linux-android --release || echo "Android x86_64 build failed"
- name: Upload Rust artifacts
uses: actions/upload-artifact@v4
with:
name: rust-libraries
path: |
target/release/
target/universal/release/
target/aarch64-linux-android/release/
target/armv7-linux-androideabi/release/
target/i686-linux-android/release/
target/x86_64-linux-android/release/
retention-days: 1
test-flutter:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.ant-connect == 'true' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- name: Test Flutter apps
run: |
for app_dir in apps/*/; do
if [ -f "$app_dir/pubspec.yaml" ]; then
echo "Testing $(basename "$app_dir")..."
cd "$app_dir"
flutter pub get
flutter analyze
flutter test || echo "Tests failed for $(basename "$app_dir")"
cd ../..
fi
done
deploy-ios:
runs-on: macos-14 # Use latest macOS runner
needs:
if: |
(github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' ||
(github.ref == 'refs/heads/main' && needs.changes.outputs.ant-connect == 'true')) &&
(github.event.inputs.platform == 'both' || github.event.inputs.platform == 'ios' || github.event.inputs.platform == '')
strategy:
matrix:
app:
steps:
- uses: actions/checkout@v4
- name: Download Rust libraries
uses: actions/download-artifact@v4
with:
name: rust-libraries
path: target/
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- name: Setup Ruby and Fastlane
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
working-directory: fastlane
- name: Install Fastlane
run: gem install fastlane
- name: Cache Fastlane
uses: actions/cache@v4
with:
path: |
~/.fastlane
~/Library/Caches/com.github.ben-z.github-actions-cache-for-bazel
key: ${{ runner.os }}-fastlane-${{ hashFiles('**/Gemfile.lock') }}
- name: Setup iOS certificates and provisioning
if: github.ref_type == 'tag' || github.event.inputs.deployment_type == 'production'
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
run: |
cd fastlane
fastlane match appstore --readonly || echo "Certificate setup failed - continuing with development build"
- name: Deploy iOS app
env:
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
APP_STORE_CONNECT_API_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
APP_STORE_CONNECT_API_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_ISSUER_ID }}
APP_STORE_CONNECT_API_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY }}
run: |
cd fastlane
# Determine deployment type
if [[ "${{ github.ref_type }}" == "tag" ]] || [[ "${{ github.event.inputs.deployment_type }}" == "production" ]]; then
echo "๐ Production deployment"
fastlane deploy_app app:${{ matrix.app }} platform:ios
elif [[ "${{ github.event.inputs.deployment_type }}" == "dev_build" ]]; then
echo "๐จ Development build"
fastlane build_dev app:${{ matrix.app }}
else
echo "๐งช Beta deployment"
fastlane beta_all
fi
deploy-android:
runs-on: ubuntu-latest
needs:
if: |
(github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' ||
(github.ref == 'refs/heads/main' && needs.changes.outputs.ant-connect == 'true')) &&
(github.event.inputs.platform == 'both' || github.event.inputs.platform == 'android' || github.event.inputs.platform == '')
strategy:
matrix:
app:
steps:
- uses: actions/checkout@v4
- name: Download Rust libraries
uses: actions/download-artifact@v4
with:
name: rust-libraries
path: target/
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- name: Setup Ruby and Fastlane
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Install Fastlane
run: gem install fastlane
- name: Setup Android signing
if: github.ref_type == 'tag' || github.event.inputs.deployment_type == 'production' || github.event.inputs.deployment_type == 'beta'
run: |
if [ -n "${{ secrets.ANDROID_KEYSTORE }}" ]; then
echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 --decode > android-keystore.jks
# Create key.properties for each app
for app_dir in apps/*/android; do
if [ -d "$app_dir" ]; then
cat > "$app_dir/key.properties" << EOF
storeFile=../../../android-keystore.jks
keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}
storePassword=${{ secrets.ANDROID_STORE_PASSWORD }}
keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}
EOF
fi
done
fi
- name: Setup Google Play Service Account
if: github.ref_type == 'tag' || github.event.inputs.deployment_type == 'production' || github.event.inputs.deployment_type == 'beta'
run: |
if [ -n "${{ secrets.GOOGLE_PLAY_JSON_KEY }}" ]; then
echo "${{ secrets.GOOGLE_PLAY_JSON_KEY }}" > google-play-key.json
echo "GOOGLE_PLAY_JSON_KEY_PATH=$(pwd)/google-play-key.json" >> $GITHUB_ENV
fi
- name: Deploy Android app
env:
GOOGLE_PLAY_JSON_KEY_PATH: ${{ env.GOOGLE_PLAY_JSON_KEY_PATH }}
run: |
cd fastlane
# Determine deployment type
if [[ "${{ github.ref_type }}" == "tag" ]] || [[ "${{ github.event.inputs.deployment_type }}" == "production" ]]; then
echo "๐ Production deployment"
fastlane deploy_app app:${{ matrix.app }} platform:android
elif [[ "${{ github.event.inputs.deployment_type }}" == "dev_build" ]]; then
echo "๐จ Development build"
fastlane build_dev app:${{ matrix.app }}
else
echo "๐งช Beta deployment"
fastlane beta_all
fi
cleanup:
runs-on: ubuntu-latest
needs:
if: always()
steps:
- name: Cleanup artifacts
if: always()
run: |
echo "Deployment completed"