From 8bd0d185aeb1aa1edf1e8d4697d769a9f49df2de Mon Sep 17 00:00:00 2001 From: John Betaro <114379310+JohnBetaro@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:16:42 +0100 Subject: [PATCH 1/5] Create android.yml --- .github/workflows/android.yml | 76 +++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..3f81740 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,76 @@ +name: android + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v3 + + - uses: subosito/flutter-action@v2 + + - name: Build APKs + run: | + sed -i 's/signingConfig signingConfigs.release//g' android/app/build.gradle + flutter build apk && flutter build apk --split-per-abi + + - name: Sign APKs + env: + KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} + KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }} + run: | + echo "${KEYSTORE_BASE64}" | base64 -d > apksign.keystore + for apk in ./build/app/outputs/flutter-apk/*-release*.apk; do + out=${apk/-release/-release-signed} + ${ANDROID_HOME}/build-tools/30.0.2/apksigner sign --ks apksign.keystore --ks-pass env:KEYSTORE_PASS --out "${out}" "${apk}" + echo "$(sha256sum ${out})" + done + rm apksign.keystore + + - name: Create Release And Upload APKs + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GAT }} + tag: "v${{ steps.compare_versions.outputs.version }}-beta" + artifacts: ./build/app/outputs/flutter-apk/*-signed*.apk + continue-on-error: true + + - name: Wait For 10 Seconds + run: sleep 10 + + - name: Verify If APKs Have Been Uploaded + id: check_for_apk + run: | + release_info=$(curl -s "https://api.github.com/repos/ImranR98/Obtainium/releases/latest" -H "Authorization: Bearer ${{ secrets.GAT }}") + apk_asset_count=$(echo $release_info | jq '.assets | length') + release_id=$(echo $release_info | jq -r '.id') + if [[ $apk_asset_count -eq 0 ]]; then + echo "Deleting the release $release_id" + echo "::set-output name=delete_latest_release::true" + else + echo "APK found. Not deleting the release $release_id" + echo "::set-output name=delete_latest_release::false" + fi + + - name: Delete The Latest Release If No APKs Found + uses: ClementTsang/delete-tag-and-release@v0.3.1 + with: + delete_release: true + tag_name: "v${{ steps.compare_versions.outputs.version }}-beta" + env: + GITHUB_TOKEN: ${{ secrets.GAT }} + if: steps.check_for_apk.outputs.delete_latest_release == 'true' + + - name: Archive Reports For Job + uses: actions/upload-artifact@v3 + with: + name: reports + path: '*/build/reports' + if: ${{ always() }} From 102b9da617c80ff9aaf2713ac5edf41e6c0b556a Mon Sep 17 00:00:00 2001 From: John Betaro <114379310+JohnBetaro@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:19:46 +0100 Subject: [PATCH 2/5] Update android.yml --- .github/workflows/android.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 3f81740..608c64a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -34,11 +34,17 @@ jobs: done rm apksign.keystore + - name: Extract Version + id: extract_version + run: | + VERSION=$(grep -oP "currentVersion = '\K[^']+" lib/main.dart) + echo "::set-output name=version::$VERSION" + - name: Create Release And Upload APKs uses: ncipollo/release-action@v1 with: token: ${{ secrets.GAT }} - tag: "v${{ steps.compare_versions.outputs.version }}-beta" + tag: "v${{ steps.extract_version.outputs.version }}-beta" artifacts: ./build/app/outputs/flutter-apk/*-signed*.apk continue-on-error: true From 6935bff244d98876f46c919b9bacb0e2b48b7b37 Mon Sep 17 00:00:00 2001 From: John Betaro <114379310+JohnBetaro@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:22:29 +0100 Subject: [PATCH 3/5] Update android.yml --- .github/workflows/android.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 608c64a..5ad5a55 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -45,6 +45,7 @@ jobs: with: token: ${{ secrets.GAT }} tag: "v${{ steps.extract_version.outputs.version }}-beta" + prerelease: true artifacts: ./build/app/outputs/flutter-apk/*-signed*.apk continue-on-error: true From ae0cd74b0e59bebeb2f4e54fc4ab6c44e14fd651 Mon Sep 17 00:00:00 2001 From: John Betaro <114379310+JohnBetaro@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:29:03 +0100 Subject: [PATCH 4/5] Update android.yml --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 5ad5a55..b494ac7 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -70,7 +70,7 @@ jobs: uses: ClementTsang/delete-tag-and-release@v0.3.1 with: delete_release: true - tag_name: "v${{ steps.compare_versions.outputs.version }}-beta" + tag_name: "v${{ steps.extract_version.outputs.version }}-beta" env: GITHUB_TOKEN: ${{ secrets.GAT }} if: steps.check_for_apk.outputs.delete_latest_release == 'true' From 4304251e1e1b0ac66ffcd0c7e0e1bcd9c6d87924 Mon Sep 17 00:00:00 2001 From: John Betaro <114379310+JohnBetaro@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:31:42 +0100 Subject: [PATCH 5/5] Remove checking for APKs This is because I couldn't check for prereleases because I don't know how, maybe you can. --- .github/workflows/android.yml | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b494ac7..9ccee7f 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -47,34 +47,7 @@ jobs: tag: "v${{ steps.extract_version.outputs.version }}-beta" prerelease: true artifacts: ./build/app/outputs/flutter-apk/*-signed*.apk - continue-on-error: true - - - name: Wait For 10 Seconds - run: sleep 10 - - - name: Verify If APKs Have Been Uploaded - id: check_for_apk - run: | - release_info=$(curl -s "https://api.github.com/repos/ImranR98/Obtainium/releases/latest" -H "Authorization: Bearer ${{ secrets.GAT }}") - apk_asset_count=$(echo $release_info | jq '.assets | length') - release_id=$(echo $release_info | jq -r '.id') - if [[ $apk_asset_count -eq 0 ]]; then - echo "Deleting the release $release_id" - echo "::set-output name=delete_latest_release::true" - else - echo "APK found. Not deleting the release $release_id" - echo "::set-output name=delete_latest_release::false" - fi - - - name: Delete The Latest Release If No APKs Found - uses: ClementTsang/delete-tag-and-release@v0.3.1 - with: - delete_release: true - tag_name: "v${{ steps.extract_version.outputs.version }}-beta" - env: - GITHUB_TOKEN: ${{ secrets.GAT }} - if: steps.check_for_apk.outputs.delete_latest_release == 'true' - + - name: Archive Reports For Job uses: actions/upload-artifact@v3 with: