11name : Build APKs (Preview)
22
33on :
4- workflow_dispatch : # Allow manual triggering
4+ workflow_dispatch :
55
66jobs :
7- build :
8- name : Build Preview APK
7+
8+ # Reads the version info and appends the short commit SHA so the preview APK is traceable.
9+ prepare :
10+ name : Read Version Info
911 runs-on : ubuntu-latest
12+ outputs :
13+ version_name : ${{ steps.version.outputs.version_name }}
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+
19+ - name : Extract version name with commit SHA appended
20+ id : version
21+ run : |
22+ BASE_VERSION_NAME=$(grep -oP 'versionName "\K[^"]*' music/build.gradle)
23+ COMMIT_ID=$(git rev-parse --short HEAD)
24+ VERSION_NAME="${BASE_VERSION_NAME}-${COMMIT_ID}"
25+
26+ echo "version_name=$VERSION_NAME" >> $GITHUB_OUTPUT
27+
28+ # Builds the preview APK targeting arm64-v8a devices only.
29+ build-arm64 :
30+ name : Build arm64-v8a
31+ runs-on : ubuntu-latest
32+ needs : prepare
1033
1134 steps :
1235 - name : Checkout code
@@ -15,56 +38,83 @@ jobs:
1538 - name : Set up Java and Android SDK
1639 uses : actions/setup-java@v4
1740 with :
18- java-version : ' 21' # Adjust the Java version as needed
41+ java-version : ' 21'
1942 distribution : ' temurin'
2043
21- - name : Decode Keystore
22- id : decode_keystore
44+ - name : Decode keystore
2345 uses : timheuer/base64-to-file@v1
2446 with :
2547 fileName : ' keystore/key.jks'
2648 encodedString : ${{ secrets.SIGN_KEY }}
2749
28- - name : Extract Version Name and Version Code
50+ - name : Accept Android SDK licenses
51+ run : yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses
52+
53+ - name : Build arm64-v8a release APK
2954 run : |
30- # Extract versionName and versionCode from build.gradle
31- BASE_VERSION_NAME=$(cat music/build.gradle | grep -oP 'versionName "\K[^"]*')
32- VERSION_CODE=$(cat music/build.gradle | grep -oP 'versionCode \K\d+')
55+ chmod +x ./gradlew
56+ ./gradlew clean assembleFossRelease -Pandroid.injected.build.abi=arm64-v8a --no-build-cache --rerun-tasks
57+ env :
58+ SIGNING_KEY_ALIAS : ${{ secrets.ALIAS }}
59+ SIGNING_KEY_PASSWORD : ${{ secrets.KEY_PASSWORD }}
60+ SIGNING_STORE_PASSWORD : ${{ secrets.KEY_STORE_PASSWORD }}
3361
34- # Get the short Git commit SHA (first 7 characters)
35- COMMIT_ID=$(git rev-parse --short HEAD)
62+ - name : Rename APK to felicity-foss-arm64-v8a.apk
63+ run : |
64+ mkdir -p ${{ runner.temp }}/apks
65+ APK=$(find music/ -name "*.apk" | head -n 1)
66+ mv "$APK" "${{ runner.temp }}/apks/felicity-foss-arm64-v8a.apk"
3667
37- # Append the commit ID to the version name
38- VERSION_NAME="${BASE_VERSION_NAME}-${COMMIT_ID}"
68+ - name : Upload arm64-v8a APK
69+ uses : actions/upload-artifact@v4
70+ with :
71+ name : felicity-foss-arm64-v8a-${{ needs.prepare.outputs.version_name }}
72+ path : ${{ runner.temp }}/apks/felicity-foss-arm64-v8a.apk
73+ if-no-files-found : error
3974
40- echo "Version Name: $VERSION_NAME"
41- echo "Version Code: $VERSION_CODE"
75+ # Builds the preview APK targeting x86_64 devices only.
76+ build-x86_64 :
77+ name : Build x86_64
78+ runs-on : ubuntu-latest
79+ needs : prepare
4280
43- # Set these values as environment variables for later steps
44- echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
45- echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
81+ steps :
82+ - name : Checkout code
83+ uses : actions/checkout@v4
84+
85+ - name : Set up Java and Android SDK
86+ uses : actions/setup-java@v4
87+ with :
88+ java-version : ' 21'
89+ distribution : ' temurin'
90+
91+ - name : Decode keystore
92+ uses : timheuer/base64-to-file@v1
93+ with :
94+ fileName : ' keystore/key.jks'
95+ encodedString : ${{ secrets.SIGN_KEY }}
4696
4797 - name : Accept Android SDK licenses
4898 run : yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses
4999
50- - name : Build Release APK
100+ - name : Build x86_64 release APK
51101 run : |
52102 chmod +x ./gradlew
53- ./gradlew clean assembleFossRelease --no-build-cache --rerun-tasks
103+ ./gradlew clean assembleFossRelease -Pandroid.injected.build.abi=x86_64 - -no-build-cache --rerun-tasks
54104 env :
55105 SIGNING_KEY_ALIAS : ${{ secrets.ALIAS }}
56106 SIGNING_KEY_PASSWORD : ${{ secrets.KEY_PASSWORD }}
57107 SIGNING_STORE_PASSWORD : ${{ secrets.KEY_STORE_PASSWORD }}
58108
59- - name : Rename and Move APK to Temporary Directory
109+ - name : Rename APK to felicity-foss-x86_64.apk
60110 run : |
61111 mkdir -p ${{ runner.temp }}/apks
62112 APK=$(find music/ -name "*.apk" | head -n 1)
63- mv "$APK" "${{ runner.temp }}/apks/felicity-foss-${{ env.VERSION_NAME }} .apk"
113+ mv "$APK" "${{ runner.temp }}/apks/felicity-foss-x86_64 .apk"
64114
65- - name : Archive APK
115+ - name : Upload x86_64 APK
66116 uses : actions/upload-artifact@v4
67117 with :
68- name : ${{ env.VERSION_NAME }}
69- path : ${{ runner.temp }}/apks/felicity-foss-${{ env.VERSION_NAME }} .apk
118+ name : felicity-foss-x86_64- ${{ needs.prepare.outputs.version_name }}
119+ path : ${{ runner.temp }}/apks/felicity-foss-x86_64 .apk
70120 if-no-files-found : error
0 commit comments