Repository navigation
396 lines (341 loc) · 10.6 KB
/
Copy pathbuild.yml
File metadata and controls
396 lines (341 loc) · 10.6 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
name: Build and Release
permissions:
contents: write
on:
push:
branches: [ "main" ]
tags:
- "*.*.*"
paths-ignore:
- '*.md'
pull_request:
branches: [ "main" ]
paths-ignore:
- '*.md'
jobs:
build_linux_agents:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- name: Install Android NDK and build tools
run: |
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses || true
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install \
"ndk;29.0.13113456" \
"build-tools;36.0.0" \
"platforms;android-35"
env:
ANDROID_HOME: /usr/local/lib/android/sdk
- name: Build Android agents
run: make -C agents/android all
env:
ANDROID_HOME: /usr/local/lib/android/sdk
- name: Upload Android agent binaries
uses: actions/upload-artifact@v7
with:
name: android-agents
path: |
agents/android/mobilecli-arm64-v8a.so
agents/android/mobilecli-x86_64.so
agents/android/mobilecli.dex
retention-days: 1
build_ios_agents:
runs-on: macos-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Build iOS agents
run: make -C agents/ios all
- name: Upload iOS agent binaries
uses: actions/upload-artifact@v7
with:
name: ios-agents
path: |
agents/ios/agent-sim.dylib
agents/ios/agent-dev.dylib
retention-days: 1
test:
runs-on: macos-latest
timeout-minutes: 15
needs: [build_linux_agents, build_ios_agents]
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Download Android agent binaries
uses: actions/download-artifact@v8
with:
name: android-agents
path: agents/android/
- name: Download iOS agent binaries
uses: actions/download-artifact@v8
with:
name: ios-agents
path: agents/ios/
- name: Run Unit Tests
run: |
CGO_ENABLED=0 go build -ldflags="-s -w"
go test ./... -v -race
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Check formatting
run: |
go fmt ./...
git diff --exit-code
- name: Create placeholder agent binaries for typecheck
run: touch agents/android/mobilecli-arm64-v8a.so agents/android/mobilecli-x86_64.so agents/android/mobilecli.dex agents/ios/agent-sim.dylib agents/ios/agent-dev.dylib
- name: Lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.13.1
verify: false
continue-on-error: true
security:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Security scan
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck -show verbose ./... || true
# no cgo anywhere, so one linux runner cross-compiles every platform
build:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
needs: [build_linux_agents, build_ios_agents]
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Download Android agent binaries
uses: actions/download-artifact@v8
with:
name: android-agents
path: agents/android/
- name: Download iOS agent binaries
uses: actions/download-artifact@v8
with:
name: ios-agents
path: agents/ios/
- name: Set version
if: github.ref_type == 'tag'
run: |
if [[ ! "$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid release tag format: $GITHUB_REF_NAME"
exit 1
fi
sed -i 's/Version = \"dev\"/Version = \"'"$GITHUB_REF_NAME"'\"/' utils/version.go
- name: Build
env:
CGO_ENABLED: 0
run: |
for target in darwin/arm64 darwin/amd64 linux/arm64 linux/amd64 windows/amd64 windows/arm64; do
os="${target%/*}"
arch="${target#*/}"
ext=""
if [ "$os" = "windows" ]; then
ext=".exe"
fi
GOOS="$os" GOARCH="$arch" go build -ldflags="-s -w" -o "mobilecli-$os-$arch$ext"
done
./mobilecli-linux-amd64 --version
- name: Upload macos build artifact
uses: actions/upload-artifact@v7
with:
name: macos-build
path: |
mobilecli-darwin-arm64
mobilecli-darwin-amd64
retention-days: 1
overwrite: true
- name: Upload linux build artifact
uses: actions/upload-artifact@v7
with:
name: linux-build
path: |
mobilecli-linux-arm64
mobilecli-linux-amd64
retention-days: 1
overwrite: true
- name: Upload windows build artifact
uses: actions/upload-artifact@v7
with:
name: windows-build
path: |
mobilecli-windows-amd64.exe
mobilecli-windows-arm64.exe
retention-days: 1
overwrite: true
e2e_test:
runs-on: self-hosted
timeout-minutes: 10
needs: [build]
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Download macos build
uses: actions/download-artifact@v8
with:
name: macos-build
path: .
- name: Make mobilecli executable
run: |
mv mobilecli-darwin-arm64 mobilecli
chmod +x mobilecli
- name: npm install
run: |
cd test
npm install --ignore-scripts
# run the downloaded release binary as-is, never rebuild it here: what we test
# is what publish ships. MOBILECLI_HOME keeps the daemon away from ~/.mobilecli
- name: run tests
env:
MOBILECLI_HOME: ${{ runner.temp }}/mobilecli-home
run: |
mkdir -p "$MOBILECLI_HOME"
./mobilecli --version
./mobilecli daemon stop || true
cd test && npx playwright test
- name: stop daemon
if: always()
env:
MOBILECLI_HOME: ${{ runner.temp }}/mobilecli-home
run: ./mobilecli daemon stop || true
publish:
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
id-token: write # Required for npm trusted publishing with OIDC
contents: write
needs: [build, e2e_test, test, lint, security]
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: actions/setup-node@v5
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Download darwin build
uses: actions/download-artifact@v8
with:
name: macos-build
path: mobilecli-darwin
- name: Download linux build
uses: actions/download-artifact@v8
with:
name: linux-build
path: mobilecli-linux
- name: Download windows build
uses: actions/download-artifact@v8
with:
name: windows-build
path: mobilecli-windows
- name: Zip builds
run: |
if [[ ! "$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid release tag format: $GITHUB_REF_NAME"
exit 1
fi
mkdir dist
cd dist
# macos-arm64
cp ../mobilecli-darwin/mobilecli-darwin-arm64 mobilecli
zip -9 "../mobilecli-$GITHUB_REF_NAME-macos-arm64.zip" mobilecli
rm -f mobilecli
# macos-amd64
cp ../mobilecli-darwin/mobilecli-darwin-amd64 mobilecli
zip -9 "../mobilecli-$GITHUB_REF_NAME-macos-amd64.zip" mobilecli
rm -f mobilecli
# linux-amd64
cp ../mobilecli-linux/mobilecli-linux-amd64 mobilecli
zip -9 "../mobilecli-$GITHUB_REF_NAME-linux-amd64.zip" mobilecli
rm -f mobilecli
# linux-arm64
cp ../mobilecli-linux/mobilecli-linux-arm64 mobilecli
zip -9 "../mobilecli-$GITHUB_REF_NAME-linux-arm64.zip" mobilecli
rm -f mobilecli
# windows-amd64
cp ../mobilecli-windows/mobilecli-windows-amd64.exe mobilecli.exe
zip -9 "../mobilecli-$GITHUB_REF_NAME-windows-amd64.zip" mobilecli.exe
rm -f mobilecli.exe
# windows-arm64
cp ../mobilecli-windows/mobilecli-windows-arm64.exe mobilecli.exe
zip -9 "../mobilecli-$GITHUB_REF_NAME-windows-arm64.zip" mobilecli.exe
rm -f mobilecli.exe
cd ..
ls -l *.zip
rm -rf dist
- name: Extract release notes from CHANGELOG.md
run: awk -v tag="$GITHUB_REF_NAME" '/^## \[/{f = ($0 ~ "^## \\[" tag "\\]")} f' CHANGELOG.md > release-notes.md
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.RELEASES_TOKEN }}
with:
name: Version ${{ github.ref_name }}
body_path: release-notes.md
files: |
mobilecli-*.zip
- name: Publish
run: |
# publish platform-specific packages
for platform in darwin-arm64 darwin-amd64 linux-arm64 linux-amd64 windows-amd64 windows-arm64; do
os="${platform%-*}"
binary="mobilecli-$platform"
if [ "$os" = "windows" ]; then
binary="$binary.exe"
fi
cp "mobilecli-$os/$binary" "publish/npm-$platform/"
chmod +x "publish/npm-$platform/$binary"
cd "publish/npm-$platform"
npm version "$GITHUB_REF_NAME" --no-git-tag-version
npm publish --access public --provenance
cd ../..
done
# publish main package (wrapper)
cp README.md publish/npm
cd publish/npm
npm version "$GITHUB_REF_NAME" --no-git-tag-version
for platform in darwin-arm64 darwin-amd64 linux-arm64 linux-amd64 windows-amd64 windows-arm64; do
npm pkg set "optionalDependencies.@mobilenext/mobilecli-$platform=$GITHUB_REF_NAME"
done
npm publish --access public --provenance