Skip to content

Commit 625f003

Browse files
authored
Update Release Build (#60)
* Update Release Build * Add Release Drafter
1 parent 7b0329a commit 625f003

File tree

3 files changed

+171
-66
lines changed

3 files changed

+171
-66
lines changed

.github/workflows/draft.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Draft Release"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: ["master"]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
draft:
14+
name: "Draft Release"
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 5
17+
permissions:
18+
contents: write
19+
20+
steps:
21+
- name: "Checkout"
22+
uses: actions/checkout@v4
23+
24+
- name: "Draft Release Action"
25+
id: draft
26+
uses: cssnr/draft-release-action@master
27+
with:
28+
semver: patch
29+
prerelease: false
30+
31+
- name: "Process Release Draft URL"
32+
run: |
33+
echo "url: ${{ steps.draft.outputs.url }}"

.github/workflows/release.yaml

Lines changed: 112 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,34 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
env:
13-
path: app/build/outputs/apk/release # Output Path
14-
output: app-release-unsigned.apk # Output File Name
15-
name: ${{ github.repository_owner }}.apk # Final APK Name
1613
key_name: my-key
17-
key_file: release.keystore
18-
tools_path: /usr/local/lib/android/sdk/build-tools/36.0.0
19-
cmdline_tools: /usr/local/lib/android/sdk/cmdline-tools/latest/bin
14+
package_name: com.djangofiles.djangofiles
2015

2116
jobs:
2217
release:
2318
name: "Release"
2419
runs-on: ubuntu-latest
25-
timeout-minutes: 15
20+
timeout-minutes: 20
2621
permissions:
2722
contents: write
23+
env:
24+
apk_file: app-release-unsigned.apk
25+
apk_path: app/build/outputs/apk/release
26+
aab_file: app-release.aab
27+
aab_path: app/build/outputs/bundle/release
28+
mapping_file: app/build/outputs/mapping/release/mapping.txt
29+
debug_symbols: app/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib
30+
tools_path: /usr/local/lib/android/sdk/build-tools/36.0.0
31+
cmdline_tools: /usr/local/lib/android/sdk/cmdline-tools/latest/bin
32+
key_file: release.keystore
33+
gradle_file: app/build.gradle.kts
34+
signed_apk: app-release.apk
2835

2936
steps:
3037
- name: "Checkout"
3138
uses: actions/checkout@v4
3239

3340
- name: "Debug Event"
34-
if: ${{ !github.event.act }}
3541
continue-on-error: true
3642
run: |
3743
echo "ref: ${{ github.ref }}"
@@ -43,13 +49,11 @@ jobs:
4349
echo "::endgroup::"
4450
4551
- name: "Set Tools Path"
46-
if: ${{ !github.event.act }}
4752
run: |
4853
echo "${{ env.tools_path }}" >> "$GITHUB_PATH"
4954
echo "${{ env.cmdline_tools }}" >> "$GITHUB_PATH"
5055
5156
- name: "Verify Tools"
52-
if: ${{ !github.event.act }}
5357
run: |
5458
which keytool
5559
which zipalign
@@ -65,22 +69,34 @@ jobs:
6569
6670
- name: "Update Version"
6771
uses: chkfung/[email protected]
72+
id: version
6873
with:
69-
gradlePath: app/build.gradle.kts
74+
gradlePath: ${{ env.gradle_file }}
7075
versionCode: ${{ github.run_number }}
7176
versionName: ${{ github.ref_name }}
7277

7378
- name: "Debug Version"
74-
if: ${{ !github.event.act }}
7579
continue-on-error: true
7680
run: |
7781
echo "versionCode: ${{ github.run_number }}"
7882
echo "versionName: ${{ github.ref_name }}"
7983
80-
echo "::group::cat app/build.gradle.kts"
81-
cat app/build.gradle.kts
84+
echo "::group::cat ${{ env.gradle_file }}"
85+
cat ${{ env.gradle_file }}
8286
echo "::endgroup::"
8387
88+
- name: "Write Google Services File"
89+
run: |
90+
echo "${{ secrets.GOOGLE_SERVICES }}" | base64 --decode > app/google-services.json
91+
92+
stat app/google-services.json
93+
94+
- name: "Write Keystore File"
95+
run: |
96+
echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 --decode > ${{ env.key_file }}
97+
98+
echo ${{ secrets.ANDROID_KEYSTORE_PASS }} | keytool -list -keystore ${{ env.key_file }}
99+
84100
- name: "Setup Node 22"
85101
uses: actions/setup-node@v4
86102
with:
@@ -91,10 +107,11 @@ jobs:
91107
run: |
92108
bash prepare.sh
93109
94-
- name: "Google Services File"
95-
if: ${{ !github.event.act }}
110+
- name: "Debug Prepare"
111+
continue-on-error: true
96112
run: |
97-
echo "${{ secrets.GOOGLE_SERVICES }}" | base64 --decode > app/google-services.json
113+
ls .
114+
ls -lAh app
98115
99116
- name: "Setup Java"
100117
uses: actions/setup-java@v4
@@ -103,63 +120,108 @@ jobs:
103120
java-version: "17"
104121
#cache: "gradle"
105122

106-
- name: "Gradle Assemble"
123+
- name: "Gradle Assemble APK"
107124
run: |
108125
chmod +x ./gradlew
109126
./gradlew assembleRelease
110127
111-
- name: "Verify Build"
128+
- name: "Verify APK"
112129
run: |
113-
apkanalyzer -h apk summary "${{ env.path }}/${{ env.output }}"
130+
apkanalyzer -h apk summary "${{ env.apk_path }}/${{ env.apk_file }}"
114131
115-
echo "::group::ls env.path"
116-
ls -lAh ${{ env.path }}
132+
echo "::group::ls env.apk_path"
133+
ls -lAh ${{ env.apk_path }}
117134
echo "::endgroup::"
118135
119136
- name: "Align APK"
120137
run: |
121-
zipalign -P 16 -f -v 4 "${{ env.path }}/${{ env.output }}" "${{ env.path }}/${{ env.name }}"
122-
123-
- name: "Verify Alignment"
124-
run: |
125-
zipalign -c -P 16 -v 4 "${{ env.path }}/${{ env.name }}"
126-
127-
- name: "Decode Keystore"
128-
run: |
129-
echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 --decode > ${{ env.key_file }}
130-
131-
- name: "Debug Keystore"
132-
continue-on-error: true
133-
run: |
134-
echo ${{ secrets.ANDROID_KEYSTORE_PASS }} | keytool -list -keystore ${{ env.key_file }}
138+
mv "${{ env.apk_path }}/${{ env.apk_file }}" "${{ env.apk_path }}/source.apk"
139+
zipalign -P 16 -f -v 4 \
140+
"${{ env.apk_path }}/source.apk" \
141+
"${{ env.apk_path }}/${{ env.apk_file }}"
142+
zipalign -c -P 16 -v 4 "${{ env.apk_path }}/${{ env.apk_file }}"
143+
rm -f "${{ env.apk_path }}/source.apk"
135144
136145
- name: "Sign APK"
137146
run: |
138147
apksigner sign --ks ${{ env.key_file }} \
139148
--ks-pass pass:${{ secrets.ANDROID_KEYSTORE_PASS }} \
140149
--ks-key-alias ${{ env.key_name }} \
141-
"${{ env.path }}/${{ env.name }}"
150+
"${{ env.apk_path }}/${{ env.apk_file }}"
151+
apksigner verify --verbose "${{ env.apk_path }}/${{ env.apk_file }}"
152+
mv "${{ env.apk_path }}/${{ env.apk_file }}" "${{ env.apk_path }}/${{ env.signed_apk }}"
142153
143-
- name: "Verify Signature"
144-
run: |
145-
apksigner verify --verbose "${{ env.path }}/${{ env.name }}"
146-
147-
- name: "Upload Artifacts"
154+
- name: "Upload APK to Artifacts"
148155
if: ${{ !github.event.act }}
149156
uses: actions/upload-artifact@v4
150157
with:
151-
name: ${{ github.repository_owner }}-release
152-
path: ${{ env.path }}
158+
name: release
159+
path: ${{ env.apk_path }}
153160

154-
- name: "Upload to Release"
161+
- name: "Upload APK to Release"
155162
if: ${{ github.event_name == 'release' }}
156163
uses: svenstaro/upload-release-action@v2
157164
with:
158-
file: ${{ env.path }}/${{ env.name }}
165+
file: ${{ env.apk_path }}/${{ env.signed_apk }}
159166
tag: ${{ github.ref }}
160167
overwrite: true
161168
file_glob: true
162169

170+
#- name: "Gradle Bundle AAB"
171+
# if: ${{ !github.event.release.prerelease }}
172+
# run: |
173+
# chmod +x ./gradlew
174+
# ./gradlew bundleRelease
175+
176+
#- name: "Debug Bundle"
177+
# if: ${{ !github.event.release.prerelease }}
178+
# continue-on-error: true
179+
# run: |
180+
# echo "env.aab_path: ${{ env.aab_path }}"
181+
# ls -lAh ${{ env.aab_path }} ||:
182+
# echo "env.debug_symbols: ${{ env.debug_symbols }}"
183+
# ls -lAh ${{ env.debug_symbols }} ||:
184+
# echo "env.mapping_file: ${{ env.mapping_file }}"
185+
# ls -lAh $(dirname ${{ env.debug_symbols }}) ||:
186+
187+
#- name: "Sign Bundle"
188+
# if: ${{ !github.event.release.prerelease }}
189+
# run: |
190+
# apksigner sign --ks ${{ env.key_file }} \
191+
# --min-sdk-version 26 \
192+
# --v1-signing-enabled true \
193+
# --v2-signing-enabled true \
194+
# --ks-pass pass:${{ secrets.ANDROID_KEYSTORE_PASS }} \
195+
# --ks-key-alias ${{ env.key_name }} \
196+
# "${{ env.aab_path }}/${{ env.aab_file }}"
197+
198+
#- name: "Upload Bundle to Artifacts"
199+
# if: ${{ !github.event.release.prerelease }}
200+
# uses: actions/upload-artifact@v4
201+
# with:
202+
# name: bundle
203+
# path: ${{ env.aab_path }}
204+
205+
#- name: "Generate Whats New"
206+
# if: ${{ !github.event.release.prerelease }}
207+
# run: |
208+
# mkdir -p whatsNew
209+
# echo "GitHub Actions Build" > whatsNew/whatsnew-en-US
210+
# cat whatsNew/whatsnew-en-US
211+
212+
#- name: "Upload Google Play"
213+
# if: ${{ github.event_name == 'release' && !github.event.release.prerelease }}
214+
# uses: r0adkll/upload-google-play@v1
215+
# with:
216+
# serviceAccountJsonPlainText: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }}
217+
# packageName: ${{ env.package_name }}
218+
# releaseFiles: ${{ env.aab_path }}/${{ env.aab_file }}
219+
# debugSymbols: ${{ env.debug_symbols }}
220+
# mappingFile: ${{ env.mapping_file }}
221+
# whatsNewDirectory: whatsNew
222+
# releaseName: "${{ github.run_number }} (${{ github.ref_name }})"
223+
# track: internal
224+
163225
- name: "VirusTotal"
164226
if: ${{ github.event_name == 'release' }}
165227
uses: cssnr/virustotal-action@v1
@@ -180,15 +242,15 @@ jobs:
180242
run: |
181243
echo -e "## Android Release\n\n" >> $GITHUB_STEP_SUMMARY
182244
183-
echo -e "Final APK: \`${{ env.name }}\`\n\n" >> $GITHUB_STEP_SUMMARY
245+
echo -e "Final APK: \`${{ env.signed_apk }}\`\n\n" >> $GITHUB_STEP_SUMMARY
184246
185247
echo -e "<details><summary>Build Artifacts</summary>\n\n" >> $GITHUB_STEP_SUMMARY
186-
echo -e "\`\`\`text\n$(ls -lAh ${{ env.path }})\n\`\`\`\n\n" >> $GITHUB_STEP_SUMMARY
248+
echo -e "\`\`\`text\n$(ls -lAh ${{ env.apk_path }})\n\`\`\`\n\n" >> $GITHUB_STEP_SUMMARY
187249
echo -e "</details>\n\n" >> $GITHUB_STEP_SUMMARY
188250
189-
if [ -f "${{ env.path }}/output-metadata.json" ];then
251+
if [ -f "${{ env.apk_path }}/output-metadata.json" ];then
190252
echo -e "<details><summary>File: output-metadata.json</summary>\n\n" >> $GITHUB_STEP_SUMMARY
191-
echo -e "\`\`\`json\n$(cat ${{ env.path }}/output-metadata.json)\n\`\`\`\n\n" >> $GITHUB_STEP_SUMMARY
253+
echo -e "\`\`\`json\n$(cat ${{ env.apk_path }}/output-metadata.json)\n\`\`\`\n\n" >> $GITHUB_STEP_SUMMARY
192254
echo -e "</details>\n\n" >> $GITHUB_STEP_SUMMARY
193255
fi
194256

0 commit comments

Comments
 (0)