Skip to content

Commit ef9a722

Browse files
committed
refactor: overhaul codebase
1 parent 867c217 commit ef9a722

File tree

5 files changed

+395
-478
lines changed

5 files changed

+395
-478
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
- name: Set matrix based on patch source
3737
id: set-matrix
3838
run: |
39-
matrix=$(./build.sh get-matrix config.toml ${{ inputs.patch_source }})
40-
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
39+
matrix="$(./build.sh get-matrix config.toml "${{ inputs.patch_source }}")"
40+
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
4141
4242
run:
4343
needs: prepare
@@ -81,7 +81,7 @@ jobs:
8181
- name: Upload build log as artifact
8282
uses: actions/upload-artifact@v7
8383
with:
84-
name: build-log-${{ matrix.id }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
84+
name: log-${{ matrix.id }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
8585
path: build.md
8686
if-no-files-found: warn
8787
retention-days: 1
@@ -95,30 +95,28 @@ jobs:
9595
uses: actions/checkout@v6
9696
with:
9797
fetch-depth: 0
98-
98+
9999
- name: Check if any artifacts exist
100100
id: check_artifacts
101101
continue-on-error: true
102102
run: |
103-
if gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --jq '.artifacts[] | select(.name | startswith("apks-")) | .name' | grep -q .; then
104-
echo "has_artifacts=true" >> $GITHUB_OUTPUT
103+
if gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" --jq '.artifacts[] | select(.name | startswith("apks-")) | .name' | grep -q .; then
104+
echo "has_artifacts=true" >> "$GITHUB_OUTPUT"
105105
else
106-
echo "has_artifacts=false" >> $GITHUB_OUTPUT
106+
echo "has_artifacts=false" >> "$GITHUB_OUTPUT"
107107
exit 1
108108
fi
109109
env:
110110
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111-
111+
112112
- name: Prepare version
113113
if: steps.check_artifacts.outputs.has_artifacts == 'true'
114114
id: version
115115
run: |
116-
VER=$(date +%y.%m.%d)
117-
if [ "${{ inputs.build_mode }}" == "dev" ]; then
118-
VER="${VER}-pre"
119-
fi
116+
VER="$(date +%y.%m.%d)"
117+
[[ "${{ inputs.build_mode }}" == "dev" ]] && VER="${VER}-pre"
120118
VER="${VER}-${{ inputs.patch_source }}"
121-
echo "version=${VER}" >> $GITHUB_OUTPUT
119+
echo "version=${VER}" >> "$GITHUB_OUTPUT"
122120
123121
- name: Download all APKs
124122
if: steps.check_artifacts.outputs.has_artifacts == 'true'
@@ -128,20 +126,20 @@ jobs:
128126
path: all-apks
129127
merge-multiple: true
130128

131-
- name: Download all build logs
129+
- name: Download all logs
132130
if: steps.check_artifacts.outputs.has_artifacts == 'true'
133131
uses: actions/download-artifact@v8
134132
with:
135-
pattern: build-log-*
136-
path: build-logs
133+
pattern: log-*
134+
path: logs
137135

138-
- name: Combine build logs
136+
- name: Combine logs
139137
if: steps.check_artifacts.outputs.has_artifacts == 'true'
140138
id: get_output
141139
run: |
142140
DELIM="$(openssl rand -hex 8)"
143141
echo "BUILD_LOG<<${DELIM}" >> "$GITHUB_OUTPUT"
144-
./build.sh combine-logs build-logs >> "$GITHUB_OUTPUT"
142+
./build.sh combine-logs logs >> "$GITHUB_OUTPUT"
145143
echo "${DELIM}" >> "$GITHUB_OUTPUT"
146144
147145
- name: Upload APKs to release

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ Here you can download and use applications selected for this repository, which a
4848

4949
## ⚠️ Disclaimer
5050

51-
- This project is **not affiliated with any patch creators mentioned here**, and is intended for educational & personal use only.
51+
- This project is **not affiliated with any patch creators mentioned here**, and is intended for educational & personal use only.
5252
- All builds are created using **publicly available tools**. This repository simply automates the process for convenience.
5353
- The entire process is handled via **public GitHub Actions** to ensure security and transparency. For maximum security, you can always build the applications yourself using the provided source code or official methods.
54-
- The build code is based on the original implementation by **[j-hc](https://github.com/j-hc)** (with my custom modifications). Full credit for the original implementation goes to him.
54+
- The build code is a **heavily refactored, optimized, and customized** version of the original implementation by **j-hc**. It has been strictly modified to exclusively support Morphe patches (`.mpp`). Full credit for the initial groundwork goes to him.
5555
- This repository only provides pre-built APKs. If a build fails due to upstream app or patch changes, please report it to the patch creators or wait for an update.
5656

5757
---

build.sh

Lines changed: 57 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
set -euo pipefail
44
shopt -s nullglob
55
trap "rm -rf temp/*tmp.* temp/*/*tmp.* temp/*-temporary-files; kill 0; exit 130" INT
6+
[[ "${1-}" == "clean" ]] && { rm -rf temp build logs build.md; exit 0; }
67

7-
if [ "${1-}" = "clean" ]; then
8-
rm -rf temp build logs build.md
9-
exit 0
10-
fi
11-
8+
# shellcheck disable=SC1091
129
source utils.sh
1310
set_prebuilts
1411
_UA=$(ua)
@@ -18,96 +15,89 @@ install_pkg jq
1815
install_pkg java openjdk-21-jdk
1916
install_pkg unzip
2017

21-
if [ "${1-}" = "separate-config" ] || [ "${1-}" = "combine-logs" ] || [ "${1-}" = "get-matrix" ]; then
22-
case "${1}" in
23-
separate-config) separate_config "${@:2}" ;;
24-
combine-logs) combine_logs "${@:2}" ;;
25-
get-matrix) get_matrix "${@:2}" ;;
26-
esac
27-
exit 0
28-
fi
18+
case "${1-}" in
19+
separate-config) separate_config "${@:2}"; exit 0 ;;
20+
combine-logs) combine_logs "${@:2}"; exit 0 ;;
21+
get-matrix) get_matrix "${@:2}"; exit 0 ;;
22+
esac
2923

