build twitter yay

This commit is contained in:
j-hc 2022-07-23 14:56:01 +03:00
parent a4970bf434
commit d455f7efb4
No known key found for this signature in database
GPG Key ID: 242B44D16774A2ED
5 changed files with 127 additions and 50 deletions

View File

@ -23,37 +23,43 @@ jobs:
- id: next_ver_code
run: export TAG=${{ steps.prev_tag.outputs.tag }}; echo ::set-output name=NEXT_VER_CODE::$((TAG + 1))
- run: ./build.sh all
- run: ./build.sh build
env:
GITHUB_REPOSITORY: $GITHUB_REPOSITORY
NEXT_VER_CODE: ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}
- id: get_output
run: |
echo ::set-output name=YT_OUTPUT::$(find . -maxdepth 1 -name "yt-revanced-magisk-*.zip" -printf '%P')
echo ::set-output name=MUSIC_OUTPUT_ARM64::$(find . -maxdepth 1 -name "music-revanced-magisk-*-arm64-v8a.zip" -printf '%P')
echo ::set-output name=MUSIC_OUTPUT_ARM::$(find . -maxdepth 1 -name "music-revanced-magisk-*-arm-v7a.zip" -printf '%P')
BUILD_LOG=$(cat build.log)
BUILD_LOG="${BUILD_LOG//'%'/'%25'}"
BUILD_LOG="${BUILD_LOG//$'\n'/'%0A'}"
BUILD_LOG="${BUILD_LOG//$'\r'/'%0D'}"
echo ::set-output name=BUILD_LOG::$BUILD_LOG
shell: bash
cd build
yt_op=$(find . -maxdepth 1 -name "yt-revanced-magisk-*.zip" -printf '%P')
echo ::set-output name=YT_OUTPUT::$yt_op
if [ -z "$yt_op" ]; then
echo ::set-output name=RELEASE_NAME::"revanced"
else
echo ::set-output name=RELEASE_NAME::$yt_op
fi
echo ::set-output name=MUSIC_OUTPUT_ARM64::$(find . -maxdepth 1 -name "music-revanced-magisk-*-arm64-v8a.zip" -printf '%P')
echo ::set-output name=MUSIC_OUTPUT_ARM::$(find . -maxdepth 1 -name "music-revanced-magisk-*-arm-v7a.zip" -printf '%P')
- name: Upload modules to release
uses: svenstaro/upload-release-action@v2
with:
body: ${{ steps.get_output.outputs.BUILD_LOG }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./*.zip
release_name: ${{ steps.get_output.outputs.YT_OUTPUT }}
file: ./build/*
release_name: ${{ steps.get_output.outputs.RELEASE_NAME }}
tag: ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}
file_glob: true
overwrite: false
- name: Switch to update branch and create if it DNE
- name: Switch to update branch
run: git checkout -f update || git switch --discard-changes --orphan update
- name: Update changelog and Magisk update jsons
@ -69,19 +75,26 @@ jobs:
\"changelog\": \"$4\"
}"
}
YT_VER=$(echo "${{ steps.get_output.outputs.BUILD_LOG }}" | sed -n 's/.*YouTube version: \(.*\)/\1/p')
YT_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.YT_OUTPUT }}"
UPDATE_YT_JSON=$(get_update_json "$YT_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}" "$YT_DLURL" "$CHANGELOG_URL")
echo "$UPDATE_YT_JSON" >yt-update.json
if [ -n "${{ steps.get_output.outputs.YT_OUTPUT }}" ]; then
YT_VER=$(echo "${{ steps.get_output.outputs.BUILD_LOG }}" | sed -n 's/.*YouTube version: \(.*\)/\1/p')
YT_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.YT_OUTPUT }}"
UPDATE_YT_JSON=$(get_update_json "$YT_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}" "$YT_DLURL" "$CHANGELOG_URL")
echo "$UPDATE_YT_JSON" >yt-update.json
fi
MUSIC_VER=$(echo "${{ steps.get_output.outputs.BUILD_LOG }}" | sed -n 's/.*Music (arm64-v8a) version: \(.*\)/\1/p')
MUSIC_ARM64_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM64 }}"
MUSIC_ARM_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM }}"
if [ -n "${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM64 }}" ]; then
MUSIC_VER=$(echo "${{ steps.get_output.outputs.BUILD_LOG }}" | sed -n 's/.*Music (arm64-v8a) version: \(.*\)/\1/p')
MUSIC_ARM64_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM64 }}"
UPDATE_MUSIC_ARM64_JSON=$(get_update_json "$MUSIC_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}" "$MUSIC_ARM64_DLURL" "$CHANGELOG_URL")
echo "$UPDATE_MUSIC_ARM64_JSON" >music-update-arm64-v8a.json
fi
UPDATE_MUSIC_ARM64_JSON=$(get_update_json "$MUSIC_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}" "$MUSIC_ARM64_DLURL" "$CHANGELOG_URL")
echo "$UPDATE_MUSIC_ARM64_JSON" >music-update-arm64-v8a.json
UPDATE_MUSIC_ARM_JSON=$(get_update_json "$MUSIC_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}" $MUSIC_ARM_DLURL "$CHANGELOG_URL")
echo "$UPDATE_MUSIC_ARM_JSON" >music-update-arm-v7a.json
if [ -n "${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM }}" ]; then
MUSIC_VER=$(echo "${{ steps.get_output.outputs.BUILD_LOG }}" | sed -n 's/.*Music (arm-v7a) version: \(.*\)/\1/p')
MUSIC_ARM_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM }}"
UPDATE_MUSIC_ARM_JSON=$(get_update_json "$MUSIC_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}" "$MUSIC_ARM_DLURL" "$CHANGELOG_URL")
echo "$UPDATE_MUSIC_ARM_JSON" >music-update-arm-v7a.json
fi
- uses: stefanzweifel/git-auto-commit-action@v4
with:

View File

@ -4,7 +4,7 @@
This repo includes a simple script that downloads all the latest version of necessary prebuilt revanced tools and the stock APKs of YouTube and YouTube Music from APKMirror, applies the patches and creates magisk modules.
You will need to install the stock YouTube app matching with the module's version on your phone, there is no need for the split APKs or SAI anymore, the regular APK is just fine. The link is also provided in release notes.
You will need to **install the stock YouTube (or YT Music) app matching with the module's version on your phone**, there is no need for the split APKs or SAI anymore, the regular APK is just fine. The link is also provided in release notes.
You can get the [latest CI release](https://github.com/j-hc/revanced-magisk-module/releases) from here.
@ -15,13 +15,13 @@ The modules support Magisk update which means you will receive updates from your
If you wish to include/exclude some patches to your liking:
* Star the repo :eyes:
* Fork the repo
* Edit the patcher args in [`build.sh`](./build.sh)
* Edit the patcher args in [`build.conf`](./build.conf)
* Run the [workflow](../../actions/workflows/build.yml)
* Grab your module from [releases](../../releases)
* Grab your modules from [releases](../../releases)
# Building the Magisk Modules
If you are going to build locally, make sure you have [Azul Zulu distribution of OpenJDK 17](https://www.azul.com/downloads/?version=java-17-lts&os=linux&architecture=x86-64-bit&package=jdk)
```console
$ ./build.sh all
$ ./build.sh build
```

12
build.conf Normal file
View File

@ -0,0 +1,12 @@
YT_PATCHER_ARGS="-e microg-support"
MUSIC_PATCHER_ARGS="-e microg-support"
BUILD_YT=true
BUILD_MUSIC_ARM64_V8A=true
BUILD_MUSIC_ARM_V7A=true
BUILD_TWITTER=true
UPDATE_PREBUILTS=true
# this is the repo to fallback for magisk update json if you are not building on github actions ↓
GITHUB_REPO_FALLBACK="j-hc/revanced-magisk-module"

View File

@ -2,17 +2,11 @@
set -euo pipefail
YT_PATCHER_ARGS="-e microg-support -e swipe-controls"
MUSIC_PATCHER_ARGS="-e microg-support"
# dont change anything after this point ↓
source build.conf
source utils.sh
BUILD_YT=false
BUILD_MUSIC=false
print_usage() {
echo -e "Usage:\n${0} all|youtube|music|clean|reset-template"
echo -e "Usage:\n${0} build|clean|reset-template"
}
if [ -z ${1+x} ]; then
@ -25,30 +19,37 @@ elif [ "$1" = "clean" ]; then
elif [ "$1" = "reset-template" ]; then
reset_template
exit 0
elif [ "$1" = "all" ]; then
BUILD_YT=true
BUILD_MUSIC=true
elif [ "$1" = "youtube" ]; then
BUILD_YT=true
elif [ "$1" = "music" ]; then
BUILD_MUSIC=true
elif [ "$1" = "build" ]; then
:
else
print_usage
exit 1
fi
true >build.log
: >build.log
log "$(date +'%Y-%m-%d')\n"
mkdir -p "$BUILD_DIR"
get_prebuilts
if [ "$UPDATE_PREBUILTS" = true ]; then
get_prebuilts
else
set_prebuilts
fi
if [ "$BUILD_YT" = true ]; then
build_yt "$YT_PATCHER_ARGS"
fi
if [ "$BUILD_MUSIC" = true ]; then
if [ "$BUILD_MUSIC_ARM64_V8A" = true ]; then
build_music "$MUSIC_PATCHER_ARGS" "$ARM64_V8A"
fi
if [ "$BUILD_MUSIC_ARM_V7A" = true ]; then
build_music "$MUSIC_PATCHER_ARGS" "$ARM_V7A"
fi
if [ "$BUILD_TWITTER" = true ]; then
build_twitter
fi
echo "Done"

View File

@ -1,11 +1,8 @@
#!/bin/bash
# this is the repo to fallback for magisk update json if you are not building on github actions ↓
GITHUB_REPO_FALLBACK="j-hc/revanced-magisk-module"
# dont change anything after this point ↓
MODULE_TEMPLATE_DIR="revanced-magisk"
TEMP_DIR="temp"
BUILD_DIR="build"
ARM64_V8A="arm64-v8a"
ARM_V7A="arm-v7a"
@ -34,6 +31,19 @@ get_prebuilts() {
dl_if_dne "$RV_PATCHES_JAR" "$RV_PATCHES_URL"
}
set_prebuilts() {
[ ! -d "$TEMP_DIR" ] && {
echo "${TEMP_DIR} directory could not be found"
exit 1
}
RV_CLI_JAR=$(find "$TEMP_DIR" -maxdepth 1 -name "revanced-cli-*")
log "CLI: ${RV_CLI_JAR#"$TEMP_DIR/"}"
RV_INTEGRATIONS_APK=$(find "$TEMP_DIR" -maxdepth 1 -name "app-release-unsigned-*")
log "Integrations: ${RV_INTEGRATIONS_APK#"$TEMP_DIR/"}"
RV_PATCHES_JAR=$(find "$TEMP_DIR" -maxdepth 1 -name "revanced-patches-*")
log "Patches: ${RV_PATCHES_JAR#"$TEMP_DIR/"}"
}
reset_template() {
echo "# utils" >"${MODULE_TEMPLATE_DIR}/common/install.sh"
echo "# utils" >"${MODULE_TEMPLATE_DIR}/service.sh"
@ -87,8 +97,47 @@ dl_music() {
req "$url" "$2"
}
dl_twitter() {
echo "Downloading Twitter"
local url="https://www.apkmirror.com/apk/twitter-inc/twitter/twitter-${1//./-}-release/"
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's/href="/@/g; s;.*APK</span>[^@]*@\([^#]*\).*;\1;p')"
log "\nTwitter version: $1"
log "downloaded from: [APKMirror - Twitter v${1}]($url)"
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')"
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')"
req "$url" "$2"
}
apk_last_ver() {
req "$1" - | sed -n 's;.*Version:</span><span class="infoSlide-value">\(.*\)</span>.*;\1;p' | head -n 1 | xargs
}
build_twitter() {
echo "Building Twitter"
local supported_versions last_ver
supported_versions=$(unzip -p "$RV_PATCHES_JAR" | strings -n 8 -s , | sed -rn 's/.*twitter,versions,(([0-9.]*,*)*),Lk.*/\1/p')
if [ -z "$supported_versions" ]; then
last_ver=$(apk_last_ver "https://www.apkmirror.com/apk/twitter-inc/")
echo "Choosing latest version '${last_ver}'"
else
echo "Supported versions of the Twitter patch: $supported_versions"
last_ver=$(echo "$supported_versions" | awk -F, '{ print $NF }')
echo "Choosing '${last_ver}'"
fi
local twitter_base_apk="${TEMP_DIR}/twitter-stock-v${last_ver}.apk"
if [ ! -f "$twitter_base_apk" ]; then
dl_twitter "$last_ver" "$twitter_base_apk"
fi
local twitter_patched_apk="twitter-revanced-v${last_ver}.apk"
java -jar "$RV_CLI_JAR" -a "$twitter_base_apk" -c -o "$twitter_patched_apk" -b "$RV_PATCHES_JAR"
mv -f "$twitter_patched_apk" "$BUILD_DIR"
echo "Built Twitter: '${BUILD_DIR}/${twitter_patched_apk}'"
}
build_yt() {
echo "Patching YouTube"
echo "Building YouTube"
reset_template
local supported_versions last_ver
# This only finds the supported versions of some random patch wrt the first occurance of the string but that's fine
@ -116,12 +165,13 @@ build_yt() {
zip -r "../$output" .
cd ..
echo "Built YouTube: '${output}'"
mv -f "$output" "$BUILD_DIR"
echo "Built YouTube: '${BUILD_DIR}/${output}'"
}
build_music() {
local arch="$2"
echo "Patching YouTube Music ($arch)"
echo "Building YouTube Music ($arch)"
reset_template
local supported_versions last_ver
# This only finds the supported versions of some random patch wrt the first occurance of the string but that's fine
@ -149,7 +199,8 @@ build_music() {
zip -r "../$output" .
cd ..
echo "Built Music '${output}'"
mv -f "$output" "$BUILD_DIR"
echo "Built Music '${BUILD_DIR}/${output}'"
}
service_sh() {