-
-
Notifications
You must be signed in to change notification settings - Fork 255
323 lines (280 loc) · 10.9 KB
/
Copy pathflutter-build.yml
File metadata and controls
323 lines (280 loc) · 10.9 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
name: Build OpenClaw Apps
on:
push:
branches: ['*']
paths:
- 'flutter_app/**'
- 'scripts/fetch-proot-binaries.sh'
- 'scripts/build-apk.sh'
- '.github/workflows/flutter-build.yml'
pull_request:
branches: [main]
paths:
- 'flutter_app/**'
- 'scripts/fetch-proot-binaries.sh'
- 'scripts/build-apk.sh'
- '.github/workflows/flutter-build.yml'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
build:
name: Build APK & AAB
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.0'
channel: stable
cache: true
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('flutter_app/android/**/*.gradle*', 'flutter_app/android/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}-
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: |
~/.pub-cache
flutter_app/.dart_tool
key: pub-${{ runner.os }}-${{ hashFiles('flutter_app/pubspec.lock') }}
restore-keys: pub-${{ runner.os }}-
- name: Setup signing
if: env.KEYSTORE_BASE64 != ''
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
echo "$KEYSTORE_BASE64" | base64 -d > "${{ github.workspace }}/release.jks"
cat > flutter_app/android/key.properties <<EOF
storePassword=$KEYSTORE_PASSWORD
keyPassword=$KEY_PASSWORD
keyAlias=$KEY_ALIAS
storeFile=${{ github.workspace }}/release.jks
EOF
sed -i 's/^[[:space:]]*//' flutter_app/android/key.properties
- name: Fetch PRoot binaries
run: bash scripts/fetch-proot-binaries.sh
- name: Verify PRoot binaries
run: |
echo "Checking jniLibs contents..."
for abi in arm64-v8a armeabi-v7a x86_64; do
for lib in libproot.so libprootloader.so; do
FILE="flutter_app/android/app/src/main/jniLibs/${abi}/${lib}"
if [ ! -f "$FILE" ]; then
echo "ERROR: Missing $FILE"
exit 1
fi
SIZE=$(stat -c%s "$FILE")
if [ "$SIZE" -lt 1000 ]; then
echo "WARN: $FILE looks like a placeholder (${SIZE} bytes)"
else
echo "OK: $FILE (${SIZE} bytes)"
fi
done
done
- name: Get Flutter dependencies
working-directory: flutter_app
run: flutter pub get
- name: Analyze Dart code
working-directory: flutter_app
run: flutter analyze --no-fatal-infos
continue-on-error: true
- name: Build fat APK (all ABIs)
working-directory: flutter_app
run: flutter build apk --release
- name: Build per-ABI APKs
working-directory: flutter_app
run: flutter build apk --release --split-per-abi
- name: Build AAB (App Bundle)
working-directory: flutter_app
run: flutter build appbundle --release
- name: Rename and collect artifacts
id: apks
run: |
VERSION=$(grep '^version:' flutter_app/pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
mkdir -p artifacts
# Fat APK
cp flutter_app/build/app/outputs/flutter-apk/app-release.apk \
"artifacts/OpenClaw-v${VERSION}-universal.apk"
# Per-ABI APKs
for abi in arm64-v8a armeabi-v7a x86_64; do
SRC="flutter_app/build/app/outputs/flutter-apk/app-${abi}-release.apk"
if [ -f "$SRC" ]; then
cp "$SRC" "artifacts/OpenClaw-v${VERSION}-${abi}.apk"
fi
done
# AAB
AAB="flutter_app/build/app/outputs/bundle/release/app-release.aab"
if [ -f "$AAB" ]; then
cp "$AAB" "artifacts/OpenClaw-v${VERSION}.aab"
fi
# Summary
echo "### Build Artifacts" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| File | Size |" >> "$GITHUB_STEP_SUMMARY"
echo "|------|------|" >> "$GITHUB_STEP_SUMMARY"
for f in artifacts/*; do
SIZE=$(du -h "$f" | cut -f1)
echo "| \`$(basename $f)\` | $SIZE |" >> "$GITHUB_STEP_SUMMARY"
done
echo "Built artifacts:"
ls -lh artifacts/
- name: Upload APK artifacts
uses: actions/upload-artifact@v4
with:
name: openclaw-apks
path: artifacts/*.apk
retention-days: 30
- name: Upload AAB artifact
uses: actions/upload-artifact@v4
with:
name: openclaw-aab
path: artifacts/*.aab
retention-days: 30
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const version = '${{ steps.apks.outputs.version }}';
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const body = [
`## Build Successful`,
``,
`**Version:** \`v${version}\``,
``,
`### Download APKs`,
``,
`| Architecture | Download |`,
`|---|---|`,
`| arm64-v8a (recommended) | [OpenClaw-v${version}-arm64-v8a.apk](${runUrl}#artifacts) |`,
`| armeabi-v7a (32-bit) | [OpenClaw-v${version}-armeabi-v7a.apk](${runUrl}#artifacts) |`,
`| x86_64 (emulator) | [OpenClaw-v${version}-x86_64.apk](${runUrl}#artifacts) |`,
`| Universal (all ABIs) | [OpenClaw-v${version}-universal.apk](${runUrl}#artifacts) |`,
`| App Bundle (Play Store) | [OpenClaw-v${version}.aab](${runUrl}#artifacts) |`,
``,
`> Download from [**Actions Artifacts**](${runUrl}#artifacts)`,
``,
`---`,
`*Built from ${process.env.GITHUB_SHA.substring(0, 7)} by [GitHub Actions](${runUrl})*`,
].join('\n');
// Find existing bot comment to update instead of spamming
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('## Build Successful')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
- name: Comment build failure on PR
if: github.event_name == 'pull_request' && failure()
uses: actions/github-script@v7
with:
script: |
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: [
`## Build Failed`,
``,
`The build failed for commit ${process.env.GITHUB_SHA.substring(0, 7)}.`,
``,
`[View build logs](${runUrl})`,
].join('\n'),
});
release:
name: Create GitHub Release
needs: [build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download APK artifacts
uses: actions/download-artifact@v4
with:
name: openclaw-apks
path: artifacts
- name: Download AAB artifact
uses: actions/download-artifact@v4
with:
name: openclaw-aab
path: artifacts
- name: Get version
id: version
run: |
VERSION=$(grep '^version:' flutter_app/pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Check if this tag already exists
if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q .; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create Release
if: steps.version.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: OpenClaw v${{ steps.version.outputs.version }}
body: |
## OpenClaw Android v${{ steps.version.outputs.version }}
Standalone Android app — no Termux required.
### Downloads
| File | Description |
|------|-------------|
| `OpenClaw-v${{ steps.version.outputs.version }}-arm64-v8a.apk` | Most modern Android phones (recommended) |
| `OpenClaw-v${{ steps.version.outputs.version }}-armeabi-v7a.apk` | Older 32-bit ARM devices |
| `OpenClaw-v${{ steps.version.outputs.version }}-x86_64.apk` | Emulators / x86 devices |
| `OpenClaw-v${{ steps.version.outputs.version }}-universal.apk` | All architectures (larger) |
| `OpenClaw-v${{ steps.version.outputs.version }}.aab` | Android App Bundle (Play Store) |
### First Run
1. Install the APK
2. Follow the setup wizard (downloads ~500MB Ubuntu rootfs)
3. Start the gateway from the dashboard
4. Access the web dashboard at `http://127.0.0.1:18789`
### Requirements
- Android 10+ (API 29)
- ~500MB free storage for initial setup
- Internet connection for first-time setup
files: artifacts/*
draft: false
prerelease: false