forked from OpenEnroth/OpenEnroth
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (133 loc) · 5.07 KB
/
android.yml
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
name: Android
on:
pull_request: null
workflow_dispatch:
inputs:
myCommit:
description: Commit SHA1
required: false
default: ''
type: string
releaseTag:
description: Release tag
required: false
default: ''
type: string
workflow_call:
inputs:
myCommit:
description: Commit SHA1
required: false
default: ''
type: string
releaseTag:
description: Release tag
required: false
default: ''
type: string
push: null
release:
types:
- published
env:
# This version is referenced in android/openenroth/build.gradle.
# See https://developer.android.com/ndk/downloads for revision-to-version mapping.
# When updating the version here you should also update it in the Dependencies repo!
NDK_REVISION: r26d
jobs:
build_android:
timeout-minutes: 60
name: Build Android Client
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
configuration:
- Debug
- Release
# Magical: https://stackoverflow.com/questions/73630573/how-to-write-conditional-expressions-in-github-actions
architecture: ${{ fromJson('[["universal"], ["arm64-v8a", "armeabi-v7a", "x86_64"]]')[inputs.releaseTag == ''] }}
steps:
- name: Configure fast APT mirror
uses: vegardit/fast-apt-mirror.sh@v1
with: # the following parameters are listed with their action default values and are optional
healthchecks: 10 # Number of mirrors from the mirrors list to check for availability and up-to-dateness
speedtests: 6 # Maximum number of healthy mirrors to test for speed
parallel: 2 # Number of parallel speed tests
sample-size: 1024 # Number of kilobytes to download during the speed from each mirror
sample-time: 3 # Maximum number of seconds within the sample download from a mirror must finish
- name: Checkout
uses: actions/checkout@v4.2.2
with:
submodules: recursive
ref: '${{inputs.myCommit}}'
# Note that secrets are not passed to actions triggered by PRs, so this step will be skipped for PRs.
- name: Decode keystore
if: env.SECRETS_KEYSTORE != ''
id: decode_keystore
uses: timheuer/base64-to-file@v1.2.4
with:
fileName: android_keystore.jks
encodedString: '${{env.SECRETS_KEYSTORE}}'
env:
# Secrets cannot be referenced in if: blocks, so we have to work it around.
SECRETS_KEYSTORE: '${{secrets.KEYSTORE}}'
- name: Get NDK
id: get-ndk
uses: nttld/setup-ndk@v1.5.0
with:
ndk-version: '${{env.NDK_REVISION}}'
add-to-path: false
local-cache: true
link-to-sdk: true
- name: Install dependencies
run: |
sudo apt-get install -y yasm
if [[ "${{matrix.architecture}}" = "universal" || "${{matrix.architecture}}" = "x86" ]]; then
sudo dpkg --add-architecture i386
fi
if [[ "${{matrix.architecture}}" = "universal" || "${{matrix.architecture}}" = "x86" || "${{matrix.architecture}}" = "armeabi-v7a" ]]; then
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install -y gcc-13-multilib g++-13-multilib
fi
- uses: actions/setup-java@v4.4.0
with:
distribution: temurin
java-version: 17.0.6
cache: gradle
- name: Run ccache
uses: hendrikmuhs/ccache-action@v1.2.14
with:
key: 'android-${{matrix.configuration}}-${{matrix.architecture}}'
save: ${{ github.ref == 'refs/heads/master' || inputs.releaseTag != '' }}
verbose: 2
max-size: ${{ fromJson('["200M", "600M"]')[matrix.architecture == 'universal'] }}
- name: Build the app
working-directory: android
run: |
./gradlew "assemble${{matrix.configuration}}" -Pandroid.native.buildOutput=verbose
env:
SIGNING_KEYSTORE: '${{steps.decode_keystore.outputs.filePath}}'
SIGNING_KEY_ALIAS: '${{secrets.SIGNING_KEY_ALIAS}}'
SIGNING_KEY_PASSWORD: '${{secrets.SIGNING_KEY_PASSWORD}}'
SIGNING_STORE_PASSWORD: '${{secrets.SIGNING_STORE_PASSWORD}}'
CMAKE_BUILD_PARALLEL_LEVEL: 3
GITHUBARCH: '${{matrix.architecture}}'
- name: List artifacts
run: |
find android/openenroth/build/outputs/apk
- name: Publish apk package
if: inputs.releaseTag != ''
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: '${{inputs.releaseTag}}'
files: |
android/openenroth/build/outputs/apk/debug/openenroth-debug.apk
android/openenroth/build/outputs/apk/release/openenroth-release.apk
# Don't publish unsigned APKs:
# android/openenroth/build/outputs/apk/release/openenroth-release-unsigned.apk
- name: Cleanup ccache
run: |
ccache -c