Skip to content

Commit ba2abce

Browse files
committed
Matrix-build APKs and add publish job
1 parent 8bd74ce commit ba2abce

1 file changed

Lines changed: 72 additions & 139 deletions

File tree

.github/workflows/gradle.yml

Lines changed: 72 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,43 @@ env:
1313
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
1414

1515
jobs:
16-
build:
16+
build-apks:
1717
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
include:
21+
- abi: Universal
22+
abi_lower: universal
23+
variant: Foss
24+
variant_lower: foss
25+
- abi: Arm64
26+
abi_lower: arm64
27+
variant: Foss
28+
variant_lower: foss
29+
- abi: Armeabi
30+
abi_lower: armeabi
31+
variant: Foss
32+
variant_lower: foss
33+
- abi: X86_64
34+
abi_lower: x86_64
35+
variant: Foss
36+
variant_lower: foss
37+
- abi: Universal
38+
abi_lower: universal
39+
variant: Gms
40+
variant_lower: gms
41+
- abi: Arm64
42+
abi_lower: arm64
43+
variant: Gms
44+
variant_lower: gms
45+
- abi: Armeabi
46+
abi_lower: armeabi
47+
variant: Gms
48+
variant_lower: gms
49+
- abi: X86_64
50+
abi_lower: x86_64
51+
variant: Gms
52+
variant_lower: gms
1853

1954
steps:
2055
- name: Checkout Code
@@ -32,8 +67,9 @@ jobs:
3267
path: |
3368
~/.gradle/caches
3469
~/.gradle/wrapper
35-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
70+
key: ${{ runner.os }}-gradle-${{ matrix.variant }}-${{ matrix.abi }}-${{ hashFiles('**/*.gradle*') }}
3671
restore-keys: |
72+
${{ runner.os }}-gradle-${{ matrix.variant }}-${{ matrix.abi }}-
3773
${{ runner.os }}-gradle-
3874
3975
- name: Create local.properties
@@ -56,17 +92,17 @@ jobs:
5692
mkdir -p app/keystore
5793
echo "$RELEASE_KEYSTORE_BASE64" | base64 --decode > app/keystore/release.keystore
5894
59-
- name: Build Debug APKs (PR / Check)
95+
- name: Build Debug APK (PR / Check)
6096
if: github.event_name == 'pull_request'
61-
run: ./gradlew assembleUniversalFossDebug assembleArm64FossDebug assembleArmeabiFossDebug assembleX86_64FossDebug assembleUniversalGmsDebug assembleArm64GmsDebug assembleArmeabiGmsDebug assembleX86_64GmsDebug
97+
run: ./gradlew assemble${{ matrix.abi }}${{ matrix.variant }}Debug
6298

63-
- name: Build and Sign Release APKs (Push to main / Dispatch / Tag)
99+
- name: Build and Sign Release APK (Push to main / Dispatch / Tag)
64100
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
65101
env:
66102
STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
67103
KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
68104
KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
69-
run: ./gradlew assembleUniversalFossRelease assembleArm64FossRelease assembleArmeabiFossRelease assembleX86_64FossRelease assembleUniversalGmsRelease assembleArm64GmsRelease assembleArmeabiGmsRelease assembleX86_64GmsRelease
105+
run: ./gradlew assemble${{ matrix.abi }}${{ matrix.variant }}Release
70106

