-
-
Notifications
You must be signed in to change notification settings - Fork 28
270 lines (227 loc) · 10.1 KB
/
build_push.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
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
name: Build app
run-name: ${{ github.event_name == 'workflow_dispatch' && format('Build and Release v{0}', github.event.inputs.version) || github.event.commits[0].message }}
on:
push:
branches:
- master
workflow_dispatch:
inputs:
version:
description: 'Version (without "v" prefix)'
required: true
type: string
beta:
description: 'Beta release'
default: false
required: false
type: boolean
message:
description: 'Message for releases (the text at the top of changelog)'
default: ''
required: false
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
cancel-in-progress: true
jobs:
build:
name: Build app
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Android SDK
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;35.0.0"
- name: Setup Gradle
uses: null2264/actions/gradle-setup@a4d662095a2f2af1ed24f1228eb6e55b0f9f1f29
with:
java: 17
distro: adopt
- name: Setup CHANGELOG parser
uses: taiki-e/install-action@parse-changelog
- name: Copy CI gradle.properties
run: |
mkdir -p ~/.gradle
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
- name: Extract branch name
id: branch_name
shell: bash
run: echo "NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: Get changelog
id: changelog
shell: bash
run: |
# extended SemVer (major.minor.patch.hotfix)
VERSION_FORMAT='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))?(-[0-9A-Za-z\.-]+)?(\+[0-9A-Za-z\.-]+)?$|^Unreleased$'
{
echo "CHANGELOG<<END_OF_FILE"
parse-changelog CHANGELOG.md ${{ github.event.inputs.version == '' && 'Unreleased' || github.event.inputs.version }} --version-format $VERSION_FORMAT || parse-changelog CHANGELOG.md Unreleased --version-format $VERSION_FORMAT || echo "No documented changes so far..."
echo ""
echo "END_OF_FILE"
} >> "$GITHUB_OUTPUT" 2> /dev/null
# PROD
- name: Prepare release build
if: github.event.inputs.version != '' && github.event.inputs.beta != 'true'
run: |
set -x
echo "VERSION_TAG=v${{github.event.inputs.version}}" >> $GITHUB_ENV
# BETA
- name: Prepare beta build
if: github.event.inputs.version != '' && github.event.inputs.beta == 'true'
run: |
set -x
BETA_COUNT=$(git tag -l --sort=refname "v${{github.event.inputs.version}}-b*" | tail -n1 | sed "s/^\S*-b//g")
[ "$BETA_COUNT" = "" ] && BETA_COUNT="1" || BETA_COUNT=$((BETA_COUNT+1))
echo "VERSION_TAG=v${{github.event.inputs.version}}-b${BETA_COUNT}" >> $GITHUB_ENV
# NIGHTLY
- name: Prepare nightly build
if: steps.branch_name.outputs.NAME == 'master' && github.event.inputs.version == ''
run: |
set -x
echo "VERSION_TAG=r$(git rev-list --count HEAD)" >> $GITHUB_ENV
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "COMMIT_SHORT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
# PROD
- name: Build release build and run tests
if: startsWith(env.VERSION_TAG, 'v') && github.event.inputs.beta != 'true'
run: ./gradlew assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
# BETA
- name: Build beta build and run tests
if: startsWith(env.VERSION_TAG, 'v') && github.event.inputs.beta == 'true'
run: ./gradlew assembleStandardBeta testReleaseUnitTest testStandardBetaUnitTest
# NIGHTLY
- name: Build nightly build and run tests
if: startsWith(env.VERSION_TAG, 'r')
run: ./gradlew assembleStandardNightly testReleaseUnitTest testStandardNightlyUnitTest
- name: Upload R8 APK to artifact
uses: actions/upload-artifact@v4
if: env.VERSION_TAG != ''
with:
name: arm64-v8a-${{ github.sha }}
path: app/build/outputs/apk/standard/*/app*-arm64-v8a-*.apk
- name: Upload R8 mapping
uses: actions/upload-artifact@v4
if: env.VERSION_TAG != ''
with:
name: mapping-${{ github.sha }}
path: app/build/outputs/mapping/standard*
- name: Publish test report
uses: mikepenz/action-junit-report@v5
if: success() || failure()
with:
include_passed: true
detailed_summary: true
report_paths: '**/build/test-results/test*/TEST-*.xml'
- name: Get version stage
id: version_stage
shell: bash
run: |
stage=""
case "${{ env.VERSION_TAG }}" in
v*)
[ "$(echo '${{ env.VERSION_TAG }}' | grep 'v*-b')" = "" ] && stage="release" || stage="beta"
;;
r*) stage="nightly" ;;
esac
[ "$stage" = "" ] && exit 1 # something went wrong
echo "STAGE=${stage}" >> $GITHUB_OUTPUT
- name: Sign APK
uses: null2264/actions/android-signer@a4d662095a2f2af1ed24f1228eb6e55b0f9f1f29
if: env.VERSION_TAG != ''
with:
releaseDir: app/build/outputs/apk/standard/${{ steps.version_stage.outputs.STAGE }}
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
keyAlias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
summarise: true
- name: Clean up build artifacts
if: env.VERSION_TAG != ''
run: |
set -e
dir="app/build/outputs/apk/standard/${{ steps.version_stage.outputs.STAGE }}"
mv $dir/app-standard-universal-*-signed.apk yokai-${{ env.VERSION_TAG }}.apk
sha=`sha256sum yokai-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_ENV
cp $dir/app-standard-arm64-v8a-*-signed.apk yokai-arm64-v8a-${{ env.VERSION_TAG }}.apk
sha=`sha256sum yokai-arm64-v8a-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_ENV
cp $dir/app-standard-armeabi-v7a-*-signed.apk yokai-armeabi-v7a-${{ env.VERSION_TAG }}.apk
sha=`sha256sum yokai-armeabi-v7a-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_ENV
cp $dir/app-standard-x86-*-signed.apk yokai-x86-${{ env.VERSION_TAG }}.apk
sha=`sha256sum yokai-x86-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_X86_SHA=$sha" >> $GITHUB_ENV
cp $dir/app-standard-x86_64-*-signed.apk yokai-x86_64-${{ env.VERSION_TAG }}.apk
sha=`sha256sum yokai-x86_64-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_X86_64_SHA=$sha" >> $GITHUB_ENV
- name: Create Release
if: startsWith(env.VERSION_TAG, 'v')
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION_TAG }}
name: Yōkai ${{ env.VERSION_TAG }}
body: |
${{ github.event.inputs.message }}
${{ steps.changelog.outputs.CHANGELOG }}
---
### Checksums
| Variant | SHA-256 |
| ------- | ------- |
| Universal | ${{ env.APK_UNIVERSAL_SHA }}
| arm64-v8a | ${{ env.APK_ARM64_V8A_SHA }}
| armeabi-v7a | ${{ env.APK_ARMEABI_V7A_SHA }}
| x86 | ${{ env.APK_X86_SHA }} |
| x86_64 | ${{ env.APK_X86_64_SHA }} |
> [!TIP]
>
> If you are unsure which version to download then go with **yokai-${{ env.VERSION_TAG }}.apk**
files: |
yokai-${{ env.VERSION_TAG }}.apk
yokai-arm64-v8a-${{ env.VERSION_TAG }}.apk
yokai-armeabi-v7a-${{ env.VERSION_TAG }}.apk
yokai-x86-${{ env.VERSION_TAG }}.apk
yokai-x86_64-${{ env.VERSION_TAG }}.apk
draft: true
prerelease: ${{ github.event.inputs.beta }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Nightly
if: startsWith(env.VERSION_TAG, 'r')
uses: softprops/action-gh-release@v2
with:
repository: null2264/yokai-nightly
tag_name: ${{ env.VERSION_TAG }}
name: Yōkai Nightly (${{ env.VERSION_TAG }})
body: |
> [!CAUTION]
> _**This alpha version is for testing only!**_
>
> This build is triggered by commit [`${{ env.COMMIT_SHORT_HASH }}`](https://github.com/null2264/yokai/commit/${{ env.COMMIT_HASH }})
It is not ready for daily use and we do not guarantee its usability. Please download the latest stable releases instead (https://github.com/null2264/yokai/releases/latest). If you insist, please be sure to ALWAYS backup before updating.
${{ steps.changelog.outputs.CHANGELOG }}
---
### Checksums
| Variant | SHA-256 |
| ------- | ------- |
| Universal | ${{ env.APK_UNIVERSAL_SHA }}
| arm64-v8a | ${{ env.APK_ARM64_V8A_SHA }}
| armeabi-v7a | ${{ env.APK_ARMEABI_V7A_SHA }}
| x86 | ${{ env.APK_X86_SHA }} |
| x86_64 | ${{ env.APK_X86_64_SHA }} |
> [!TIP]
>
> If you are unsure which version to download then go with **yokai-${{ env.VERSION_TAG }}.apk**
files: |
yokai-${{ env.VERSION_TAG }}.apk
yokai-arm64-v8a-${{ env.VERSION_TAG }}.apk
yokai-armeabi-v7a-${{ env.VERSION_TAG }}.apk
yokai-x86-${{ env.VERSION_TAG }}.apk
yokai-x86_64-${{ env.VERSION_TAG }}.apk
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.NIGHTLY_PAT }}