forked from OpenEnroth/OpenEnroth
-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (144 loc) · 5.2 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
147
148
149
150
151
152
153
154
155
156
157
158
159
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.
NDK_REVISION: r26-rc1
jobs:
build_android:
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@v3
with:
submodules: recursive
ref: '${{inputs.myCommit}}'
- name: Decode keystore
if: env.super_secret != ''
id: decode_keystore
uses: timheuer/base64-to-file@v1.2
with:
fileName: android_keystore.jks
fileDir: /home/runner/work/OpenEnroth/OpenEnroth/app/keystore/
encodedString: '${{secrets.KEYSTORE}}'
env:
super_secret: '${{secrets.KEYSTORE}}'
- name: Get NDK
id: get-ndk
uses: nttld/setup-ndk@v1.3.1
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 apt-get update
sudo apt-get install -y gcc-13-multilib g++-13-multilib
fi
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17.0.6
cache: gradle
- name: Check for ffmpeg cache
id: ffmpeg-cache
uses: actions/cache/restore@v3
with:
path: |
android/openenroth/jni/FFmpeg/android/
key: ffmpeg-cache
- name: Build ffmpeg
if: steps.ffmpeg-cache.outputs.cache-hit != 'true'
working-directory: android/openenroth/jni/FFmpeg
run: |
./build.sh
- name: Save ffmpeg cache
if: steps.ffmpeg-cache.outputs.cache-hit != 'true'
id: check-for-ffmpeg-save
uses: actions/cache/save@v3
with:
path: |
android/openenroth/jni/FFmpeg/android/
key: ffmpeg-cache
- name: Run ccache
uses: hendrikmuhs/ccache-action@v1.2.10
with:
key: 'android-${{matrix.configuration}}-${{matrix.architecture}}'
save: ${{ github.ref == 'refs/heads/master' || inputs.releaseTag != '' }}
verbose: 2
max-size: ${{ fromJson('["100M", "300M"]')[matrix.architecture == 'universal'] }}
- name: Build the app
working-directory: android
run: |
./gradlew "assemble${{matrix.configuration}}" -Pandroid.native.buildOutput=verbose
env:
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: 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-unsigned.apk
android/openenroth/build/outputs/apk/release/openenroth-release-signed.apk
- name: Cleanup ccache
run: |
ccache -c