71107
- name: Rename and Organize APKs
72108
run: |
@@ -76,41 +112,50 @@ jobs:
76112
find app/build/outputs/apk/ -name "*.apk" ! -path "*/release-artifacts/*" | while read -r apk_path; do
77113
lower_path=$(echo "$apk_path" | tr '[:upper:]' '[:lower:]')
78114
79-
# 1. Determine variant
80-
case "$lower_path" in
81-
*foss*) variant="foss" ;;
82-
*gms*) variant="gms" ;;
83-
*) continue ;;
84-
esac
85-
86-
# 2. Determine ABI
87-
case "$lower_path" in
88-
*universal*) abi="universal" ;;
89-
*arm64*) abi="arm64" ;;
90-
*armeabi*) abi="armeabi" ;;
91-
*x86_64*) abi="x86_64" ;;
92-
*) continue ;;
93-
esac
94-
95-
# 3. Determine build type
115+
# 1. Determine build type
96116
case "$lower_path" in
97117
*debug*) build_type="debug" ;;
98118
*) build_type="release" ;;
99119
esac
100120
101-
# 4. Construct target name
121+
# 2. Construct target name
102122
if [ "$build_type" = "debug" ]; then
103-
target_name="EchoMusic-v${VERSION_NAME}-${variant}-${abi}-debug.apk"
123+
target_name="EchoMusic-v${VERSION_NAME}-${{ matrix.variant_lower }}-${{ matrix.abi_lower }}-debug.apk"
104124
else
105-
target_name="EchoMusic-v${VERSION_NAME}-${variant}-${abi}.apk"
125+
target_name="EchoMusic-v${VERSION_NAME}-${{ matrix.variant_lower }}-${{ matrix.abi_lower }}.apk"
106126
fi
107127
108128
cp "$apk_path" "app/build/outputs/apk/release-artifacts/$target_name"
109129
echo "Copied $apk_path -> app/build/outputs/apk/release-artifacts/$target_name"
110130
done
111131
132+
- name: Upload APK Artifact
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: EchoMusic-${{ matrix.variant_lower }}-${{ matrix.abi_lower }}-${{ github.event_name == 'pull_request' && 'debug' || 'release' }}
136+
path: app/build/outputs/apk/release-artifacts/*.apk
137+
138+
publish:
139+
needs: build-apks
140+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
141+
runs-on: ubuntu-latest
142+
steps:
143+
- name: Checkout Code
144+
uses: actions/checkout@v6
145+
146+
- name: Download Build Artifacts
147+
uses: actions/download-artifact@v4
148+
with:
149+
path: downloaded-artifacts
150+
151+
- name: Flatten Artifacts Directory
152+
run: |
153+
mkdir -p app/build/outputs/apk/release-artifacts
154+
find downloaded-artifacts/ -name "*.apk" -exec cp {} app/build/outputs/apk/release-artifacts/ \;
155+
echo "Flattened files list:"
156+
ls -R app/build/outputs/apk/release-artifacts
157+
112158
- name: Parse Release Info
113-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
114159
run: |
115160
# 1. Read first line and strip the "# " to get the Title
116161
TITLE=$(head -n 1 RELEASE_INFO.md | sed 's/^# //')
@@ -232,115 +277,3 @@ jobs:
232277
233278
# Post to Discord Webhook
234279
curl -H "Content-Type: application/json" -d @discord-payload.json "$DISCORD_WEBHOOK"
235-
236-
- name: Upload FOSS Universal Debug APK
237-
if: github.event_name == 'pull_request'
238-
uses: actions/upload-artifact@v4
239-
with:
240-
name: EchoMusic-foss-universal-debug
241-
path: app/build/outputs/apk/release-artifacts/*-foss-universal-debug.apk
242-
243-
- name: Upload FOSS ARM64 Debug APK
244-
if: github.event_name == 'pull_request'
245-
uses: actions/upload-artifact@v4
246-
with:
247-
name: EchoMusic-foss-arm64-debug
248-
path: app/build/outputs/apk/release-artifacts/*-foss-arm64-debug.apk
249-
250-
- name: Upload FOSS ARMeabi Debug APK
251-
if: github.event_name == 'pull_request'
252-
uses: actions/upload-artifact@v4
253-
with:
254-
name: EchoMusic-foss-armeabi-debug
255-
path: app/build/outputs/apk/release-artifacts/*-foss-armeabi-debug.apk
256-
257-
- name: Upload FOSS x86_64 Debug APK
258-
if: github.event_name == 'pull_request'
259-
uses: actions/upload-artifact@v4
260-
with:
261-
name: EchoMusic-foss-x86_64-debug
262-
path: app/build/outputs/apk/release-artifacts/*-foss-x86_64-debug.apk
263-
264-
- name: Upload GMS Universal Debug APK
265-
if: github.event_name == 'pull_request'
266-
uses: actions/upload-artifact@v4
267-
with:
268-
name: EchoMusic-gms-universal-debug
269-
path: app/build/outputs/apk/release-artifacts/*-gms-universal-debug.apk
270-
271-
- name: Upload GMS ARM64 Debug APK
272-
if: github.event_name == 'pull_request'
273-
uses: actions/upload-artifact@v4
274-
with:
275-
name: EchoMusic-gms-arm64-debug
276-
path: app/build/outputs/apk/release-artifacts/*-gms-arm64-debug.apk
277-
278-
- name: Upload GMS ARMeabi Debug APK
279-
if: github.event_name == 'pull_request'
280-
uses: actions/upload-artifact@v4
281-
with:
282-
name: EchoMusic-gms-armeabi-debug
283-
path: app/build/outputs/apk/release-artifacts/*-gms-armeabi-debug.apk
284-
285-
- name: Upload GMS x86_64 Debug APK
286-
if: github.event_name == 'pull_request'
287-
uses: actions/upload-artifact@v4
288-
with:
289-
name: EchoMusic-gms-x86_64-debug
290-
path: app/build/outputs/apk/release-artifacts/*-gms-x86_64-debug.apk
291-
292-
- name: Upload FOSS Universal Release APK
293-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
294-
uses: actions/upload-artifact@v4
295-
with:
296-
name: EchoMusic-foss-universal
297-
path: app/build/outputs/apk/release-artifacts/*-foss-universal.apk
298-
299-
- name: Upload FOSS ARM64 Release APK
300-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
301-
uses: actions/upload-artifact@v4
302-
with:
303-
name: EchoMusic-foss-arm64
304-
path: app/build/outputs/apk/release-artifacts/*-foss-arm64.apk
305-
306-
- name: Upload FOSS ARMeabi Release APK
307-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
308-
uses: actions/upload-artifact@v4
309-
with:
310-
name: EchoMusic-foss-armeabi
311-
path: app/build/outputs/apk/release-artifacts/*-foss-armeabi.apk
312-
313-
- name: Upload FOSS x86_64 Release APK
314-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
315-
uses: actions/upload-artifact@v4
316-
with:
317-
name: EchoMusic-foss-x86_64
318-
path: app/build/outputs/apk/release-artifacts/*-foss-x86_64.apk
319-
320-
- name: Upload GMS Universal Release APK
321-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
322-
uses: actions/upload-artifact@v4
323-
with:
324-
name: EchoMusic-gms-universal
325-
path: app/build/outputs/apk/release-artifacts/*-gms-universal.apk
326-
327-
- name: Upload GMS ARM64 Release APK
328-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
329-
uses: actions/upload-artifact@v4
330-
with:
331-
name: EchoMusic-gms-arm64
332-
path: app/build/outputs/apk/release-artifacts/*-gms-arm64.apk
333-
334-
- name: Upload GMS ARMeabi Release APK
335-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
336-
uses: actions/upload-artifact@v4
337-
with:
338-
name: EchoMusic-gms-armeabi
339-
path: app/build/outputs/apk/release-artifacts/*-gms-armeabi.apk
340-
341-
- name: Upload GMS x86_64 Release APK
342-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
343-
uses: actions/upload-artifact@v4
344-
with:
345-
name: EchoMusic-gms-x86_64
346-
path: app/build/outputs/apk/release-artifacts/*-gms-x86_64.apk

0 commit comments

Comments
 (0)