30-
vtf() { if ! isoneof "${1}" "true" "false"; then abort "ERROR: '${1}' is not a valid option for '${2}': only true or false is allowed"; fi; }
24+
vtf() { isoneof "$1" "true" "false" || abort "ERROR: '$1' is not a valid option for '$2': only true or false is allowed"; }
3125

3226
# -- Main config --
3327
toml_prep "${1:-config.toml}" || abort "could not find config file '${1:-config.toml}'\n\tUsage: $0 <config.toml>"
34-
main_config_t=$(toml_get_table_main)
35-
PARALLEL_JOBS=$(toml_get "$main_config_t" parallel-jobs) || PARALLEL_JOBS=$(nproc)
36-
DEF_PATCHES_VER=$(toml_get "$main_config_t" patches-version) || DEF_PATCHES_VER="latest"
37-
DEF_CLI_VER=$(toml_get "$main_config_t" cli-version) || DEF_CLI_VER="latest"
38-
DEF_PATCHES_SRC=$(toml_get "$main_config_t" patches-source) || DEF_PATCHES_SRC="MorpheApp/morphe-patches"
39-
DEF_CLI_SRC=$(toml_get "$main_config_t" cli-source) || DEF_CLI_SRC="MorpheApp/morphe-cli"
40-
DEF_BRAND=$(toml_get "$main_config_t" brand) || DEF_BRAND="Morphe"
41-
DEF_DPI_LIST=$(toml_get "$main_config_t" dpi) || DEF_DPI_LIST="nodpi anydpi 120-640dpi"
28+
main_config_t="$(toml_get_table_main)"
29+
PARALLEL_JOBS="$(toml_get "$main_config_t" parallel-jobs)" || PARALLEL_JOBS="$(nproc)"
30+
DEF_PATCHES_VER="$(toml_get "$main_config_t" patches-version)" || DEF_PATCHES_VER="latest"
31+
DEF_CLI_VER="$(toml_get "$main_config_t" cli-version)" || DEF_CLI_VER="latest"
32+
DEF_PATCHES_SRC="$(toml_get "$main_config_t" patches-source)" || DEF_PATCHES_SRC="MorpheApp/morphe-patches"
33+
DEF_CLI_SRC="$(toml_get "$main_config_t" cli-source)" || DEF_CLI_SRC="MorpheApp/morphe-cli"
34+
DEF_BRAND="$(toml_get "$main_config_t" brand)" || DEF_BRAND="Morphe"
35+
DEF_DPI_LIST="$(toml_get "$main_config_t" dpi)" || DEF_DPI_LIST="nodpi anydpi 120-640dpi"
4236
mkdir -p "$TEMP_DIR" "$BUILD_DIR"
4337

