Repository navigation
818 lines (741 loc) · 36 KB
/
Copy pathandroid.yml
File metadata and controls
818 lines (741 loc) · 36 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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
name: Android CI
# Docs-only changes don't build. Store texts (fastlane/) are NOT ignored: StoreMetadataTest
# checks them. A change that also touches anything else runs CI as usual.
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- 'docs/**'
- 'LICENSE'
- '.github/ISSUE_TEMPLATE/**'
pull_request:
paths-ignore:
- '**.md'
- 'docs/**'
- 'LICENSE'
- '.github/ISSUE_TEMPLATE/**'
workflow_dispatch:
# Only the newest run per branch / PR matters; cancel superseded ones.
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# The checks run as three parallel jobs (app, libraries, release build) rather than one long Gradle
# invocation; fdroid flavor only, the play flavor differs only in store flags and is built by the
# release workflow. The instrumented tests run in the `instrumented` job below.
build:
name: app (format, unit tests, coverage, detekt)
# Dependabot bumps (build(deps) / ci(deps)) don't run CI on their own PR: they are merged in
# batches and checked on the branch that takes them, or on main after the merge.
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
pull-requests: write # only for the coverage comment
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Format, unit tests, coverage, detekt
run: >-
./gradlew spotlessCheck
:app:testFdroidDebugUnitTest
:app:koverXmlReportFdroidDebug
:app:koverVerifyFdroidDebug
:app:detekt
# For information only: posts (and keeps updating) one PR comment with the app
# coverage. It never fails the build.
- name: Coverage comment
if: github.event_name == 'pull_request'
continue-on-error: true
uses: madrapps/jacoco-report@e51ce1f46f7f8b5331593f935e59cbaf44b84920 # v1.8.0
with:
paths: app/build/reports/kover/reportFdroidDebug.xml
token: ${{ secrets.GITHUB_TOKEN }}
title: 'Coverage'
update-comment: true
min-coverage-overall: 0
min-coverage-changed-files: 0
- name: Upload reports on failure
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: reports-app
path: |
app/build/reports/
app/build/test-results/
retention-days: 7
if-no-files-found: ignore
# The Kotlin Multiplatform libraries on their desktop JVM and Android host targets: unit tests, the
# Kover gates, detekt and the public API dump (and Dokka for :editor). The database's desktop tests
# open and migrate an encrypted vault through Sealite's native library. Their iOS targets compile in
# the `editor-ios` job below, which also builds the iOS app around :shared (the domain, the data logic and
# the whole UI). Its Compose UI tests run under Robolectric in testAndroidHostTest; it has no public API to
# dump.
modules:
name: libraries (tests, coverage, detekt, API)
# Dependabot bumps (build(deps) / ci(deps)) don't run CI on their own PR: they are merged in
# batches and checked on the branch that takes them, or on main after the merge.
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
# The desktop app's tests open real AWT windows (capture exclusion, window hooks), so they run under a
# virtual X display.
- name: Virtual display for the desktop tests
run: sudo apt-get update && sudo apt-get install -y xvfb
- name: Library checks
run: >-
xvfb-run --auto-servernum ./gradlew
:editor:desktopTest
:editor:testAndroidHostTest
:editor:koverVerify
:editor:koverVerifyEditorLogic
:editor:detekt
:editor:checkKotlinAbi
:editor:dokkaGeneratePublicationHtml
:core:common:desktopTest
:core:common:testAndroidHostTest
:core:common:koverVerify
:core:common:detekt
:core:common:checkKotlinAbi
:core:crypto:desktopTest
:core:crypto:testAndroidHostTest
:core:crypto:koverVerify
:core:crypto:detekt
:core:crypto:checkKotlinAbi
:core:security:desktopTest
:core:security:testAndroidHostTest
:core:security:koverVerify
:core:security:detekt
:core:security:checkKotlinAbi
:core:keystore:desktopTest
:core:keystore:detekt
:core:keystore:koverVerify
:core:keystore:checkKotlinAbi
:core:database:desktopTest
:core:database:testAndroidHostTest
:core:database:koverVerify
:core:database:detekt
:core:database:checkKotlinAbi
:core:resources:desktopTest
:core:resources:testAndroidHostTest
:shared:desktopTest
:shared:testAndroidHostTest
:shared:koverVerify
:shared:detekt
:desktopApp:desktopTest
:desktopApp:koverVerify
:desktopApp:detekt
- name: Upload reports on failure
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: reports-libraries
path: |
editor/build/reports/
editor/build/test-results/
core/*/build/reports/
core/*/build/test-results/
shared/build/reports/
shared/build/test-results/
desktopApp/build/reports/
desktopApp/build/test-results/
retention-days: 7
if-no-files-found: ignore
# The desktop installers: MSI (Windows), DMG (macOS) and DEB (Linux), each built on its own OS since jpackage
# cannot cross-build, plus a Flatpak bundle on Linux. They are signed (macOS: Developer ID, hardened runtime,
# notarized and stapled; Windows: the MSI with signtool) only when the signing secrets exist and the run is not
# a pull request; otherwise they stay unsigned, as before, and the artifact name keeps `-unsigned`. Partly set
# secrets fail the job. The secrets and what they are: desktopApp/README.md, "Signing the desktop installers".
# The DEB and the Flatpak bundle are not code-signed on any path (a Linux release is signed by the repository
# or the store that serves it), so their artifacts always say `-unsigned`.
desktop-package:
name: desktop installer (${{ matrix.os }})
if: github.actor != 'dependabot[bot]'
runs-on: ${{ matrix.os }}
timeout-minutes: 60
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, task: packageDeb, pattern: 'desktopApp/build/compose/binaries/main/deb/*.deb' }
- { os: windows-latest, task: packageMsi, pattern: 'desktopApp/build/compose/binaries/main/msi/*.msi' }
- { os: macos-15, task: packageDmg, pattern: 'desktopApp/build/compose/binaries/main/dmg/*.dmg' }
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
# Decides whether this run signs, from which secrets exist. `secrets` cannot be used in an `if:`, so the
# secrets are read into this one step's environment and the result goes out as step outputs. A pull request
# never signs (its code must not run with the certificates). Some of a group set and some not is an error,
# never a silent unsigned build.
- name: Signing
id: signing
env:
EVENT_NAME: ${{ github.event_name }}
ENCLY_MACOS_CERT_P12_BASE64: ${{ secrets.ENCLY_MACOS_CERT_P12_BASE64 }}
ENCLY_MACOS_CERT_PASSWORD: ${{ secrets.ENCLY_MACOS_CERT_PASSWORD }}
ENCLY_MACOS_SIGN_IDENTITY: ${{ secrets.ENCLY_MACOS_SIGN_IDENTITY }}
ENCLY_MACOS_NOTARY_APPLE_ID: ${{ secrets.ENCLY_MACOS_NOTARY_APPLE_ID }}
ENCLY_MACOS_NOTARY_PASSWORD: ${{ secrets.ENCLY_MACOS_NOTARY_PASSWORD }}
ENCLY_MACOS_NOTARY_TEAM_ID: ${{ secrets.ENCLY_MACOS_NOTARY_TEAM_ID }}
ENCLY_WINDOWS_CERT_PFX_BASE64: ${{ secrets.ENCLY_WINDOWS_CERT_PFX_BASE64 }}
ENCLY_WINDOWS_CERT_PASSWORD: ${{ secrets.ENCLY_WINDOWS_CERT_PASSWORD }}
run: |
set -euo pipefail
# none / all / partial, for the secrets named in the arguments
state() {
local set=0 total=0 name
for name in "$@"; do
total=$((total + 1))
if [ -n "${!name:-}" ]; then set=$((set + 1)); fi
done
if [ "$set" -eq 0 ]; then echo none; elif [ "$set" -eq "$total" ]; then echo all; else echo partial; fi
}
signed=false
notarize=false
if [ "$EVENT_NAME" = pull_request ]; then
echo "::notice::Pull request: the installer is not signed."
elif [ "$RUNNER_OS" = macOS ]; then
cert=$(state ENCLY_MACOS_CERT_P12_BASE64 ENCLY_MACOS_CERT_PASSWORD ENCLY_MACOS_SIGN_IDENTITY)
notary=$(state ENCLY_MACOS_NOTARY_APPLE_ID ENCLY_MACOS_NOTARY_PASSWORD ENCLY_MACOS_NOTARY_TEAM_ID)
if [ "$cert" = partial ] || [ "$notary" = partial ] || { [ "$notary" = all ] && [ "$cert" != all ]; }; then
echo "::error::Incomplete macOS signing secrets (certificate: $cert, notarization: $notary). Set all of a group or none; notarization needs the certificate."
exit 1
fi
if [ "$cert" = all ]; then signed=true; fi
if [ "$notary" = all ]; then notarize=true; fi
if [ "$signed" = false ]; then echo "::notice::No macOS signing secrets: the DMG is not signed."; fi
if [ "$signed" = true ] && [ "$notarize" = false ]; then echo "::warning::Signed but not notarized: Gatekeeper will still warn."; fi
elif [ "$RUNNER_OS" = Windows ]; then
cert=$(state ENCLY_WINDOWS_CERT_PFX_BASE64 ENCLY_WINDOWS_CERT_PASSWORD)
if [ "$cert" = partial ]; then
echo "::error::Incomplete Windows signing secrets. Set ENCLY_WINDOWS_CERT_PFX_BASE64 and ENCLY_WINDOWS_CERT_PASSWORD, or neither."
exit 1
fi
if [ "$cert" = all ]; then signed=true; else echo "::notice::No Windows signing secrets: the MSI is not signed."; fi
fi
suffix=-unsigned
if [ "$RUNNER_OS" != Linux ] && [ "$signed" = true ]; then suffix=''; fi
{
echo "signed=$signed"
echo "notarize=$notarize"
echo "suffix=$suffix"
} >> "$GITHUB_OUTPUT"
# jpackage builds a .deb with dpkg-deb and fakeroot.
- name: Linux packaging tools
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y fakeroot
# macOS: the Developer ID certificate goes into a keychain of its own that exists for this job only
# (random password, masked) and is deleted again in the last step. Nothing is written to the repository.
- name: Import the signing certificate (macOS)
if: runner.os == 'macOS' && steps.signing.outputs.signed == 'true'
env:
CERT_P12_BASE64: ${{ secrets.ENCLY_MACOS_CERT_P12_BASE64 }}
CERT_PASSWORD: ${{ secrets.ENCLY_MACOS_CERT_PASSWORD }}
SIGN_IDENTITY: ${{ secrets.ENCLY_MACOS_SIGN_IDENTITY }}
run: |
set -euo pipefail
keychain="$RUNNER_TEMP/encly-signing.keychain-db"
keychain_password=$(openssl rand -base64 24)
echo "::add-mask::$keychain_password"
printf '%s' "$CERT_P12_BASE64" | base64 --decode > "$RUNNER_TEMP/encly-signing.p12"
security create-keychain -p "$keychain_password" "$keychain"
security set-keychain-settings -lut 21600 "$keychain"
security unlock-keychain -p "$keychain_password" "$keychain"
security import "$RUNNER_TEMP/encly-signing.p12" -P "$CERT_PASSWORD" -t cert -f pkcs12 \
-T /usr/bin/codesign -T /usr/bin/security -k "$keychain" > /dev/null
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$keychain_password" "$keychain" > /dev/null
rm -f "$RUNNER_TEMP/encly-signing.p12"
# The keychain must be on the search list for codesign to find the chain.
keychains=("$keychain")
while IFS= read -r existing; do
keychains+=("$existing")
done < <(security list-keychains -d user | sed 's/^[[:space:]]*"//; s/"$//')
security list-keychains -d user -s "${keychains[@]}"
if ! security find-identity -v -p codesigning "$keychain" | grep -qF "$SIGN_IDENTITY"; then
echo "::error::The certificate has no code-signing identity named like ENCLY_MACOS_SIGN_IDENTITY."
exit 1
fi
echo "ENCLY_MACOS_KEYCHAIN=$keychain" >> "$GITHUB_ENV"
- name: Package
if: runner.os != 'macOS' || steps.signing.outputs.signed != 'true'
run: ./gradlew :desktopApp:${{ matrix.task }}
# Gradle signs the app image (every binary, hardened runtime, desktopApp/packaging/macos/entitlements.plist)
# and the DMG; notarizeDmg submits it to Apple with notarytool, waits, and staples the ticket.
- name: Package, sign and notarize (macOS)
if: runner.os == 'macOS' && steps.signing.outputs.signed == 'true'
env:
ENCLY_MACOS_SIGN_IDENTITY: ${{ secrets.ENCLY_MACOS_SIGN_IDENTITY }}
ENCLY_MACOS_NOTARY_APPLE_ID: ${{ secrets.ENCLY_MACOS_NOTARY_APPLE_ID }}
ENCLY_MACOS_NOTARY_PASSWORD: ${{ secrets.ENCLY_MACOS_NOTARY_PASSWORD }}
ENCLY_MACOS_NOTARY_TEAM_ID: ${{ secrets.ENCLY_MACOS_NOTARY_TEAM_ID }}
NOTARIZE: ${{ steps.signing.outputs.notarize }}
run: |
set -euo pipefail
tasks=(:desktopApp:packageDmg)
if [ "$NOTARIZE" = true ]; then tasks+=(:desktopApp:notarizeDmg); fi
./gradlew "${tasks[@]}"
# A signed build that Gatekeeper would reject must fail here, not at the first user.
- name: Verify the signature (macOS)
if: runner.os == 'macOS' && steps.signing.outputs.signed == 'true'
env:
NOTARIZE: ${{ steps.signing.outputs.notarize }}
run: |
set -euo pipefail
dmg=$(ls desktopApp/build/compose/binaries/main/dmg/*.dmg)
mount="$RUNNER_TEMP/encly-dmg"
mkdir -p "$mount"
hdiutil attach "$dmg" -nobrowse -readonly -mountpoint "$mount" > /dev/null
trap 'hdiutil detach "$mount" -quiet || true' EXIT
app=$(ls -d "$mount"/*.app)
codesign --verify --deep --strict --verbose=2 "$app"
if [ "$NOTARIZE" = true ]; then
xcrun stapler validate "$dmg"
spctl --assess --type execute --verbose=2 "$app"
fi
# Windows: signtool, from the Windows SDK on the runner, signs the MSI with the PFX and a timestamp, so the
# signature outlives the certificate. The PFX exists on disk only for this step.
- name: Sign the MSI (Windows)
if: runner.os == 'Windows' && steps.signing.outputs.signed == 'true'
env:
PFX_BASE64: ${{ secrets.ENCLY_WINDOWS_CERT_PFX_BASE64 }}
PFX_PASSWORD: ${{ secrets.ENCLY_WINDOWS_CERT_PASSWORD }}
TIMESTAMP_URL: ${{ vars.ENCLY_WINDOWS_TIMESTAMP_URL || 'http://timestamp.digicert.com' }}
MSYS2_ARG_CONV_EXCL: '*'
run: |
set -euo pipefail
pfx="$RUNNER_TEMP/encly-signing.pfx"
printf '%s' "$PFX_BASE64" | base64 --decode > "$pfx"
signtool=$(find "/c/Program Files (x86)/Windows Kits/10/bin" -path '*/x64/signtool.exe' | sort -V | tail -n 1)
if [ -z "$signtool" ]; then
echo "::error::signtool.exe not found on the runner"
exit 1
fi
msi=$(ls desktopApp/build/compose/binaries/main/msi/*.msi)
"$signtool" sign /f "$(cygpath -w "$pfx")" /p "$PFX_PASSWORD" /fd SHA256 \
/tr "$TIMESTAMP_URL" /td SHA256 /d "Encly" "$(cygpath -w "$msi")"
"$signtool" verify /pa /v "$(cygpath -w "$msi")"
- name: Upload the installer
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: encly-desktop-${{ matrix.os }}${{ steps.signing.outputs.suffix }}
path: ${{ matrix.pattern }}
retention-days: 14
if-no-files-found: error
# Linux only: the Flatpak bundle (desktopApp/packaging/flatpak). flatpak-builder installs the freedesktop
# runtime from Flathub; ubuntu-latest restricts unprivileged user namespaces, which bubblewrap needs.
- name: Flatpak tooling
if: runner.os == 'Linux'
run: |
set -euo pipefail
sudo apt-get install -y flatpak flatpak-builder appstream desktop-file-utils libxml2-utils
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 || true
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
- name: App image
if: runner.os == 'Linux'
run: ./gradlew :desktopApp:createDistributable
- name: Flatpak
if: runner.os == 'Linux'
env:
ENCLY_FLATPAK_SKIP_GRADLE: '1'
ENCLY_FLATPAK_REQUIRE_LINT: '1'
run: desktopApp/packaging/flatpak/build.sh
# For information only: Flathub's linter. It expects a source build and screenshots, so it reports things
# that do not apply to this bundle; it never fails the job.
- name: Flatpak lint
if: runner.os == 'Linux'
continue-on-error: true
run: |
flatpak install --user -y flathub org.flatpak.Builder
flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest desktopApp/packaging/flatpak/io.github.pasichdev.Encly.yml
flatpak run --command=flatpak-builder-lint org.flatpak.Builder repo desktopApp/build/flatpak/repo
- name: Upload the Flatpak bundle
if: runner.os == 'Linux'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: encly-desktop-flatpak-unsigned
path: desktopApp/build/flatpak/*.flatpak
retention-days: 14
if-no-files-found: error
# Whatever happened above, the certificate does not stay on the runner.
- name: Remove the signing material
if: always()
run: |
rm -f "$RUNNER_TEMP/encly-signing.p12" "$RUNNER_TEMP/encly-signing.pfx"
if [ "$RUNNER_OS" = macOS ]; then
security delete-keychain "$RUNNER_TEMP/encly-signing.keychain-db" 2> /dev/null || true
fi
release:
name: release build (R8, lint, manifest)
# Dependabot bumps (build(deps) / ci(deps)) don't run CI on their own PR: they are merged in
# batches and checked on the branch that takes them, or on main after the merge.
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Release build
run: ./gradlew :app:assembleFdroidRelease
# Separate invocation: lint running alongside Metro code generation for another variant has
# raced on generated sources; after the build it reads finished outputs.
- name: Lint (release)
run: ./gradlew :app:lintFdroidRelease
- name: Check merged manifest has no INTERNET permission
run: |
set -euo pipefail
# AGP has used both directory names; a check that finds no manifest must fail, not pass.
manifests=$(find app/build/intermediates/merged_manifest app/build/intermediates/merged_manifests \
-name AndroidManifest.xml -path '*fdroidRelease*' 2>/dev/null || true)
if [ -z "$manifests" ]; then
echo "::error::No merged fdroidRelease manifest found to check"
exit 1
fi
found=0
for m in $manifests; do
echo "Checking $m"
if grep -q 'android.permission.INTERNET' "$m"; then
echo "::error file=$m::INTERNET permission found in merged release manifest"
found=1
fi
done
exit $found
# The exact set, not only "no INTERNET": a library that starts asking for a permission, or a new
# <uses-permission> in the app, must be a decision. Change the list below on purpose, in the same commit.
- name: Check merged manifest permission set
run: |
set -euo pipefail
manifests=$(find app/build/intermediates/merged_manifest app/build/intermediates/merged_manifests \
-name AndroidManifest.xml -path '*fdroidRelease*' 2>/dev/null || true)
if [ -z "$manifests" ]; then
echo "::error::No merged fdroidRelease manifest found to check"
exit 1
fi
expected=$(printf '%s\n' \
android.permission.HIDE_OVERLAY_WINDOWS \
android.permission.USE_BIOMETRIC \
android.permission.USE_FINGERPRINT \
com.pasich.encly.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION | sort)
status=0
for m in $manifests; do
actual=$(grep -oE '<uses-permission[^>]*android:name="[^"]+"' "$m" \
| sed -E 's/.*android:name="([^"]+)"/\1/' | sort -u)
echo "Permissions in $m:"
echo "$actual"
if [ "$actual" != "$expected" ]; then
echo "::error file=$m::Merged release permissions differ from the pinned set"
diff <(echo "$expected") <(echo "$actual") || true
status=1
fi
done
exit $status
- name: Upload reports on failure
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: reports-release
path: |
app/build/reports/
retention-days: 7
if-no-files-found: ignore
# The KMP libraries with iOS targets compile for iOS here. Kotlin/Native compiles for Apple targets only on
# macOS, so this job builds the iOS klibs there (for the database, Room's KSP runs for the iOS targets too).
# The crypto, security and key store tests run on the iOS simulator: the AES-GCM bridge to CryptoKit and
# the golden vectors of every vault and backup format must give the JVM's bytes. So do the common tests of
# :shared (the ViewModels, the formatters), which also exercise the iOS actuals of dates and Unicode. The
# last step builds the iOS app (iosApp/) for the Simulator, unsigned: the Xcode project links the static
# framework that Gradle builds from :shared. The job keeps its name so that the name of the check does not change.
# F-Droid builds the fdroid flavor from the tag on its own server and publishes it only when its APK
# is byte for byte the one on the GitHub release (fdroiddata: Binaries + AllowedAPKSigningKeys). Two
# builds of the same commit in different directories, without the build cache, must give identical
# unsigned APKs; a path or machine value that leaks into the output would stop every F-Droid update.
fdroid-reproducible:
name: fdroid build reproducible
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: first
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: elsewhere/second
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
with:
build-root-directory: first
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
# The release workflow's command, no build cache, no shared daemon, and a Gradle home of its own for the
# second build, so it downloads and transforms every dependency again.
- name: Build twice
run: |
set -euo pipefail
(cd first && chmod +x ./gradlew && ./gradlew --no-daemon --no-build-cache --no-configuration-cache \
:app:assembleRelease)
(cd elsewhere/second && chmod +x ./gradlew && GRADLE_USER_HOME="$RUNNER_TEMP/gradle-home-2" \
./gradlew --no-daemon --no-build-cache --no-configuration-cache :app:assembleRelease)
- name: Compare the APKs
run: |
set -euo pipefail
a=$(ls first/app/build/outputs/apk/fdroid/release/*.apk)
b=$(ls elsewhere/second/app/build/outputs/apk/fdroid/release/*.apk)
if cmp -s "$a" "$b"; then
echo "Identical: $(sha256sum "$a" | cut -d' ' -f1)"
exit 0
fi
echo "::error::The two fdroid release builds differ; F-Droid would not publish this version."
python3 - "$a" "$b" <<'PY'
import hashlib, sys, zipfile
def entries(path):
with zipfile.ZipFile(path) as z:
return {i.filename: hashlib.sha256(z.read(i)).hexdigest() for i in z.infolist()}
a, b = entries(sys.argv[1]), entries(sys.argv[2])
for name in sorted(set(a) | set(b)):
if a.get(name) != b.get(name):
print("differs:", name)
PY
exit 1
editor-ios:
if: github.actor != 'dependabot[bot]'
name: editor (iOS compile)
runs-on: macos-15
timeout-minutes: 75
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Compile the iOS targets
run: >-
./gradlew
:editor:compileKotlinIosSimulatorArm64
:editor:compileKotlinIosArm64
:core:common:compileKotlinIosSimulatorArm64
:core:common:compileKotlinIosArm64
:core:database:compileKotlinIosSimulatorArm64
:core:database:compileKotlinIosArm64
:core:resources:compileKotlinIosSimulatorArm64
:core:resources:compileKotlinIosArm64
:core:crypto:compileKotlinIosArm64
:core:security:compileKotlinIosArm64
:core:keystore:compileKotlinIosArm64
:shared:compileKotlinIosSimulatorArm64
:shared:compileKotlinIosArm64
- name: iOS tests (crypto, security, key store, database, editor, shared)
run: >-
./gradlew
:core:crypto:iosSimulatorArm64Test
:core:security:iosSimulatorArm64Test
:core:keystore:iosSimulatorArm64Test
:core:database:iosSimulatorArm64Test
:editor:iosSimulatorArm64Test
:shared:iosSimulatorArm64Test
# On a Mac the klib dump of the public API is made from the real iOS klibs (elsewhere it is
# inferred), so this is where editor/api/editor.klib.api and core/common/api/common.klib.api
# are really checked.
- name: Public API dump
run: >-
./gradlew :editor:checkKotlinAbi :core:common:checkKotlinAbi :core:database:checkKotlinAbi
:core:crypto:checkKotlinAbi :core:security:checkKotlinAbi :core:keystore:checkKotlinAbi
# The app itself, for the Simulator and without signing. The first build phase of the project runs
# Gradle (`:shared:embedAndSignAppleFrameworkForXcode`), which links the framework.
- name: Build the iOS app (Simulator, unsigned)
run: >-
xcodebuild
-project iosApp/iosApp.xcodeproj
-scheme iosApp
-sdk iphonesimulator
-destination 'generic/platform=iOS Simulator'
CODE_SIGNING_ALLOWED=NO
build
# The desktop PIN factor against the real secret store of each OS: DPAPI on Windows, the login Keychain on
# macOS, the freedesktop Secret Service (GNOME Keyring) on Linux. The unit tests of :core:keystore run in
# the `build` job; here ENCLY_KEYSTORE_IT=1 turns on the one test per OS that creates, reads, uses and
# deletes a secret in the real store (under a test namespace). --rerun: the test result must not come
# from the build cache of a run without the variable.
keystore-it:
if: github.actor != 'dependabot[bot]'
name: keystore (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-15, ubuntu-latest]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
# A headless Secret Service: a private session bus, GNOME Keyring started on it with the login keyring
# created and unlocked with a throw-away password (read from stdin), then the Gradle run inside that
# same bus session. The probe fails the job early, and readably, if no Secret Service answers.
- name: Keystore tests (Linux, Secret Service)
if: runner.os == 'Linux'
env:
ENCLY_KEYSTORE_IT: '1'
run: |
sudo apt-get update
sudo apt-get install -y gnome-keyring dbus-x11 libsecret-tools
dbus-run-session -- bash -euo pipefail -c '
printf "%s" "ci-throwaway-keyring-password" | gnome-keyring-daemon --replace --daemonize --unlock --components=secrets > /dev/null
printf "probe" | secret-tool store --label="probe" application encly-ci-probe
secret-tool lookup application encly-ci-probe
secret-tool clear application encly-ci-probe
./gradlew :core:keystore:desktopTest --rerun
'
- name: Keystore tests (Windows, macOS)
if: runner.os != 'Linux'
env:
ENCLY_KEYSTORE_IT: '1'
run: ./gradlew :core:keystore:desktopTest --rerun
# RealBackendTest skips every OS but the runner's own: exactly one of its tests must have run here,
# so a backend that silently skipped (wrong OS detection, variable not passed) fails the job.
- name: The real secret store was exercised
run: |
report=core/keystore/build/test-results/desktopTest/TEST-com.pasich.encly.core.keystore.RealBackendTest.xml
test -f "$report"
tests=$(grep -o 'tests="[0-9]*"' "$report" | head -1 | tr -dc 0-9)
skipped=$(grep -o 'skipped="[0-9]*"' "$report" | head -1 | tr -dc 0-9)
failures=$(grep -o 'failures="[0-9]*"' "$report" | head -1 | tr -dc 0-9)
echo "RealBackendTest: tests=$tests skipped=$skipped failures=$failures"
if [ $((tests - skipped)) -lt 1 ] || [ "$failures" != "0" ]; then
echo "::error::RealBackendTest did not run against the ${{ runner.os }} secret store"
exit 1
fi
- name: Upload test reports on failure
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: keystore-reports-${{ matrix.os }}
path: core/keystore/build/reports/tests/
retention-days: 7
if-no-files-found: ignore
# The tests that need the real native SQLCipher and Room on Android: opening a vault written by
# earlier releases, the lock/unlock lifecycle, every schema migration. They live in the
# :core:database module (source set androidDeviceTest) and run in its own test app. On the oldest
# supported API and a current one.
instrumented:
if: github.actor != 'dependabot[bot]'
name: instrumented (API ${{ matrix.api }})
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- { api: 26, target: default }
- { api: 35, target: google_apis }
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Build the test APK
run: ./gradlew :core:database:assembleAndroidDeviceTest
- name: Instrumented tests
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
with:
api-level: ${{ matrix.api }}
arch: x86_64
target: ${{ matrix.target }}
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew :core:database:connectedAndroidDeviceTest
- name: Upload test reports
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: instrumented-reports-api-${{ matrix.api }}
path: core/database/build/reports/androidTests/
retention-days: 7