1- name : Pre-release CI
1+ name : APK Release CI
22
33on :
44 push :
5- branches :
6- - master
7- tags :
8- - ' [0-9]+.[0-9]+.[0-9]+'
5+ tags : ['[0-9]+.[0-9]+.[0-9]+']
6+ branches : [master]
97
108permissions :
119 contents : write
@@ -16,33 +14,28 @@ concurrency:
1614
1715jobs :
1816 build :
19- name : Build app
17+ name : Build APK
2018 runs-on : ubuntu-latest
21-
19+ outputs :
20+ release_sha : ${{ steps.prepare_artifact.outputs.release_sha }}
21+ short_sha : ${{ steps.prepare_artifact.outputs.short_sha }}
2222 steps :
23- - name : Checkout master
24- uses : actions/checkout@v4
25-
26- - name : Checkout archives
23+ - name : Checkout code
2724 uses : actions/checkout@v4
28- with :
29- ref : " archives"
30- path : " archives"
3125
3226 - name : Validate Gradle Wrapper
3327 uses : gradle/wrapper-validation-action@v1
3428
3529 - name : Setup Android SDK
36- run : |
37- ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
30+ run : ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
3831
3932 - name : Set up JDK
4033 uses : actions/setup-java@v4
4134 with :
4235 java-version : 17
4336 distribution : adopt
4437
45- - name : Build release artifacts
38+ - name : Assemble release APK
4639 uses : gradle/gradle-command-action@v2
4740 with :
4841 arguments : :app:assembleRelease
@@ -56,97 +49,138 @@ jobs:
5649 keyStorePassword : ${{ secrets.KEY_STORE_PASSWORD }}
5750 keyPassword : ${{ secrets.KEY_PASSWORD }}
5851
59- - name : Clean up build artifacts
52+ - name : Prepare release artifact
53+ id : prepare_artifact
6054 run : |
61- set -e
6255 mv app/build/outputs/apk/release/app-release-unsigned-signed.apk flixclusive-release.apk
63- sha=`sha256sum flixclusive-release.apk | awk '{ print $1 }'`
64- echo "RELEASE_SHA=$sha" >> $GITHUB_ENV
56+ echo "release_sha=$(sha256sum flixclusive-release.apk | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
57+ echo "short_sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
58+
59+ - name : Upload artifact
60+ uses : actions/upload-artifact@v3
61+ with :
62+ name : release-apk
63+ path : flixclusive-release.apk
64+
65+ release :
66+ name : Create Release
67+ needs : build
68+ runs-on : ubuntu-latest
69+ steps :
70+ - name : Checkout code
71+ uses : actions/checkout@v4
72+ with :
73+ fetch-depth : 0
74+
75+ - name : Download artifact
76+ uses : actions/download-artifact@v3
77+ with :
78+ name : release-apk
79+
80+ - name : Get previous tag
81+ id : previousTag
82+ if : startsWith(github.ref, 'refs/tags/')
83+ run : |
84+ name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1)
85+ echo "previousTag: $name"
86+ echo "previousTag=$name" >> $GITHUB_ENV
6587
6688 - name : Generate changelogs
6789 id : changelog
6890 uses : requarks/changelog-action@v1
6991 with :
7092 token : ${{ secrets.GITHUB_TOKEN }}
7193 fromTag : ${{ github.ref_name }}
72- toTag : pre-release
73- excludeTypes : ' '
94+ toTag : ${{ startsWith(github.ref, 'refs/tags/') && env.previousTag || ' pre-release' }}
95+ excludeTypes : ${{ startsWith(github.ref, 'refs/tags/') && 'build,docs,other,style' || '' }}
7496 writeToFile : false
7597
76- - name : Write changelogs to file
98+ - name : Manage pre-release
99+ if : " !startsWith(github.ref, 'refs/tags/')"
100+ env :
101+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
77102 run : |
78- echo "##### _NOTE: Android TV is incomplete, the providers on this port are not yet installable. Though, you could test it now._
79-
103+ gh release delete pre-release --yes || true
104+ gh release create pre-release \
105+ --title "PR-${{ needs.build.outputs.short_sha }}" \
106+ --notes "$(cat << EOF
107+ ##### _NOTE: Android TV is incomplete, the providers on this port are not yet installable. Though, you could test it now._
108+
80109 ---
81-
110+
82111 ### 🐞 Known issues
83112 - TV focus crashes. Compose TV is bugged af; we wait til the new update.
84-
113+
85114 ${{ steps.changelog.outputs.changes }}
86115 ---
87-
116+
88117 ### Checksums
89118
90119 | Variant | SHA-256 |
91120 | ------- | ------- |
92- | release | ${{ env.RELEASE_SHA }} |" > ${{ github.workspace }}-CHANGELOG.txt
121+ | release | ${{ needs.build.outputs.release_sha }} |
122+ EOF
123+ )" \
124+ --prerelease \
125+ flixclusive-release.apk
93126
94- - name : Delete old pre-release
95- uses : cb80/delrel@latest
96- with :
97- tag : pre-release
127+ - name : Manage stable release
128+ if : startsWith(github.ref, 'refs/tags/')
129+ env :
130+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
131+ run : |
132+ gh release create ${{ github.ref_name }} \
133+ --title "${{ github.ref_name }}" \
134+ --notes "$(cat << EOF
135+ ##### _NOTE: Android TV is incomplete, the providers on this port are not yet installable. Though, you could test it now._
98136
99- - name : Update old pre-release tag
100- uses : EndBug/latest-tag@latest
101- with :
102- ref : pre-release
137+ ---
103138
104- - name : Get short SHA
105- run : echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
139+ ### 🐞 Known issues
140+ - TV focus crashes. Compose TV is bugged af; we wait til the new update.
106141
107- - name : Get PRE-RELEASE version
108- run : |
109- chmod +x .github/parse_version.sh
110- version=$(.github/parse_version.sh)
111- echo "PRE-RELEASE Version: $version-[${{ env.SHORT_SHA }}]"
112- echo "PRE_RELEASE_VERSION=$version" >> $GITHUB_ENV
142+ ${{ steps.changelog.outputs.changes }}
143+ ---
144+
145+ ### Checksums
146+
147+ | Variant | SHA-256 |
148+ | ------- | ------- |
149+ | release | ${{ needs.build.outputs.release_sha }} |
150+ EOF
151+ )" \
152+ flixclusive-release.apk
113153
114- - name : Upload new PRE-RELEASE
115- uses : softprops/action-gh-release@v2
154+
155+ archive :
156+ name : Archive APK
157+ needs : [build, release]
158+ if : " !startsWith(github.ref, 'refs/tags/')"
159+ runs-on : ubuntu-latest
160+ steps :
161+ - name : Checkout code
162+ uses : actions/checkout@v4
163+
164+ - name : Checkout archives
165+ uses : actions/checkout@v4
116166 with :
117- tag_name : pre-release
118- name : PR-${{ env.SHORT_SHA }}
119- body_path : ${{ github.workspace }}-CHANGELOG.txt
120- files : flixclusive-release.apk
121- draft : false
122- prerelease : true
123-
124- - name : Get STABLE version
125- if : startsWith(github.ref, 'refs/tags/')
126- run : |
127- set -x
128- echo "STABLE_VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
129- echo "STABLE Version: ${{ env.STABLE_VERSION_TAG }}"
167+ ref : " archives"
168+ path : " archives"
130169
131- - name : Upload new STABLE
132- uses : softprops/action-gh-release@v2
133- if : startsWith(github.ref, 'refs/tags/')
170+ - name : Download artifact
171+ uses : actions/download-artifact@v3
134172 with :
135- body_path : ${{ github.workspace }}-CHANGELOG.txt
136- files : flixclusive-release.apk
137- draft : false
138- prerelease : false
173+ name : release-apk
139174
140- - name : Push pre-release apk to archives branch
175+ - name : Archive pre-release APK
141176 run : |
142- mkdir -p $GITHUB_WORKSPACE/archives/${{ env.PRE_RELEASE_VERSION }}
143- ARCHIVE_DATE=$(date +"%Y-%m-%d %H:%M:%S")
144-
145- cp flixclusive-release.apk "$GITHUB_WORKSPACE/archives/${{ env.PRE_RELEASE_VERSION }}/PR-${{ env.SHORT_SHA }} $ARCHIVE_DATE.apk"
146-
177+ version=$(.github/parse_version.sh)
178+ archive_dir="$GITHUB_WORKSPACE/archives/$version"
179+ mkdir -p "$archive_dir"
180+ cp flixclusive-release.apk "$archive_dir/PR-${{ needs.build.outputs.short_sha }} $(date +'%Y-%m-%d %H:%M:%S').apk"
147181 cd $GITHUB_WORKSPACE/archives
148- git config --local user.email "actions@ github.com"
149- git config --local user.name "GitHub Actions"
150- git add "$GITHUB_WORKSPACE/archives/${{ env.PRE_RELEASE_VERSION }}/PR-${{ env.SHORT_SHA }} $ARCHIVE_DATE.apk"
151- git commit -m "Archive $(date +" %Y-%m-%d" ) [flixclusiveorg/Flixclusive@${GITHUB_SHA}]" || exit 0
152- git push
182+ git config user.name github-actions
183+ git config user.email github-actions@github.com
184+ git add .
185+ git commit -m "Archive $(date +' %Y-%m-%d' ) [flixclusiveorg/Flixclusive@${GITHUB_SHA}]" || true
186+ git push
0 commit comments