refactor(app): enhance auto-app updater #120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: APK Release CI | |
on: | |
push: | |
tags: ['[0-9]+.[0-9]+.[0-9]+'] | |
branches: [master] | |
permissions: | |
contents: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build APK | |
runs-on: ubuntu-latest | |
outputs: | |
release_sha: ${{ steps.prepare_artifact.outputs.release_sha }} | |
short_sha: ${{ steps.prepare_artifact.outputs.short_sha }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Validate Gradle Wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: Setup Android SDK | |
run: ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3" | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: adopt | |
- name: Assemble release APK | |
uses: gradle/gradle-command-action@v2 | |
with: | |
arguments: :app:assembleRelease | |
- name: Sign release APK | |
uses: r0adkll/sign-android-release@v1 | |
with: | |
releaseDirectory: app/build/outputs/apk/release | |
signingKeyBase64: ${{ secrets.SIGNING_KEY }} | |
alias: ${{ secrets.ALIAS }} | |
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
keyPassword: ${{ secrets.KEY_PASSWORD }} | |
- name: Prepare release artifact | |
id: prepare_artifact | |
run: | | |
mv app/build/outputs/apk/release/app-release-unsigned-signed.apk flixclusive-release.apk | |
echo "release_sha=$(sha256sum flixclusive-release.apk | cut -d ' ' -f1)" >> $GITHUB_OUTPUT | |
echo "short_sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-apk | |
path: flixclusive-release.apk | |
release: | |
name: Create Release | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-apk | |
- name: Get previous tag | |
id: previousTag | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1) | |
echo "previousTag: $name" | |
echo "previousTag=$name" >> $GITHUB_ENV | |
- name: Generate changelogs | |
id: changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fromTag: ${{ github.ref_name }} | |
toTag: ${{ startsWith(github.ref, 'refs/tags/') && env.previousTag || 'pre-release' }} | |
excludeTypes: ${{ startsWith(github.ref, 'refs/tags/') && 'build,docs,other,style' || '' }} | |
writeToFile: false | |
- name: Manage pre-release | |
if: "!startsWith(github.ref, 'refs/tags/')" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release delete pre-release --yes || true | |
gh release create pre-release \ | |
--title "PR-${{ needs.build.outputs.short_sha }}" \ | |
--notes "$(cat << EOF | |
##### _NOTE: Android TV is incomplete, the providers on this port are not yet installable. Though, you could test it now._ | |
--- | |
### 🐞 Known issues | |
- TV focus crashes. Compose TV is bugged af; we wait til the new update. | |
${{ steps.changelog.outputs.changes }} | |
--- | |
### Checksums | |
| Variant | SHA-256 | | |
| ------- | ------- | | |
| release | ${{ needs.build.outputs.release_sha }} | | |
EOF | |
)" \ | |
--prerelease \ | |
flixclusive-release.apk | |
- name: Manage stable release | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ github.ref_name }} \ | |
--title "${{ github.ref_name }}" \ | |
--notes "$(cat << EOF | |
##### _NOTE: Android TV is incomplete, the providers on this port are not yet installable. Though, you could test it now._ | |
--- | |
### 🐞 Known issues | |
- TV focus crashes. Compose TV is bugged af; we wait til the new update. | |
${{ steps.changelog.outputs.changes }} | |
--- | |
### Checksums | |
| Variant | SHA-256 | | |
| ------- | ------- | | |
| release | ${{ needs.build.outputs.release_sha }} | | |
EOF | |
)" \ | |
flixclusive-release.apk | |
archive: | |
name: Archive APK | |
needs: [build, release] | |
if: "!startsWith(github.ref, 'refs/tags/')" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Checkout archives | |
uses: actions/checkout@v4 | |
with: | |
ref: "archives" | |
path: "archives" | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-apk | |
- name: Archive pre-release APK | |
run: | | |
version=$(.github/parse_version.sh) | |
archive_dir="$GITHUB_WORKSPACE/archives/$version" | |
mkdir -p "$archive_dir" | |
cp flixclusive-release.apk "$archive_dir/PR-${{ needs.build.outputs.short_sha }} $(date +'%Y-%m-%d %H:%M:%S').apk" | |
cd $GITHUB_WORKSPACE/archives | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git commit -m "Archive $(date +'%Y-%m-%d') [flixclusiveorg/Flixclusive@${GITHUB_SHA}]" || true | |
git push |