Skip to content

Commit

Permalink
added uptodown-dlurl
Browse files Browse the repository at this point in the history
  • Loading branch information
j-hc committed Jan 10, 2023
1 parent f69a8b6 commit 2fd2ddb
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 213 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on: [workflow_call, workflow_dispatch]

jobs:
run:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v3
Expand Down
133 changes: 67 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
76 changes: 43 additions & 33 deletions CONFIG.md
Original file line number Diff line number Diff line change
@@ -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</span>[^@]*@\([^#]*\)' # regex used to get the dl url in apkmirror. default: APK</span>[^@]*@\([^#]*\)
# this default gets the url to the non-bundle apk.
```
# 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</span>[^@]*@\([^#]*\)' # regex used to get the dl url in apkmirror. default: APK</span>[^@]*@\([^#]*\)
# this default gets the url to the non-bundle apk.
```
13 changes: 4 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:**"
Expand All @@ -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=""
Expand All @@ -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],,}
Expand Down
Loading

0 comments on commit 2fd2ddb

Please sign in to comment.