4438
: >build.md
4539

4640
for file in "$TEMP_DIR"/*/changelog.md; do
47-
[ -f "$file" ] && : >"$file"
41+
[[ -f "$file" ]] && : >"$file"
4842
done
4943

5044
idx=0
5145
for table_name in $(toml_get_table_names); do
52-
if [ -z "$table_name" ]; then continue; fi
53-
t=$(toml_get_table "$table_name")
54-
enabled=$(toml_get "$t" enabled) || enabled=true
46+
[[ -z "$table_name" ]] && continue
47+
t="$(toml_get_table "$table_name")"
48+
enabled="$(toml_get "$t" enabled)" || enabled="true"
5549
vtf "$enabled" "enabled"
56-
if [ "$enabled" = false ]; then continue; fi
50+
[[ "$enabled" == "false" ]] && continue
5751
if ((idx >= PARALLEL_JOBS)); then
5852
wait -n
59-
idx=$((idx - 1))
53+
(( idx-- ))
6054
fi
6155

6256
declare -A app_args
63-
patches_src=$(toml_get "$t" patches-source) || patches_src=$DEF_PATCHES_SRC
57+
patches_src="$(toml_get "$t" patches-source)" || patches_src="$DEF_PATCHES_SRC"
6458

65-
if [ "${BUILD_MODE:-}" = "dev" ]; then
59+
if [[ "${BUILD_MODE:-}" == "dev" ]]; then
6660
patches_ver="dev"
6761
else
68-
patches_ver=$(toml_get "$t" patches-version) || patches_ver=$DEF_PATCHES_VER
62+
patches_ver="$(toml_get "$t" patches-version)" || patches_ver="$DEF_PATCHES_VER"
6963
fi
70-
71-
cli_src=$(toml_get "$t" cli-source) || cli_src=$DEF_CLI_SRC
72-
cli_ver=$(toml_get "$t" cli-version) || cli_ver=$DEF_CLI_VER
7364

74-
if ! PREBUILTS="$(get_prebuilts "$cli_src" "$cli_ver" "$patches_src" "$patches_ver")"; then
75-
abort "could not download prebuilts"
76-
fi
77-
read -r cli_jar patches_jar <<<"$PREBUILTS"
78-
app_args[cli]=$cli_jar
79-
app_args[ptjar]=$patches_jar
80-
app_args[brand]=$(toml_get "$t" brand) || app_args[brand]=$DEF_BRAND
81-
82-
app_args[excluded_patches]=$(toml_get "$t" excluded-patches) || app_args[excluded_patches]=""
83-
if [ -n "${app_args[excluded_patches]}" ] && [[ ${app_args[excluded_patches]} != *'"'* ]]; then abort "patch names inside excluded-patches must be quoted"; fi
84-
app_args[included_patches]=$(toml_get "$t" included-patches) || app_args[included_patches]=""
85-
if [ -n "${app_args[included_patches]}" ] && [[ ${app_args[included_patches]} != *'"'* ]]; then abort "patch names inside included-patches must be quoted"; fi
86-
app_args[exclusive_patches]=$(toml_get "$t" exclusive-patches) && vtf "${app_args[exclusive_patches]}" "exclusive-patches" || app_args[exclusive_patches]=false
87-
app_args[version]=$(toml_get "$t" version) || app_args[version]="auto"
88-
app_args[app_name]=$(toml_get "$t" app-name) || app_args[app_name]=$table_name
89-
app_args[patcher_args]=$(toml_get "$t" patcher-args) || app_args[patcher_args]=""
90-
app_args[table]=$table_name
91-
65+
cli_src="$(toml_get "$t" cli-source)" || cli_src="$DEF_CLI_SRC"
66+
cli_ver="$(toml_get "$t" cli-version)" || cli_ver="$DEF_CLI_VER"
67+
68+
PREBUILTS="$(get_prebuilts "$cli_src" "$cli_ver" "$patches_src" "$patches_ver")" || abort "could not download prebuilts"
69+
read -r cli_jar patches_mpp <<<"$PREBUILTS"
70+
app_args[cli]="$cli_jar"
71+
app_args[ptmpp]="$patches_mpp"
72+
app_args[brand]="$(toml_get "$t" brand)" || app_args[brand]="$DEF_BRAND"
73+
74+
app_args[excluded_patches]="$(toml_get "$t" excluded-patches)" || app_args[excluded_patches]=""
75+
[[ -n "${app_args[excluded_patches]}" && "${app_args[excluded_patches]}" != *'"'* ]] && abort "patch names inside excluded-patches must be quoted"
76+
app_args[included_patches]="$(toml_get "$t" included-patches)" || app_args[included_patches]=""
77+
[[ -n "${app_args[included_patches]}" && "${app_args[included_patches]}" != *'"'* ]] && abort "patch names inside included-patches must be quoted"
78+
app_args[exclusive_patches]="$(toml_get "$t" exclusive-patches)" && vtf "${app_args[exclusive_patches]}" "exclusive-patches" || app_args[exclusive_patches]="false"
79+
app_args[version]="$(toml_get "$t" version)" || app_args[version]="auto"
80+
app_args[app_name]="$(toml_get "$t" app-name)" || app_args[app_name]="$table_name"
81+
app_args[patcher_args]="$(toml_get "$t" patcher-args)" || app_args[patcher_args]=""
82+
app_args[table]="$table_name"
83+
9284
for dl_from in "direct" "uptodown" "apkmirror" "archive"; do
93-
if app_args[${dl_from}_dlurl]=$(toml_get "$t" ${dl_from}-dlurl); then
94-
app_args[${dl_from}_dlurl]=${app_args[${dl_from}_dlurl]%/}
95-
app_args[${dl_from}_dlurl]=${app_args[${dl_from}_dlurl]%download}
96-
app_args[${dl_from}_dlurl]=${app_args[${dl_from}_dlurl]%/}
97-
app_args[dl_from]=${dl_from}
85+
if dl_url="$(toml_get "$t" "${dl_from}-dlurl")"; then
86+
dl_url="${dl_url%/}";
87+
dl_url="${dl_url%download}";
88+
dl_url="${dl_url%/}"
89+
app_args[${dl_from}_dlurl]="$dl_url"
90+
app_args[dl_from]="$dl_from"
9891
else
9992
app_args[${dl_from}_dlurl]=""
10093
fi
10194
done
102-
if [ -z "${app_args[dl_from]-}" ]; then abort "ERROR: no 'apkmirror-dlurl', 'uptodown-dlurl' or 'archive-dlurl' option was set for '$table_name'."; fi
103-
app_args[arch]=$(toml_get "$t" arch) || app_args[arch]="all"
104-
if ! isoneof "${app_args[arch]}" "both" "all" "arm64-v8a" "arm-v7a" "x86_64" "x86"; then
105-
abort "wrong arch '${app_args[arch]}' for '$table_name'"
106-
fi
107-
108-
app_args[dpi]=$(toml_get "$t" dpi) || app_args[dpi]="$DEF_DPI_LIST"
95+
[[ -z "${app_args[dl_from]-}" ]] && abort "ERROR: no 'apkmirror-dlurl', 'uptodown-dlurl' or 'archive-dlurl' option was set for '$table_name'."
96+
app_args[arch]="$(toml_get "$t" arch)" || app_args[arch]="all"
97+
isoneof "${app_args[arch]}" "both" "all" "arm64-v8a" "arm-v7a" "x86_64" "x86" || abort "wrong arch '${app_args[arch]}' for '$table_name'"
98+
app_args[dpi]="$(toml_get "$t" dpi)" || app_args[dpi]="$DEF_DPI_LIST"
10999

110-
if [ "${app_args[arch]}" = both ]; then
100+
if [[ "${app_args[arch]}" == "both" ]]; then
111101
app_args[table]="$table_name (arm64-v8a)"
112102
app_args[arch]="arm64-v8a"
113103
idx=$((idx + 1))
@@ -121,16 +111,14 @@ for table_name in $(toml_get_table_names); do
121111
idx=$((idx + 1))
122112
build_uni "$(declare -p app_args)" &
123113
else
124-
if ! isoneof "${app_args[arch]}" "all"; then
125-
app_args[table]="${table_name} (${app_args[arch]})"
126-
fi
114+
isoneof "${app_args[arch]}" "all" || app_args[table]="${table_name} (${app_args[arch]})"
127115
idx=$((idx + 1))
128116
build_uni "$(declare -p app_args)" &
129117
fi
130118
done
131119
wait
132120
rm -rf temp/tmp.*
133-
if [ -z "$(ls -A1 "${BUILD_DIR}")" ]; then abort "All builds failed."; fi
121+
[[ -z "$(ls -A1 "$BUILD_DIR")" ]] && abort "All builds failed."
134122

135123
log "\n- ▶️ » Install [MicroG-RE](https://github.com/MorpheApp/MicroG-RE/releases) for YouTube and YT Music APKs\n"
136124
log "$(cat "$TEMP_DIR"/*/changelog.md)"

