From 8d4d527f60e66b396e0e04d1175b8f1057e1c7c8 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Fri, 24 Nov 2023 20:19:39 +0700 Subject: [PATCH 01/15] ci(build): add compile arguments field --- .github/workflows/pr-build.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 993298dcdc..e4c5344a54 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -17,6 +17,7 @@ on: description: Cache type: boolean default: true + # Application configuration app-flavour: description: App flavour @@ -26,10 +27,15 @@ on: - release - debug - profile + # Pull Request pr-number: description: PR number (No hashtag) required: true + + # Additional + flutter-build-arguments: + description: Flutter build arguments run-name: "Build PR ${{ inputs.pr-number }}" @@ -41,7 +47,7 @@ jobs: contents: read pull-requests: write steps: - - name: Setup + - name: Setup the PR's repository env: GH_TOKEN: ${{ github.token }} run: | @@ -50,10 +56,10 @@ jobs: gh repo set-default ${{ github.repository }} gh pr checkout ${{ inputs.pr-number }} - echo "DATETIME=$( TZ='UTC+0' date --rfc-email )" >> $GITHUB_ENV + echo "DATETIME=$(TZ='UTC+0' date --rfc-email)" >> $GITHUB_ENV echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: Checkout + - name: Checkout the repository uses: actions/checkout@v4 with: persist-credentials: false @@ -76,6 +82,9 @@ jobs: - name: Generate files with Builder run: dart run build_runner build --delete-conflicting-outputs + + - name: Dart static analysis + uses: zgosalvez/github-actions-analyze-dart@v3 - name: Build with Flutter continue-on-error: true @@ -83,7 +92,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - flutter build apk --${{ inputs.app-flavour }}; + flutter build apk --${{ inputs.app-flavour }} ${{ inputs.flutter-build-arguments }}; - name: Prepare to comment run: | @@ -109,12 +118,12 @@ jobs: ### ⚙️ Overview - App flavor: ${{ inputs.app-flavour }} - Branch: ${{ inputs.flutter-branch }} + - Compile arguments: ${{ inputs.flutter-build-arguments }} - Start time: ${{ env.DATETIME }} - name: Upload build uses: actions/upload-artifact@v3 with: - if-no-files-found: error name: revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavour }})-${{ inputs.flutter-branch }} path: | build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk From 61a12096b246b9664778e6b0762e22c4ebdea2b7 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 25 Nov 2023 09:32:39 +0700 Subject: [PATCH 02/15] ci(build): output artefact url to comment --- .github/workflows/pr-build.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index e4c5344a54..30bd56e806 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -102,6 +102,23 @@ jobs: echo "MESSAGE=🚫 ReVanced Manager ${{ env.COMMIT_HASH }} build failed." >> $GITHUB_ENV fi + - name: Upload build + uses: actions/upload-artifact@v3 + with: + name: revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavour }})-${{ inputs.flutter-branch }} + path: | + build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk + build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk.sha1 + + - name: Get artifact URL + run: | + sudo apt install jq + ARTIFACT_URL=$(curl \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -s "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" | \ + jq -r ".artifacts[] | select(.name==\"revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavour }})-${{ inputs.flutter-branch }}\") | .archive_download_url") + echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV + - name: "Comment to Pull Request #${{ inputs.pr-number }}" uses: thollander/actions-comment-pull-request@v2 with: @@ -113,18 +130,12 @@ jobs: ${{ env.MESSAGE }} - You can see more details in run [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})! + You can see more details in run [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}} + + Download the apk at ${{ env.ARTIFACT_URL }} ### ⚙️ Overview - App flavor: ${{ inputs.app-flavour }} - Branch: ${{ inputs.flutter-branch }} - Compile arguments: ${{ inputs.flutter-build-arguments }} - Start time: ${{ env.DATETIME }} - - - name: Upload build - uses: actions/upload-artifact@v3 - with: - name: revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavour }})-${{ inputs.flutter-branch }} - path: | - build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk - build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk.sha1 From 4a94d8668340072dbfa13f926bde135def6fcb54 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 25 Nov 2023 09:34:39 +0700 Subject: [PATCH 03/15] ci(build): dart static check --- .github/workflows/pr-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 30bd56e806..11a1f283ab 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -130,7 +130,7 @@ jobs: ${{ env.MESSAGE }} - You can see more details in run [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}} + Checkout the Dart static analyse check at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). Download the apk at ${{ env.ARTIFACT_URL }} From 7bb05a5888ffea440b3d08b62f5c69f639da1e9f Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 25 Nov 2023 09:34:54 +0700 Subject: [PATCH 04/15] ci(build): refactor input --- .github/workflows/pr-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 11a1f283ab..4037f41a8c 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -3,6 +3,7 @@ name: PR Build on: workflow_dispatch: inputs: + # Flutter flutter-branch: description: Flutter branch From 944dcdbdf91fac1b9259c3b2238ecae9657f5669 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 25 Nov 2023 09:37:21 +0700 Subject: [PATCH 05/15] ci(build): clarify artefact comment --- .github/workflows/pr-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 4037f41a8c..2e3c729750 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -133,7 +133,7 @@ jobs: Checkout the Dart static analyse check at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). - Download the apk at ${{ env.ARTIFACT_URL }} + Download the [application artefact](${{ env.ARTIFACT_URL }}). ### ⚙️ Overview - App flavor: ${{ inputs.app-flavour }} From 81a8671276076051e70c43016f50c4e4ee33579e Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 25 Nov 2023 09:40:21 +0700 Subject: [PATCH 06/15] =?UTF-8?q?ci(build):=20american=20=F0=9F=A6=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 2e3c729750..b5220bc058 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -131,9 +131,9 @@ jobs: ${{ env.MESSAGE }} - Checkout the Dart static analyse check at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). + Checkout the Dart static analyze check at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). - Download the [application artefact](${{ env.ARTIFACT_URL }}). + Directly download the [application artifact](${{ env.ARTIFACT_URL }}) here. ### ⚙️ Overview - App flavor: ${{ inputs.app-flavour }} From 4c14e6172a9e57f2d25779bc842e704f9038ea4b Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 25 Nov 2023 09:56:42 +0700 Subject: [PATCH 07/15] ci(build): remove artefact url --- .github/workflows/pr-build.yml | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index b5220bc058..da64c29e51 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -20,7 +20,7 @@ on: default: true # Application configuration - app-flavour: + app-flavor: description: App flavour default: 'release' type: choice @@ -31,7 +31,7 @@ on: # Pull Request pr-number: - description: PR number (No hashtag) + description: PR number required: true # Additional @@ -93,7 +93,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - flutter build apk --${{ inputs.app-flavour }} ${{ inputs.flutter-build-arguments }}; + flutter build apk --${{ inputs.app-flavor }} ${{ inputs.flutter-build-arguments }}; - name: Prepare to comment run: | @@ -106,19 +106,10 @@ jobs: - name: Upload build uses: actions/upload-artifact@v3 with: - name: revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavour }})-${{ inputs.flutter-branch }} + name: revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavor }})-${{ inputs.flutter-branch }} path: | - build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk - build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk.sha1 - - - name: Get artifact URL - run: | - sudo apt install jq - ARTIFACT_URL=$(curl \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -s "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" | \ - jq -r ".artifacts[] | select(.name==\"revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavour }})-${{ inputs.flutter-branch }}\") | .archive_download_url") - echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV + build/app/outputs/flutter-apk/app-${{ inputs.app-flavor }}.apk + build/app/outputs/flutter-apk/app-${{ inputs.app-flavor }}.apk.sha1 - name: "Comment to Pull Request #${{ inputs.pr-number }}" uses: thollander/actions-comment-pull-request@v2 @@ -131,12 +122,10 @@ jobs: ${{ env.MESSAGE }} - Checkout the Dart static analyze check at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). - - Directly download the [application artifact](${{ env.ARTIFACT_URL }}) here. + Checkout the Dart static analyze check or download the artifact at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). ### ⚙️ Overview - - App flavor: ${{ inputs.app-flavour }} + - App flavor: ${{ inputs.app-flavor }} - Branch: ${{ inputs.flutter-branch }} - Compile arguments: ${{ inputs.flutter-build-arguments }} - Start time: ${{ env.DATETIME }} From 3ca879814abc42201e2b6af17adee74c425614da Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Fri, 1 Dec 2023 18:47:25 +0700 Subject: [PATCH 08/15] ci(build): step name consistency Co-authored-by: Palm --- .github/workflows/pr-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index da64c29e51..a07bdc9d6e 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -84,7 +84,7 @@ jobs: - name: Generate files with Builder run: dart run build_runner build --delete-conflicting-outputs - - name: Dart static analysis + - name: Analyze Dart code uses: zgosalvez/github-actions-analyze-dart@v3 - name: Build with Flutter From a97c39242d45b2ddfb792b8c2d181e7de8059e30 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Fri, 1 Dec 2023 18:57:04 +0700 Subject: [PATCH 09/15] ci(build): check if compile argument is supplied --- .github/workflows/pr-build.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index a07bdc9d6e..aa68acee01 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -98,9 +98,12 @@ jobs: - name: Prepare to comment run: | if [[ "${{ steps.flutter-build.outcome }}" == "success" ]]; then - echo "MESSAGE=✅ ReVanced Manager ${{ env.COMMIT_HASH }} build succeeded." >> $GITHUB_ENV + echo "STATUS_MESSAGE=✅ ReVanced Manager ${{ env.COMMIT_HASH }} build succeeded." >> $GITHUB_ENV else - echo "MESSAGE=🚫 ReVanced Manager ${{ env.COMMIT_HASH }} build failed." >> $GITHUB_ENV + echo "STATUS_MESSAGE=🚫 ReVanced Manager ${{ env.COMMIT_HASH }} build failed." >> $GITHUB_ENV + fi + if [ -n "{{ inputs.flutter-build-arguments }}" ]; then + echo "COMPILE_ARGUMENT_MESSAGE=- Compile arguments: ${{ inputs.flutter-build-arguments }}" >> $GITHUB_ENV fi - name: Upload build @@ -120,12 +123,12 @@ jobs: message: | ## ⚒️ ReVanced PR Build workflow - ${{ env.MESSAGE }} + ${{ env.STATUS_MESSAGE }} Checkout the Dart static analyze check or download the artifact at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). ### ⚙️ Overview + - Start time: ${{ env.DATETIME }} - App flavor: ${{ inputs.app-flavor }} - Branch: ${{ inputs.flutter-branch }} - - Compile arguments: ${{ inputs.flutter-build-arguments }} - - Start time: ${{ env.DATETIME }} + ${{ env.COMPILE_ARGUMENT_MESSAGE }} From de1a2259e4e0d4e88ea73d1f7b967b91c9d319a3 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Fri, 1 Dec 2023 18:57:53 +0700 Subject: [PATCH 10/15] ci(build): remove start time from overview --- .github/workflows/pr-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index aa68acee01..dcb91e8c06 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -57,7 +57,6 @@ jobs: gh repo set-default ${{ github.repository }} gh pr checkout ${{ inputs.pr-number }} - echo "DATETIME=$(TZ='UTC+0' date --rfc-email)" >> $GITHUB_ENV echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Checkout the repository @@ -128,7 +127,6 @@ jobs: Checkout the Dart static analyze check or download the artifact at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). ### ⚙️ Overview - - Start time: ${{ env.DATETIME }} - App flavor: ${{ inputs.app-flavor }} - Branch: ${{ inputs.flutter-branch }} ${{ env.COMPILE_ARGUMENT_MESSAGE }} From bdc282fcf55d885159640ee09bb3c7964dbecd36 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Fri, 1 Dec 2023 19:03:27 +0700 Subject: [PATCH 11/15] ci(build): cleanup --- .github/workflows/pr-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index dcb91e8c06..836f343c86 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -65,7 +65,7 @@ jobs: persist-credentials: false - name: Setup JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'zulu' @@ -92,7 +92,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - flutter build apk --${{ inputs.app-flavor }} ${{ inputs.flutter-build-arguments }}; + flutter build apk --${{ inputs.app-flavor }} ${{ inputs.flutter-build-arguments }} - name: Prepare to comment run: | From 03ee7f73e2e91729832526cf2d7501949987f14c Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Fri, 1 Dec 2023 22:56:32 +0700 Subject: [PATCH 12/15] ci(build): additional context on build trigger --- .github/workflows/pr-build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 836f343c86..71868c5c75 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -37,8 +37,10 @@ on: # Additional flutter-build-arguments: description: Flutter build arguments - -run-name: "Build PR ${{ inputs.pr-number }}" + additional-description: + description: What's the purpose of triggering? + +run-name: "Build PR ${{ inputs.pr-number }} ${{ inputs.additional-description }}" jobs: build: From aaee8fd762c83547a61bc3b9d3e75e0521a0d86d Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 17 Dec 2023 23:14:08 +0700 Subject: [PATCH 13/15] fix fix --- .github/workflows/pr-build.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 71868c5c75..f897115815 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -65,6 +65,17 @@ jobs: uses: actions/checkout@v4 with: persist-credentials: false + + - name: Setup the PR's repository + env: + GH_TOKEN: ${{ github.token }} + run: | + gh repo clone ${{ github.repository }} + cd revanced-manager + gh repo set-default ${{ github.repository }} + gh pr checkout ${{ inputs.pr-number }} + + echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Setup JDK uses: actions/setup-java@v4 From 2687c4ef8a8a03996bf692d9e7866b9b78a4deb0 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 17 Dec 2023 23:22:37 +0700 Subject: [PATCH 14/15] output branch --- .github/workflows/pr-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index f897115815..0cb0986d65 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -74,6 +74,7 @@ jobs: cd revanced-manager gh repo set-default ${{ github.repository }} gh pr checkout ${{ inputs.pr-number }} + git branch echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV From a91657b13f3beb5b61a8524a1478bf20f48cab30 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 23 Dec 2023 10:23:10 +0700 Subject: [PATCH 15/15] Support Just-In-Time Release build --- .github/workflows/pr-build.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 0cb0986d65..87c99fdc38 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -28,6 +28,7 @@ on: - release - debug - profile + - jit-release # Pull Request pr-number: @@ -37,10 +38,8 @@ on: # Additional flutter-build-arguments: description: Flutter build arguments - additional-description: - description: What's the purpose of triggering? -run-name: "Build PR ${{ inputs.pr-number }} ${{ inputs.additional-description }}" +run-name: "Build PR ${{ inputs.pr-number }}" jobs: build: @@ -115,9 +114,6 @@ jobs: else echo "STATUS_MESSAGE=🚫 ReVanced Manager ${{ env.COMMIT_HASH }} build failed." >> $GITHUB_ENV fi - if [ -n "{{ inputs.flutter-build-arguments }}" ]; then - echo "COMPILE_ARGUMENT_MESSAGE=- Compile arguments: ${{ inputs.flutter-build-arguments }}" >> $GITHUB_ENV - fi - name: Upload build uses: actions/upload-artifact@v3 @@ -143,4 +139,3 @@ jobs: ### ⚙️ Overview - App flavor: ${{ inputs.app-flavor }} - Branch: ${{ inputs.flutter-branch }} - ${{ env.COMPILE_ARGUMENT_MESSAGE }}