From 1e34fa18e2a14e8a66eb3ddf13012e374b062b52 Mon Sep 17 00:00:00 2001 From: siritami <102145692+FiorenMas@users.noreply.github.com> Date: Tue, 7 Nov 2023 00:17:52 +0700 Subject: [PATCH] Change method check new patch - No longer need .txt file - Easier manual patch - Special thanks to Aisrsa for nice idea --- .github/workflows/Sync-Fork.yaml | 16 ---- .github/workflows/ci.yml | 77 +++++++++++++++ .../patch-revanced-extended-android-6-7.yml | 40 ++++++++ .github/workflows/patch-revanced-extended.yml | 40 ++++++++ .../{patch.yml => patch-revanced.yml} | 95 +------------------ README.md | 2 + src/build/Revanced-1.sh | 5 - src/build/Revanced-2.sh | 5 - src/build/Revanced-3.sh | 5 - src/build/Revanced-Extended-Android-6-7.sh | 5 - src/build/Revanced-Extended.sh | 5 - src/build/ci.sh | 28 ++++++ src/build/utils.sh | 39 +++++--- 13 files changed, 214 insertions(+), 148 deletions(-) delete mode 100644 .github/workflows/Sync-Fork.yaml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/patch-revanced-extended-android-6-7.yml create mode 100644 .github/workflows/patch-revanced-extended.yml rename .github/workflows/{patch.yml => patch-revanced.yml} (53%) create mode 100644 src/build/ci.sh diff --git a/.github/workflows/Sync-Fork.yaml b/.github/workflows/Sync-Fork.yaml deleted file mode 100644 index a2c9d6e..0000000 --- a/.github/workflows/Sync-Fork.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: Automatic Sync fork -on: -# schedule: -# - cron: '0 0 */15 * *' - workflow_dispatch: { } -jobs: - sync: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - run: gh repo sync $REPOSITORY -b $BRANCH_NAME - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPOSITORY: ${{ github.repository }} - BRANCH_NAME: ${{ github.ref_name }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0f6efd8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: Check new patch +on: + schedule: + - cron: "0 21 * * *" + workflow_dispatch: +jobs: + check-rv: + name: Check new patch Revanced + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Check new patch ReVanced + id: check-rv + run: bash src/build/ci.sh ReVanced/revanced-patches youtube-revanced.apk + env: + repository: ${{ github.repository }} + + outputs: + check_rv: ${{ steps.check-rv.outputs.new_patch }} + + check-rve: + name: Check new patch Revanced Extended + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Check new patch Revanced Extended + id: check-rve + run: bash src/build/ci.sh inotia00/revanced-patches youtube-revanced-extended.apk + env: + repository: ${{ github.repository }} + + outputs: + check_rve: ${{ steps.check-rve.outputs.new_patch }} + + check-rve67: + name: Check new patch Revanced For Android 6 & 7 + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Check new patch Revanced For Android 6 & 7 + id: check-rve67 + run: bash src/build/ci.sh kitadai31/revanced-patches-android6-7 youtube-revanced-extended-android-6-7.apk + env: + repository: ${{ github.repository }} + + outputs: + check_rve67: ${{ steps.check-rve67.outputs.new_patch }} + + Patch-Revanced: + name: Patch Revanced + permissions: write-all + needs: check-rv + uses: ./.github/workflows/patch-revanced.yml + if: ${{ needs.check-rv.outputs.check_rv == 1 }} + secrets: inherit + + Patch-Revanced-Extended: + name: Patch Revanced Extended + permissions: write-all + needs: check-rve + uses: ./.github/workflows/patch-revanced-extended.yml + if: ${{ needs.check-rve.outputs.check_rve == 1 }} + secrets: inherit + + Patch-Revanced-For-Android-6-7: + name: Patch Revanced Extended For Android 6 & 7 + permissions: write-all + needs: check-rve67 + uses: ./.github/workflows/patch-revanced-extended-android-6-7.yml + if: ${{ needs.check-rve67.outputs.check_rve67 == 1 }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/patch-revanced-extended-android-6-7.yml b/.github/workflows/patch-revanced-extended-android-6-7.yml new file mode 100644 index 0000000..87c84bf --- /dev/null +++ b/.github/workflows/patch-revanced-extended-android-6-7.yml @@ -0,0 +1,40 @@ +name: Patch Revanced Extended Android 6 & 7 +on: + workflow_dispatch: + workflow_call: +jobs: + patch: + name: Patch Revanced Extended for Android 6 & 7 + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up jdk + uses: actions/setup-java@v3.11.0 + with: + distribution: 'zulu' + java-version: '17' + + - name: Patch apk + run: bash src/build/Revanced-Extended-Android-6-7.sh + env: + repository: ${{ github.repository }} + + - name: Generate release info + run: | + echo " + **Change log** :point_down: + [Revanced](https://github.com/revanced/revanced-patches/releases/latest) + [Revanced Extended](https://github.com/inotia00/revanced-patches/releases/latest) + [Revanced Extended for Android 6 & 7](https://github.com/kitadai31/revanced-patches-android6-7/releases/latest) + "> ${{ github.workspace }}-CHANGELOG.txt + + - name: Release + uses: softprops/action-gh-release@v0.1.15 + with: + files: | + ./release/* + name: Revanced & Revanced Extended + tag_name: all + body_path: ${{ github.workspace }}-CHANGELOG.txt \ No newline at end of file diff --git a/.github/workflows/patch-revanced-extended.yml b/.github/workflows/patch-revanced-extended.yml new file mode 100644 index 0000000..ff8c445 --- /dev/null +++ b/.github/workflows/patch-revanced-extended.yml @@ -0,0 +1,40 @@ +name: Patch Revanced Extended +on: + workflow_dispatch: + workflow_call: +jobs: + patch: + name: Patch Revanced Extended + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up jdk + uses: actions/setup-java@v3.11.0 + with: + distribution: 'zulu' + java-version: '17' + + - name: Patch apk + run: bash src/build/Revanced-Extended.sh + env: + repository: ${{ github.repository }} + + - name: Generate release info + run: | + echo " + **Change log** :point_down: + [Revanced](https://github.com/revanced/revanced-patches/releases/latest) + [Revanced Extended](https://github.com/inotia00/revanced-patches/releases/latest) + [Revanced Extended for Android 6 & 7](https://github.com/kitadai31/revanced-patches-android6-7/releases/latest) + "> ${{ github.workspace }}-CHANGELOG.txt + + - name: Release + uses: softprops/action-gh-release@v0.1.15 + with: + files: | + ./release/* + name: Revanced & Revanced Extended + tag_name: all + body_path: ${{ github.workspace }}-CHANGELOG.txt \ No newline at end of file diff --git a/.github/workflows/patch.yml b/.github/workflows/patch-revanced.yml similarity index 53% rename from .github/workflows/patch.yml rename to .github/workflows/patch-revanced.yml index 265ab98..05595ca 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch-revanced.yml @@ -1,9 +1,7 @@ -name: Patch +name: Patch Revanced on: -# push: - schedule: - - cron: "0 21 * * *" workflow_dispatch: + workflow_call: jobs: patch1: name: Patch Revanced-1 @@ -37,12 +35,9 @@ jobs: with: files: | ./release/* - revanced-version.txt name: Revanced & Revanced Extended tag_name: all body_path: ${{ github.workspace }}-CHANGELOG.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} patch2: name: Patch Revanced-2 @@ -76,12 +71,9 @@ jobs: with: files: | ./release/* - revanced-version.txt name: Revanced & Revanced Extended tag_name: all body_path: ${{ github.workspace }}-CHANGELOG.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} patch3: name: Patch Revanced-3 @@ -115,87 +107,6 @@ jobs: with: files: | ./release/* - revanced-version.txt name: Revanced & Revanced Extended tag_name: all - body_path: ${{ github.workspace }}-CHANGELOG.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - patch4: - name: Patch Revanced Extended - permissions: write-all - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up jdk - uses: actions/setup-java@v3.11.0 - with: - distribution: 'zulu' - java-version: '17' - - - name: Patch apk - run: bash src/build/Revanced-Extended.sh - env: - repository: ${{ github.repository }} - - - name: Generate release info - run: | - echo " - **Change log** :point_down: - [Revanced](https://github.com/revanced/revanced-patches/releases/latest) - [Revanced Extended](https://github.com/inotia00/revanced-patches/releases/latest) - [Revanced Extended for Android 6 & 7](https://github.com/kitadai31/revanced-patches-android6-7/releases/latest) - "> ${{ github.workspace }}-CHANGELOG.txt - - - name: Release - uses: softprops/action-gh-release@v0.1.15 - with: - files: | - ./release/* - revanced-extended-version.txt - name: Revanced & Revanced Extended - tag_name: all - body_path: ${{ github.workspace }}-CHANGELOG.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - patch5: - name: Patch Revanced Extended for Android 6 & 7 - permissions: write-all - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up jdk - uses: actions/setup-java@v3.11.0 - with: - distribution: 'zulu' - java-version: '17' - - - name: Patch apk - run: bash src/build/Revanced-Extended-Android-6-7.sh - env: - repository: ${{ github.repository }} - - - name: Generate release info - run: | - echo " - **Change log** :point_down: - [Revanced](https://github.com/revanced/revanced-patches/releases/latest) - [Revanced Extended](https://github.com/inotia00/revanced-patches/releases/latest) - [Revanced Extended for Android 6 & 7](https://github.com/kitadai31/revanced-patches-android6-7/releases/latest) - "> ${{ github.workspace }}-CHANGELOG.txt - - - name: Release - uses: softprops/action-gh-release@v0.1.15 - with: - files: | - ./release/* - revanced-extended-android-6-7-version.txt - name: Revanced & Revanced Extended - tag_name: all - body_path: ${{ github.workspace }}-CHANGELOG.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + body_path: ${{ github.workspace }}-CHANGELOG.txt \ No newline at end of file diff --git a/README.md b/README.md index 5e7dced..406c3b7 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,8 @@ Download --- +#### Special thanks to Aisrsa for nice idea :heartpulse: + # ⚠️ License: [@luxysiv](https://github.com/luxysiv/yt-revanced-nonroot) - [GPL-3.0](https://github.com/luxysiv/revanced-nonroot/blob/main/LICENSE) diff --git a/src/build/Revanced-1.sh b/src/build/Revanced-1.sh index 059f0dd..c3d00fd 100644 --- a/src/build/Revanced-1.sh +++ b/src/build/Revanced-1.sh @@ -4,11 +4,6 @@ source ./src/build/utils.sh ################################################# -# Checking new patch -checker "revanced/revanced-patches" "revanced" - -################################################# - # Download requirements dl_gh "revanced-patches revanced-cli revanced-integrations" "revanced" "latest" diff --git a/src/build/Revanced-2.sh b/src/build/Revanced-2.sh index 6be1853..1b354c4 100644 --- a/src/build/Revanced-2.sh +++ b/src/build/Revanced-2.sh @@ -4,11 +4,6 @@ source ./src/build/utils.sh ################################################# -# Checking new patch -checker "revanced/revanced-patches" "revanced" - -################################################# - # Download requirements dl_gh "revanced-patches revanced-cli revanced-integrations" "revanced" "latest" diff --git a/src/build/Revanced-3.sh b/src/build/Revanced-3.sh index fe61c70..8a4ba42 100644 --- a/src/build/Revanced-3.sh +++ b/src/build/Revanced-3.sh @@ -4,11 +4,6 @@ source ./src/build/utils.sh ################################################# -# Checking new patch -checker "revanced/revanced-patches" "revanced" - -################################################# - # Download requirements dl_gh "revanced-patches revanced-cli revanced-integrations" "revanced" "latest" diff --git a/src/build/Revanced-Extended-Android-6-7.sh b/src/build/Revanced-Extended-Android-6-7.sh index d0df010..0fdaf33 100644 --- a/src/build/Revanced-Extended-Android-6-7.sh +++ b/src/build/Revanced-Extended-Android-6-7.sh @@ -4,11 +4,6 @@ source src/build/utils.sh ################################################# -# Checking new patch -checker "kitadai31/revanced-patches-android6-7" "revanced-extended-android-6-7" - -################################################# - # Download requirements dl_gh "revanced-patches-android6-7 revanced-integrations" "kitadai31" "latest" dl_gh "revanced-cli" "revanced" "tags/v3.1.1" diff --git a/src/build/Revanced-Extended.sh b/src/build/Revanced-Extended.sh index ff7bd92..b91c082 100644 --- a/src/build/Revanced-Extended.sh +++ b/src/build/Revanced-Extended.sh @@ -4,11 +4,6 @@ source src/build/utils.sh ################################################# -# Checking new patch -checker "inotia00/revanced-patches" "revanced-extended" - -################################################# - # Download requirements dl_gh "revanced-patches revanced-integrations revanced-cli" "inotia00" "latest" diff --git a/src/build/ci.sh b/src/build/ci.sh new file mode 100644 index 0000000..1d513dd --- /dev/null +++ b/src/build/ci.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Check new patch: +get_date() { + local assets asset name updated_at + assets=$(curl -s https://api.github.com/repos/"$1"/releases/latest | jq '.assets') + for asset in $(echo "$assets" | jq -r '.[] | @base64'); do + asset=$(echo "$asset" | base64 --decode) + name=$(echo "$asset" | jq -r '.name') + updated_at=$(echo "$asset" | jq -r '.updated_at') + [[ $name =~ "$2" ]] && echo "$updated_at" + done +} +checker(){ + local date1 date2 date1_sec date1_sec repo=$1 ur_repo=$repository check=$2 + date1=$(get_date "$repo" "patches.json") + date2=$(get_date "$ur_repo" "$check") + date1_sec=$(date -d "$date1" +%s) + date2_sec=$(date -d "$date2" +%s) + if [ -z "$date2" ] || [ "$date1_sec" -gt "$date2_sec" ]; then + echo "new_patch=1" >> $GITHUB_OUTPUT + echo "New patch, building..." + elif [ "$date1_sec" -lt "$date2_sec" ]; then + echo "new_patch=0" >> $GITHUB_OUTPUT + echo "Old patch, not build." + fi +} +checker $1 $2 \ No newline at end of file diff --git a/src/build/utils.sh b/src/build/utils.sh index 2a55d13..d886285 100644 --- a/src/build/utils.sh +++ b/src/build/utils.sh @@ -4,21 +4,30 @@ mkdir ./release ################################################# -# Checking new patch: -checker() { -curl -sL https://api.github.com/repos/$1/releases/latest > json.txt -latest_version=$(jq -r '.name' json.txt) -curl -sL "https://api.github.com/repos/$repository/releases/latest" | jq -r '.assets[] | select(.name == "'$2'-version.txt") | .browser_download_url' | xargs curl -sLO -cur_version=$(cat $2-version.txt) -if [ "$latest_version" = "$cur_version" ]; then - echo "Old patch, not build!" - rm -f ./json.txt ./$2-version.txt - exit 0 -else - echo "New patch, building..." - rm -f ./json.txt ./$2-version.txt - echo $latest_version > $2-version.txt -fi +# Check new patch: +get_date() { + local assets asset name updated_at + assets=$(curl -s https://api.github.com/repos/"$1"/releases/latest | jq '.assets') + for asset in $(echo "$assets" | jq -r '.[] | @base64'); do + asset=$(echo "$asset" | base64 --decode) + name=$(echo "$asset" | jq -r '.name') + updated_at=$(echo "$asset" | jq -r '.updated_at') + [[ $name =~ "$2" ]] && echo "$updated_at" + done +} +checker(){ + local date1 date2 date1_sec date1_sec repo=$1 ur_repo=$GITHUB_REPOSITORY check=$2 + date1=$(get_date "$repo" "patches.json") + date2=$(get_date "$ur_repo" "$check") + date1_sec=$(date -d "$date1" +%s) + date2_sec=$(date -d "$date2" +%s) + if [ -z "$date2" ] || [ "$date1_sec" -gt "$date2_sec" ]; then + export new_patch=1 + echo "New patch, building..." + elif [ "$date1_sec" -lt "$date2_sec" ]; then + export new_patch=0 + echo "Old patch, not build." + fi } #################################################