config.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
parallel-jobs = 1
22

3-
# Morphe
43
[YouTube]
54
uptodown-dlurl = "https://youtube.en.uptodown.com/android"
65
apkmirror-dlurl = "https://apkmirror.com/apk/google-inc/youtube"
@@ -17,17 +16,16 @@ uptodown-dlurl = "https://reddit-official-app.en.uptodown.com/android"
1716
apkmirror-dlurl = "https://apkmirror.com/apk/redditinc/reddit"
1817
patcher-args = "-e 'Custom branding name for Reddit' -OappName='Morphe Reddit'"
1918

20-
# Piko
2119
[X]
2220
uptodown-dlurl = "https://twitter.en.uptodown.com/android"
23-
# apkmirror-dlurl = "https://apkmirror.com/apk/x-corp/twitter"
21+
apkmirror-dlurl = "https://apkmirror.com/apk/x-corp/twitter"
2422
patches-source = "crimera/piko"
2523
brand = "Piko"
2624
included-patches = "'Browse tweet object' 'Dynamic color'"
2725

2826
[Twitter]
2927
uptodown-dlurl = "https://twitter.en.uptodown.com/android"
30-
# apkmirror-dlurl = "https://apkmirror.com/apk/x-corp/twitter"
28+
apkmirror-dlurl = "https://apkmirror.com/apk/x-corp/twitter"
3129
patches-source = "crimera/piko"
3230
brand = "Piko"
3331
included-patches = "'Bring back twitter' 'Browse tweet object' 'Dynamic color'"

0 commit comments

Comments
 (0)