Compile and release beta build #47
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: Compile and release beta build | |
on: | |
workflow_dispatch: | |
branches: | |
- beta | |
jobs: | |
build-android: | |
name: Build Android .apk and .aab | |
runs-on: ubuntu-latest | |
env: | |
ANDROID_AAB_RELEASE_PATH: build/app/outputs/bundle/release | |
ANDROID_APK_RELEASE_PATH: build/app/outputs/apk/release | |
outputs: | |
VERSION_NAME: ${{ steps.save_version.outputs.version_name }} | |
VERSION_NUMBER: ${{ steps.save_version.outputs.version_number }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: beta | |
- name: Decode android/app/keystore.jks | |
run: echo "${{ secrets.KEYSTORE_JKS }}" | base64 --decode > android/app/keystore.jks | |
- name: Decode android/key.properties | |
run: echo "${{ secrets.KEY_PROPERTIES }}" | base64 --decode > android/key.properties | |
- name: Decode .env | |
run: echo "${{ secrets.ENV }}" | base64 --decode > .env | |
- name: Read pubspec.yaml | |
uses: adore-me/read-yaml@v1.0.0 | |
id: read_pubspec | |
with: | |
file: './pubspec.yaml' | |
key-path: '["version"]' | |
- name: Save version on env variable | |
id: save_version | |
run: | | |
version=${{ steps.read_pubspec.outputs.data }} | |
IFS='+' | |
read -r -a split <<< "$version" | |
echo "VERSION_NAME=$(echo ${split[0]})" >> $GITHUB_ENV | |
echo "version_name=${split[0]}" >> $GITHUB_OUTPUT | |
echo "version_number=${split[1]}" >> $GITHUB_OUTPUT | |
- name: Update KeyStore password in gradle properties | |
run: sed -i 's/#{KEYSTORE_PASS}#/${{ secrets.KEYSTORE_PASS }}/g' android/key.properties | |
- name: Update KeyStore key password in gradle properties | |
run: sed -i 's/#{KEYSTORE_KEY_PASS}#/${{ secrets.KEYSTORE_KEY_PASS }}/g' android/key.properties | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '18.x' | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- run: flutter clean | |
- run: flutter pub get | |
- run: flutter build apk --release | |
- run: flutter build appbundle --release | |
- name: Rename apk | |
run: mv $ANDROID_APK_RELEASE_PATH/app-release.apk $ANDROID_APK_RELEASE_PATH/AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.apk | |
- name: Rename aab | |
run: mv $ANDROID_AAB_RELEASE_PATH/app-release.aab $ANDROID_AAB_RELEASE_PATH/AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab | |
- name: Copy apk to project root | |
run: cp $ANDROID_APK_RELEASE_PATH/AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.apk AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.apk | |
- name: Copy aab to project root | |
run: cp $ANDROID_AAB_RELEASE_PATH/AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: android | |
path: | | |
AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab | |
AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.apk | |
release-builds-github: | |
name: Release beta build to GitHub | |
runs-on: ubuntu-latest | |
needs: [build-android] | |
env: | |
VERSION_NAME: ${{ needs.build-android.outputs.VERSION_NAME }} | |
VERSION_NUMBER: ${{ needs.build-android.outputs.VERSION_NUMBER }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: beta | |
- name: Create builds directory | |
run: mkdir releases | |
- name: Download Android artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: android | |
path: releases/ | |
- name: Release to GitHub | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "releases/*" | |
token: ${{ secrets.GH_TOKEN }} | |
tag: '${{ env.VERSION_NAME }}_(${{ env.VERSION_NUMBER }})' | |
name: v${{ env.VERSION_NAME }} | |
draft: true | |
prerelease: true | |
commit: ${{ github.sha }} | |
release-build-google-play: | |
name: Release Android beta build to the Google Play Store | |
runs-on: ubuntu-latest | |
needs: [build-android] | |
env: | |
VERSION_NAME: ${{ needs.build-android.outputs.VERSION_NAME }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: beta | |
- name: Download Android artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: android | |
- name: Release app to Google Play | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }} | |
packageName: com.jgeek00.adguard_home_manager | |
releaseFiles: AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab | |
track: beta | |
status: draft | |
releaseName: ${{ env.VERSION_NAME }} |