Repository navigation
140 lines (135 loc) · 5.75 KB
/
Copy pathandroid.yml
File metadata and controls
140 lines (135 loc) · 5.75 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
# Copyright 2026 Han Li and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The Android remote client: build the release APK, signed with a key that the job
# makes and throws away
# (docs/en/dev/packaging-android.md#signing-status), and upload it as the
# `vfox-plus-android` artifact. The tool versions are in android/versions.env.
name: android
on:
push:
branches: [main]
paths:
- android/**
- mygo/pair/**
- mygo/VERSION
- .github/workflows/android.yml
pull_request:
paths:
- android/**
- mygo/pair/**
- mygo/VERSION
- .github/workflows/android.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build the APK
# Forks do not run CI.
if: github.repository == 'version-fox/vfox-plus'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Read the pinned versions
run: grep -hE '^[A-Z0-9_]+=' android/versions.env >> "$GITHUB_ENV"
- name: Set up JDK
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- name: Set up the Android SDK
uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
- name: Set up Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
with:
# Only the caches: android/gradlew is Gradle Wrapper Neo, which has
# no wrapper jar to validate.
validate-wrappers: false
# Since v6 the default caching is gradle-actions-caching, which is
# closed source and under its own terms of use; `basic` is
# MIT-licensed and built on actions/cache.
cache-provider: basic
- name: Build the release APK
# Signed with a throwaway key, made here, so that the signing of the release
# (android/app/build.gradle.kts) is built on every change the way the release
# job builds it. The artifact is for testing: no other build can update it.
run: |
store="$RUNNER_TEMP/throwaway.keystore"
password="$(openssl rand -hex 16)"
keytool -genkeypair -keystore "$store" -storepass "$password" -keypass "$password" \
-alias throwaway -keyalg RSA -keysize 2048 -validity 10 -dname "CN=throwaway" >/dev/null
ANDROID_RELEASE_KEYSTORE="$store" ANDROID_RELEASE_STORE_PASSWORD="$password" \
ANDROID_RELEASE_KEY_ALIAS=throwaway ANDROID_RELEASE_KEY_PASSWORD="$password" \
./gradlew :app:assembleRelease
working-directory: android
- name: Name the APK with the version
run: |
version="$(tr -d '[:space:]' < mygo/VERSION)"
cp android/app/build/outputs/apk/release/app-release.apk \
"vfox-plus_${version}.apk"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: vfox-plus-android
path: vfox-plus_*.apk
measure:
name: Measure the APK on an emulator
# Forks do not run CI.
if: github.repository == 'version-fox/vfox-plus'
needs: build
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: vfox-plus-android
path: apk
- name: Read the Go version
run: grep -hE '^GO_VERSION=' mygo/versions.env >> "$GITHUB_ENV"
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: shared/tooling/go.sum
- name: Build vfxtool
run: go -C shared/tooling build -o "$RUNNER_TEMP/vfxtool" ./cmd/vfxtool
- 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
- uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
with:
api-level: 36
target: google_apis
arch: x86_64
profile: pixel_6
# One line: the runner executes the script line by line, each in its
# own shell.
script: ${{ runner.temp }}/vfxtool measure-apk --apk apk/vfox-plus_*.apk --output ${{ runner.temp }}/memory-android --screenshot ${{ runner.temp }}/screenshot-android.png
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: memory-android
path: ${{ runner.temp }}/memory-android/memory.txt
if-no-files-found: error
overwrite: true
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: screenshot-android
path: ${{ runner.temp }}/screenshot-android.png
if-no-files-found: error
overwrite: true