diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb33faede2..85ccb6856a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,7 @@ on: [workflow_call, workflow_dispatch] jobs: run: + permissions: write-all runs-on: ubuntu-latest steps: - uses: actions/setup-java@v3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f7609775d..e9430dc066 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,66 +1,67 @@ -name: CI -on: - workflow_dispatch: - schedule: - - cron: "0 16 * * *" - -jobs: - check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Should build? - id: should_build - shell: bash - run: | - source utils.sh - toml_prep "$(cat config.toml)" - - is_youtube_latest() { - v=$(toml_get "YouTube" "version") || version="" - if [ "$v" = latest ]; then - declare -r cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs) - [ -z "$cur_yt" ] && return 1 # empty, fail=>dont build - declare -r last_ver=$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube" | get_largest_ver) - - echo "current yt version: $cur_yt" - echo "latest yt version: $last_ver" - [ "$cur_yt" != "$last_ver" ] # test success=>build, fail=>dont build - else - return 1 # not experimental, dont build - fi - } - - is_patches_latest() { - declare -r last_patches_url=$(wget -nv --header="Authorization: token ${{ secrets.GITHUB_TOKEN }}" -O- https://api.github.com/repos/revanced/revanced-patches/releases/latest | json_get 'browser_download_url' | grep 'jar') - declare -r last_patches=${last_patches_url##*/} - cur_patches=$(sed -n 's/.*Patches: \(.*\)/\1/p' build.md | xargs) - - echo "current patches version: $cur_patches" - echo "latest patches version: $last_patches" - [ "$cur_patches" != "$last_patches" ] # test success=>build, fail=>dont build - } - - if ! git checkout update; then - echo "first time building!" - echo "SHOULD_BUILD=1" >> $GITHUB_OUTPUT - elif is_patches_latest || is_youtube_latest; then - echo "build!" - echo "SHOULD_BUILD=1" >> $GITHUB_OUTPUT - else - echo "dont build!" - echo "SHOULD_BUILD=0" >> $GITHUB_OUTPUT - fi - - outputs: - SHOULD_BUILD: ${{ steps.should_build.outputs.SHOULD_BUILD }} - - build: - needs: check - uses: ./.github/workflows/build.yml - if: ${{ needs.check.outputs.SHOULD_BUILD == 1 }} - secrets: inherit +name: CI +on: + workflow_dispatch: + schedule: + - cron: "0 16 * * *" + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Should build? + id: should_build + shell: bash + run: | + source utils.sh + toml_prep "$(cat config.toml)" + + is_youtube_latest() { + v=$(toml_get "YouTube" "version") || version="" + if [ "$v" = latest ]; then + declare -r cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs) + [ -z "$cur_yt" ] && return 1 # empty, fail=>dont build + declare -r last_ver=$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube" | get_largest_ver) + + echo "current yt version: $cur_yt" + echo "latest yt version: $last_ver" + [ "$cur_yt" != "$last_ver" ] # test success=>build, fail=>dont build + else + return 1 # not experimental, dont build + fi + } + + is_patches_latest() { + declare -r last_patches_url=$(wget -nv --header="Authorization: token ${{ secrets.GITHUB_TOKEN }}" -O- https://api.github.com/repos/revanced/revanced-patches/releases/latest | json_get 'browser_download_url' | grep 'jar') + declare -r last_patches=${last_patches_url##*/} + cur_patches=$(sed -n 's/.*Patches: \(.*\)/\1/p' build.md | xargs) + + echo "current patches version: $cur_patches" + echo "latest patches version: $last_patches" + [ "$cur_patches" != "$last_patches" ] # test success=>build, fail=>dont build + } + + if ! git checkout update; then + echo "first time building!" + echo "SHOULD_BUILD=1" >> $GITHUB_OUTPUT + elif is_patches_latest || is_youtube_latest; then + echo "build!" + echo "SHOULD_BUILD=1" >> $GITHUB_OUTPUT + else + echo "dont build!" + echo "SHOULD_BUILD=0" >> $GITHUB_OUTPUT + fi + + outputs: + SHOULD_BUILD: ${{ steps.should_build.outputs.SHOULD_BUILD }} + + build: + permissions: write-all + needs: check + uses: ./.github/workflows/build.yml + if: ${{ needs.check.outputs.SHOULD_BUILD == 1 }} + secrets: inherit diff --git a/CONFIG.md b/CONFIG.md index 496597f6d9..3e195e1f38 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -1,33 +1,43 @@ -# Config - -Adding a new app is as easy as this: -```toml -[Some-App] -apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url for the app. if not set, uptodown is used. -``` - -## If you'd like to get to know more about other options: - -There exists an example below with all defaults and all the keys explicitly set. -Almost all keys are optional and are assigned their default values if not set explicitly. - -```toml -[Some-App] -app-name = "SomeApp" # if set, app name becomes SomeApp instead of Some-App. default is same as table name. -enabled = true # whether to build the app. default: true -build-mode = "both" # 'both', 'apk' or 'module'. default: apk -allow-alpha-version = false # allow downloading alpha versions from apkmirror. default: false -rip-libs = false # removes all native libs from the app. default: false -excluded-patches = "some-patch" # whitespace seperated list of patches to exclude. default: "" (empty) -included-patches = "patch-name" # whitespace seperated list of patches to include. default: "" (empty) -version = "auto" # 'auto', 'latest' or a custom one e.g. '17.40.41'. default: auto -exclusive-patches = false # exclude all patches by default. default: false -microg-patch = "microg-support" # name of the microg-patch if exists for the app. default: "" (empty) -apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url for the app. if not set, uptodown is used. -module-prop-name = "ytrv-magisk" # explicit magisk module prop name. not explicitly needed to be set. -merge-integrations = true # whether to merge revanced integrations. default: false -arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a' or 'all'. - # this option is sometimes needed to be able to download the apks from apkmirror. default: all -apkmirror-regex = 'APK[^@]*@\([^#]*\)' # regex used to get the dl url in apkmirror. default: APK[^@]*@\([^#]*\) - # this default gets the url to the non-bundle apk. -``` \ No newline at end of file +# Config + +Adding a new app is as easy as this: +```toml +[Some-App] +apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url for the app. +``` + +or: +```toml +[Some-App] +uptodown-dlurl = "https://app.en.uptodown.com/android" # uptodown url. +``` + +## If you'd like to get to know more about other options: + +There exists an example below with all defaults and all the keys explicitly set. +Almost all keys are optional and are assigned their default values if not set explicitly. + +```toml +[Some-App] +app-name = "SomeApp" # if set, app name becomes SomeApp instead of Some-App. default is same as table name. +# this affects the release name and stuff like that +enabled = true # whether to build the app. default: true +build-mode = "both" # 'both', 'apk' or 'module'. default: apk +allow-alpha-version = false # allow downloading alpha versions from apkmirror. default: false +rip-libs = false # removes all native libs from the app. default: false +excluded-patches = "some-patch" # whitespace seperated list of patches to exclude. default: "" (empty) +included-patches = "patch-name" # whitespace seperated list of patches to include. default: "" (empty) +version = "auto" # 'auto', 'latest' or a custom one e.g. '17.40.41'. default: auto +exclusive-patches = false # exclude all patches by default. default: false +microg-patch = "microg-support" # name of the microg-patch if exists for the app. default: "" (empty) +apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url. if not set, uptodown dl url is used. +uptodown-dlurl = "https://spotify.en.uptodown.com/android" # uptodown url. if not set, apkmirror dl url is used. apkmirror is prioritized +module-prop-name = "ytrv-magisk" # explicit magisk module prop name. not explicitly needed to be set. +merge-integrations = true # whether to merge revanced integrations. default: false +arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a' or 'all'. +# this option is sometimes needed to be able to download the apks from apkmirror. default: all +# and does not affect anything else + +apkmirror-regex = 'APK[^@]*@\([^#]*\)' # regex used to get the dl url in apkmirror. default: APK[^@]*@\([^#]*\) +# this default gets the url to the non-bundle apk. +``` diff --git a/build.sh b/build.sh index 74a081f4f4..249e4af520 100755 --- a/build.sh +++ b/build.sh @@ -14,7 +14,6 @@ read_main_config if ((COMPRESSION_LEVEL > 9)) || ((COMPRESSION_LEVEL < 1)); then abort "compression-level must be from 1 to 9"; fi if [ "$UPDATE_PREBUILTS" = true ]; then get_prebuilts; else set_prebuilts; fi if [ "$BUILD_MINDETACH_MODULE" = true ]; then : >$PKGS_LIST; fi -mkdir -p revanced-magisk/bin/arm64 revanced-magisk/bin/arm get_cmpr log "**App Versions:**" @@ -24,7 +23,7 @@ for t in $(toml_get_all_tables); do enabled=$(toml_get "$t" enabled) || enabled=true if [ "$enabled" = false ]; then continue; fi - if (( idx >= PARALLEL_JOBS )); then wait -n; else idx=$((idx + 1)); fi + if ((idx >= PARALLEL_JOBS)); then wait -n; else idx=$((idx + 1)); fi declare -A app_args merge_integrations=$(toml_get "$t" merge-integrations) || merge_integrations=false excluded_patches=$(toml_get "$t" excluded-patches) || excluded_patches="" @@ -36,13 +35,9 @@ for t in $(toml_get_all_tables); do app_args[rip_libs]=$(toml_get "$t" rip-libs) || app_args[rip_libs]=false app_args[build_mode]=$(toml_get "$t" build-mode) || app_args[build_mode]=apk app_args[microg_patch]=$(toml_get "$t" microg-patch) || app_args[microg_patch]="" - app_args[apkmirror_dlurl]=$(toml_get "$t" apkmirror-dlurl) || app_args[apkmirror_dlurl]="" - if [ "${app_args[apkmirror_dlurl]}" ]; then - app_args[apkmirror_dlurl]=${app_args[apkmirror_dlurl]%/} - if [[ "${app_args[apkmirror_dlurl]%/*}" == */apk ]]; then - app_args[apkmirror_dlurl]=${app_args[apkmirror_dlurl]%/*}/${app_args[apkmirror_dlurl]##*/}/${app_args[apkmirror_dlurl]##*/} - fi - fi + app_args[uptodown_dlurl]=$(toml_get "$t" uptodown-dlurl) && app_args[uptodown_dlurl]=${app_args[uptodown_dlurl]%/} || app_args[uptodown_dlurl]="" + app_args[apkmirror_dlurl]=$(toml_get "$t" apkmirror-dlurl) && app_args[apkmirror_dlurl]=${app_args[apkmirror_dlurl]%/} || app_args[apkmirror_dlurl]="" + app_args[arch]=$(toml_get "$t" arch) || app_args[arch]="all" app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || { app_name_l=${app_args[app_name],,} diff --git a/config.toml b/config.toml index ee0d2a8506..988b7a4513 100644 --- a/config.toml +++ b/config.toml @@ -1,96 +1,97 @@ -# SEE https://github.com/j-hc/revanced-magisk-module/blob/main/CONFIG.md for more detailed explanations - -[main-config] -compression-level = 9 # compression level for module zips. between 1 and 9 -enable-magisk-update = true # set this to false if you do not want to receive updates from magisk app -parallel-jobs = 3 # max number of concurrent building jobs -update-prebuilts = true # dont touch this -build-mindetach-module = true - - -[YouTube] -enabled = true # add 'enabled = false' key to entries to not build them -build-mode = "both" # 'both', 'apk' or 'module' -excluded-patches = "debugging" # whitespace seperated list of patches to exclude -included-patches = "" # whitespace seperated list of patches to include -version = "auto" # 'auto', 'latest' or a custom one like '17.40.41' -exclusive-patches = false # excludes all patches by default -microg-patch = "microg-support" -apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube/" -module-prop-name = "ytrv-magisk" -merge-integrations = true -rip-libs = true - -[Music-arm64] -build-mode = "both" -app-name = "Music" -excluded-patches = "" -included-patches = "" -version = "auto" -microg-patch = "music-microg-support" -apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music/" -module-prop-name = "ytmusicrv-magisk" -arch = "arm64-v8a" - -[Music-arm] -build-mode = "both" -app-name = "Music" -excluded-patches = "" -included-patches = "" -version = "auto" -microg-patch = "music-microg-support" -apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music/" -module-prop-name = "ytmusicrv-arm-magisk" -arch = "arm-v7a" - -[Twitter] -build-mode = "apk" -excluded-patches = "" -version = "latest" -apkmirror-dlurl = "https://www.apkmirror.com/apk/twitter-inc/twitter/" - -[Reddit] -build-mode = "apk" -version = "latest" -apkmirror-dlurl = "https://www.apkmirror.com/apk/redditinc/reddit/" - -[Twitch] -build-mode = "apk" -version = "latest" -apkmirror-dlurl = "https://www.apkmirror.com/apk/twitch-interactive-inc/twitch/" -merge-integrations = true - -[Tiktok] -build-mode = "apk" -version = "27.2.5" -apkmirror-dlurl = "https://www.apkmirror.com/apk/tiktok-pte-ltd/tik-tok-including-musical-ly/" -merge-integrations = true - -[Spotify] -enabled = false -build-mode = "apk" -version = "latest" - -[TickTick] -enabled = false -build-mode = "apk" -version = "latest" -apkmirror-dlurl = "https://www.apkmirror.com/apk/appest-inc/ticktick-to-do-list-with-reminder-day-planner/" - -[WarnWetter] -enabled = false -version = "latest" -build-mode = "apk" -apkmirror-dlurl = "https://www.apkmirror.com/apk/appest-inc/deutscher-wetterdienst/warnwetter/" - -[Backdrops] -enabled = false -build-mode = "apk" -version = "latest" -apkmirror-dlurl = "https://www.apkmirror.com/apk/backdrops/backdrops-wallpapers/" - -[Windy] -enabled = false -build-mode = "apk" -version = "latest" -apkmirror-dlurl = "https://www.apkmirror.com/apk/windy-weather-world-inc/windy-wind-weather-forecast/" +# see https://github.com/j-hc/revanced-magisk-module/blob/main/CONFIG.md for more detailed explanations + +[main-config] +compression-level = 9 # compression level for module zips. between 1 and 9 +enable-magisk-update = true # set this to false if you do not want to receive updates for the module in magisk app +parallel-jobs = 3 # max number of concurrent building jobs +update-prebuilts = true # dont touch this +build-mindetach-module = true + + +[YouTube] +enabled = true # add 'enabled = false' key to entries to not build them +build-mode = "both" # 'both', 'apk' or 'module' +excluded-patches = "debugging" # whitespace seperated list of patches to exclude (multiline strings are not supported) +included-patches = "" # whitespace seperated list of patches to include +version = "auto" # 'auto', 'latest' or a custom one like '17.40.41' +exclusive-patches = false # excludes all patches by default +microg-patch = "microg-support" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube/" +module-prop-name = "ytrv-magisk" +merge-integrations = true +rip-libs = true + +[Music-arm64] +build-mode = "both" +app-name = "Music" +excluded-patches = "" +included-patches = "" +version = "auto" +microg-patch = "music-microg-support" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music/" +module-prop-name = "ytmusicrv-magisk" +arch = "arm64-v8a" + +[Music-arm] +build-mode = "both" +app-name = "Music" +excluded-patches = "" +included-patches = "" +version = "auto" +microg-patch = "music-microg-support" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music/" +module-prop-name = "ytmusicrv-arm-magisk" +arch = "arm-v7a" + +[Twitter] +build-mode = "apk" +excluded-patches = "" +version = "latest" +apkmirror-dlurl = "https://www.apkmirror.com/apk/twitter-inc/twitter/" + +[Reddit] +build-mode = "apk" +version = "latest" +apkmirror-dlurl = "https://www.apkmirror.com/apk/redditinc/reddit/" + +[Twitch] +build-mode = "apk" +version = "latest" +apkmirror-dlurl = "https://www.apkmirror.com/apk/twitch-interactive-inc/twitch/" +merge-integrations = true + +[Tiktok] +build-mode = "apk" +version = "27.2.5" +apkmirror-dlurl = "https://www.apkmirror.com/apk/tiktok-pte-ltd/tik-tok-including-musical-ly/" +merge-integrations = true + +[Spotify] +enabled = false +build-mode = "apk" +version = "latest" +uptodown-dlurl = "https://spotify.en.uptodown.com/android" + +[TickTick] +enabled = false +build-mode = "apk" +version = "latest" +apkmirror-dlurl = "https://www.apkmirror.com/apk/appest-inc/ticktick-to-do-list-with-reminder-day-planner/" + +[WarnWetter] +enabled = false +version = "latest" +build-mode = "apk" +apkmirror-dlurl = "https://www.apkmirror.com/apk/appest-inc/deutscher-wetterdienst/warnwetter/" + +[Backdrops] +enabled = false +build-mode = "apk" +version = "latest" +apkmirror-dlurl = "https://www.apkmirror.com/apk/backdrops/backdrops-wallpapers/" + +[Windy] +enabled = false +build-mode = "apk" +version = "latest" +apkmirror-dlurl = "https://www.apkmirror.com/apk/windy-weather-world-inc/windy-wind-weather-forecast/" diff --git a/utils.sh b/utils.sh index 6dd5d8b0d6..780f0310b9 100755 --- a/utils.sh +++ b/utils.sh @@ -63,6 +63,7 @@ get_prebuilts() { } get_cmpr() { + mkdir -p revanced-magisk/bin/arm64 revanced-magisk/bin/arm dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/arm64/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-arm64-v8a" dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/arm/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-armeabi-v7a" } @@ -72,13 +73,13 @@ abort() { echo "abort: $1" && exit 1; } set_prebuilts() { [ -d "$TEMP_DIR" ] || abort "${TEMP_DIR} directory could not be found" RV_CLI_JAR=$(find "$TEMP_DIR" -maxdepth 1 -name "revanced-cli-*.jar" | tail -n1) - [ -z "$RV_CLI_JAR" ] && abort "revanced cli not found" + [ "$RV_CLI_JAR" ] || abort "revanced cli not found" log "CLI: ${RV_CLI_JAR#"$TEMP_DIR/"}" - RV_INTEGRATIONS_APK=$(find "$TEMP_DIR" -maxdepth 1 -name "app-release-unsigned-*.apk" | tail -n1) - [ -z "$RV_CLI_JAR" ] && abort "revanced integrations not found" + RV_INTEGRATIONS_APK=$(find "$TEMP_DIR" -maxdepth 1 -name "revanced-integrations-*.apk" | tail -n1) + [ "$RV_CLI_JAR" ] || abort "revanced integrations not found" log "Integrations: ${RV_INTEGRATIONS_APK#"$TEMP_DIR/"}" RV_PATCHES_JAR=$(find "$TEMP_DIR" -maxdepth 1 -name "revanced-patches-*.jar" | tail -n1) - [ -z "$RV_CLI_JAR" ] && abort "revanced patches not found" + [ "$RV_CLI_JAR" ] || abort "revanced patches not found" log "Patches: ${RV_PATCHES_JAR#"$TEMP_DIR/"}" } @@ -154,7 +155,7 @@ get_apkmirror_pkg_name() { req "$1" - | sed -n 's;.*id=\(.*\)" class="accent_col # ------------------------------ # ------- uptodown ------------- -get_uptodown_resp() { req "https://${1}.en.uptodown.com/android/versions" -; } +get_uptodown_resp() { req "${1}/versions" -; } get_uptodown_vers() { echo "$1" | grep -x '^[0-9.]* .*' | sed 's/ >$PKGS_LIST; fi + if [ "$BUILD_MINDETACH_MODULE" = true ] && ! grep -q "$pkg_name" $PKGS_LIST; then echo "$pkg_name" >>$PKGS_LIST; fi declare -r base_template=$(mktemp -d -p $TEMP_DIR) cp -a $MODULE_TEMPLATE_DIR/. "$base_template"