- Python 99.2%
- Shell 0.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| morphe_auto | ||
| options | ||
| scripts | ||
| tests | ||
| .env.example | ||
| .gitignore | ||
| config.toml | ||
| LICENSE | ||
| README.md | ||
apk-build: automatically patch APKs with Morphe, Piko, Hushfacebook, HushMessenger, and Hushfeed
This workflow runs daily on Forgejo Actions:
- Fetch the latest stable release for each configured patches repository (Morphe by default, or Piko, Hushfacebook, HushMessenger, or Hushfeed per app). Prereleases are ignored.
- Compare it with the previous build. If the patches, source APK, and config are unchanged, the app is SKIPPED (exit 0) without downloading anything.
- When something changed:
- Download the APK from your
apk_url.
- Download the APK from your
- Verify that the APK version is supported by the patches.
- Patch it with the Morphe CLI using patch choices in
config.tomland option values inoptions/<app>.json. - Sign it with your fixed keystore.
- Check the version again after patching.
- Publish one Forgejo Release per patches repository, containing its rebuilt apps (with that repository's
NOTICEattached, see License and legal), and send one grouped Discord notification per release.
- Delete marked releases beyond
keep_releasesper app or older thanrelease_max_age_days, always retaining the newest release of each app, even when it is older thanrelease_max_age_days: an app with no new build for more than 30 days keeps its last release, and that release is deleted only after a newer one for the same app exists. A shared release counts for every app whose marker it contains. This retention step runs after every publish-enabled workflow run, including runs where every app is skipped.
Pipeline state is stored directly in each release. A release body contains one hidden <!-- morphe-build:... --> marker per app and includes an app-specific *-build-info.json file. Do not edit or remove these markers. Deleting the latest release for an app causes the next run to build it again.
Cleanup deletes through Forgejo so release assets are also removed from R2. Do not use R2 lifecycle rules: they would leave broken download links and stale state markers in Forgejo.
Initial setup
1. Create a keystore
A fixed keystore is required so future builds can update previously installed versions.
./scripts/gen-keystore.sh morphe-release.p12
The script uses keytool when Java is available and falls back to openssl. Back up the .p12 file in a safe location: if it is lost, users must uninstall the app before installing a new build. Do not commit this file.
2. Create Forgejo secrets
Open Settings → Actions → Secrets:
| Secret | Value |
|---|---|
MORPHE_REPO_TOKEN |
Forgejo access token with the write:repository scope (User settings → Applications) |
KEYSTORE_B64 |
Contents of the morphe-release.p12.b64 file created by the script |
KEYSTORE_PASSWORD |
Keystore password |
KEYSTORE_ALIAS |
Alias, default: morphe |
DISCORD_WEBHOOK_URLS |
Discord webhook URLs, one per line (required when discord.enabled = true) |
DISCORD_PROVIDER_USER_ID |
(optional) Your numeric Discord user ID for the Provided by mention on successful builds |
GH_API_TOKEN |
(optional) GitHub token to avoid the 60 requests/hour unauthenticated limit |
These secrets must be created in the same repository that runs the workflow, not only at the account level or in another repository. Before the Patch step, the workflow checks MORPHE_REPO_TOKEN, KEYSTORE_B64, KEYSTORE_PASSWORD, and the Discord webhook when enabled. If one is missing, the job stops and names the missing secret. The workflow maps MORPHE_REPO_TOKEN to the FORGEJO_TOKEN environment variable used by the application. KEYSTORE_PATH is suitable only when the runner already has the keystore at the exact path, so container runners should use KEYSTORE_B64.
Optional repository Variables (Settings → Actions → Variables), not secrets:
| Variable | Value |
|---|---|
KEEP_RELEASES |
Override global.keep_releases for both cleanup and post-publish pruning without a commit; requires Forgejo 1.20+ for Actions variables |
An unset or empty variable falls back to config.toml. Before allowing the scheduled cleanup to delete releases above a new limit, run Cleanup old releases manually with dry_run = true and inspect its log.
To disable Discord notifications, set discord.enabled = false in config.toml and push the change. When it is true, set DISCORD_WEBHOOK_URLS to one HTTPS webhook URL per line in a Forgejo Actions secret. Blank lines are ignored; invalid URLs are skipped with a warning. Set DISCORD_PROVIDER_USER_ID to your numeric Discord user ID (not your username or a <@...> tag) to add a Provided by mention only to successful build notifications; enable Developer Mode in Discord and copy your user ID from your profile. Invalid IDs are ignored with a warning.
3. Configure an app
Edit config.toml and set apk_url to a direct download URL for an .apk, .apkm, .xapk, or .apks file. URLs that return an HTML page are rejected.
YouTube Music (com.google.android.apps.youtube.music) and Reddit (com.reddit.frontpage) use Morphe patches. X and Instagram use patches_repo = "crimera/piko"; Facebook, Messenger, and TikTok use the upstream SysAdminDoc HushFacebook, HushMessenger, and HushFeed. Choose a version supported by that app's stable patches release; force = false rejects unsupported and experimental-only versions. The [apps.patches] rules use upstream recommended patches, so no options JSON is required unless you want to customize patch options.
For Piko v3.9.0, use X 12.19.1-release.0 or Instagram 439.0.0.37.89 as APKM downloads; Instagram must be the arm64-v8a variant. X has no clone patch: its patched build replaces the Play Store app, so uninstall the official X app first because its signature differs. The recommended Change version code patch prevents Play Store updates. Neither app needs MicroG or PotHelper. Check supported versions again with pick-patches --app x --list or --app instagram --list before choosing a download.
HushFeed (SysAdminDoc/HushFeed) supports only TikTok 47.8.3, global package com.zhiliaoapp.musically (not JP/trill). Use the plain APKMirror APK (arm64-v8a + armeabi-v7a, nodpi), not an APKM bundle (the CLI's bundle merge breaks three patches) and not the arm64-v8a-only APK (a separate build HushFeed rejects). The patched build replaces the official TikTok app; uninstall the official app first because the signatures differ. The optional Run beside the store app patch only works together with a Clone app patch, which HushFeed lacks. MicroG is not required; HushFeed includes Fix Google login. Check the current patch selection with python3 -m morphe_auto pick-patches --app tiktok --list before building.
HushFacebook (SysAdminDoc/HushFacebook) supports Facebook (com.facebook.katana) 588.0.0.42.55 (arm64-v8a build 707615136, armeabi-v7a build 707615135); 587 and older are no longer supported. The configured download is APKMirror's arm64-v8a, 120-480dpi, Android 11+ APKM bundle. When updating it, use the exact supported build, not another variant of the same version. HushFacebook has no Clone app patch: uninstall the official Facebook app first because the signatures differ. The recommended Install beside Meta's apps patch permits Messenger to remain installed; the Marketplace only runtime switch is off by default. Check the latest versions and patch selection with python3 -m morphe_auto pick-patches --app facebook --list before building. Meta may detect the re-signed app; consider the account risk before installing.
HushMessenger (SysAdminDoc/HushMessenger) supports Messenger (com.facebook.orca) 587.0.0.54.96. The arm64-v8a and armeabi-v7a version codes listed in its README work (arm64 nodpi: 347415280, 347415333, 347415350). Use a regular APK, not a bundle. HushMessenger has no Clone app patch: uninstall the official Messenger app first because the signatures differ. The recommended Install beside Meta apps patch allows it to coexist with patched Facebook; both patched apps must be signed with the same keystore, which this pipeline already uses. Check the latest versions and patch selection with python3 -m morphe_auto pick-patches --app messenger --list before building. Meta may detect the re-signed app; consider the account risk before installing.
Create the options file (Java 21 is required: sudo apt install openjdk-21-jre-headless):
python3 -m morphe_auto init-options --app youtube
This command creates options/youtube.json with every patch available for the app in its default state. Edit "options" values as needed, then commit the file. Running the command again replaces old patch bundles with the current release: it preserves choices for patches and option keys still available, adds new patches at their defaults, and removes obsolete patches and option keys. When [apps.patches] is present, its rules override all "enabled" values in this JSON.
Choosing patches
python3 -m morphe_auto pick-patches --app youtube --list # View available patches
python3 -m morphe_auto pick-patches --app youtube # Select interactively
The picker shows numbered patches from the latest stable patches-list.json. Enter numbers or ranges such as 1 5-8 to toggle them, /text to filter names (/ clears it), d 5 for details, b to switch base, r to reset, Enter to review and confirm, or q to quit without saving. Commit and push config.toml to trigger a CI build.
You can also edit the rules directly:
[apps.patches]
base = "recommended" # or "none"
include = ["Override certificate pinning"]
exclude = ["Hide ads"]
recommended starts from upstream-recommended patches; include adds and exclude removes. none enables only include, so newly released patches remain off until selected. Patch names are matched case-insensitively. Unknown or incompatible names stop a run before the APK download, including on dry runs. Apps without [apps.patches] continue to use the options JSON "enabled" values. For non-root YouTube, keep GmsCore support enabled to sign in.
4. Configure the runner
In .forgejo/workflows/daily-patch.yml, change runs-on: docker to your runner label. The job uses the ARM64/AMD64 node:20-bookworm image, which must provide:
nodeforactions/checkoutandsetup-java,git,aptto install Python 3.11 when the image does not already have it.
The workflow installs Python 3.11 from the Debian Bookworm repository instead of using actions/setup-python, because that action does not provide a suitable build for this ARM64 runner. Do not switch the image to Bullseye, whose repository only provides Python 3.9.
The node:20-bookworm image satisfies these requirements. Java 21 is installed by setup-java.
5. Check Forgejo and the reverse proxy
Patched APKs are commonly 100-200 MB. Make sure that:
[repository.release] ALLOWED_TYPESinapp.iniis empty (allowing all file types) or includes.apk.- The reverse proxy in front of Forgejo permits sufficiently large uploads. For nginx, for example:
client_max_body_size 512m;(the default is only 1 MB).
Then open the Actions tab and run the workflow manually once to verify the setup.
When the workflow runs
- Every day at 01:00 UTC (08:00 Vietnam time).
- When changes to
config.tomloroptions/**are pushed tomain. - Manually, with these inputs:
force: rebuild even when nothing changed.app: run only selected apps, for exampleyoutube,youtube-music.
- The separate Cleanup old releases workflow runs daily at 04:00 UTC (11:00 Vietnam time). Manual runs default to
dry_run = true, which only previews deletions and leaves the releases unchanged; review the Actions log before running withdry_run = false.max_age_daysoptionally overrides the config value;keep_releasesoverrides theKEEP_RELEASESvariable and config value for that run. Cleanup does not send Discord messages.
config.toml reference
| Field | Default | Description |
|---|---|---|
global.patches_repo |
MorpheApp/morphe-patches |
GitHub repository containing patches (.mpp) |
global.cli_repo |
MorpheApp/morphe-desktop |
GitHub repository containing the Morphe CLI |
global.keep_releases |
5 (3 in this repo) |
Number of releases to keep for each app; overridden by env KEEP_RELEASES |
global.release_max_age_days |
30 |
Delete older marked releases, keeping each app's latest even if it is older, until a newer build of that app exists; 0 disables age-based pruning |
global.java_opts |
[] |
JVM arguments, for example ["-Xmx4g"] |
discord.enabled |
false |
Enable Discord webhook notifications |
forgejo.url / forgejo.repo |
Used only for local runs; Actions reads these values from environment variables | |
apps[].id |
(required) | Unique ID containing only a-z0-9_- |
apps[].package |
(required) | Package name used to verify that the downloaded APK is the expected app |
apps[].apk_url |
(required) | Direct download URL for the source APK |
apps[].apk_type |
auto-detect | apk / apkm / xapk / apks |
apps[].variant |
Free-text hint for the APKMirror variant to pick (not used by builds), printed by scripts/apkmirror_to_openlist.py |
|
apps[].release_url |
APKMirror release page with {v} for the version in dashes, e.g. https://www.apkmirror.com/apk/<dev>/<app>/<app>-{v}-release/; the download script opens it instead of searching |
|
apps[].patches_repo |
global.patches_repo |
Override the patches repository for this app, for example crimera/piko |
apps[].options_file |
Morphe options file; omit it to use patch defaults | |
apps[].striplibs |
[] |
Keep only these architectures, for example ["arm64-v8a"] |
apps[].bytecode_mode |
CLI default | FULL / STRIP_SAFE / STRIP_FAST |
apps[].force |
false |
Patch unsupported versions too |
apps[].allow_experimental |
false |
Accept versions marked as experimental only |
apps[].continue_on_error |
false |
Publish even when patches fail (failures are listed in the release) |
apps[].enabled |
true |
Disable the app without removing it from the config |
apps[].extra_args |
[] |
Additional CLI flags; use pick-patches for patch selection |
apps[].patches.base |
recommended |
recommended or none (only when [apps.patches] exists) |
apps[].patches.include |
[] |
Patch names to enable |
apps[].patches.exclude |
[] |
Recommended patch names to disable |
A rebuild is triggered when:
- A new stable patches tag is available.
- The APK on the server changes, based on ETag/Last-Modified or SHA-256 when the server provides neither header.
- The app config or the
patchessection of its options file changes.
When the APK version changes, the build reason includes the old and new versions.
A new Morphe CLI release does not trigger a rebuild by itself.
Rebuilt apps are grouped by patches repository. Each group gets its own release tagged {slug}-{tag} (for example morphe-v1.44.0, piko-v3.9.0, hushfacebook-v0.11.0, hushmessenger-v0.23.3, or hushfeed-v0.71.3), a changelog, its own NOTICE, and one grouped Discord message. Old patches-* releases remain readable as previous build state and can still be pruned.
Run locally
python3 -m unittest # Unit tests; no network required
python3 -m morphe_auto pick-patches --app youtube --list # Show compatible patches
python3 -m morphe_auto run --dry-run # Print BUILD/SKIP for each app
python3 -m morphe_auto cleanup --dry-run --max-age-days 1 # Preview release cleanup without deleting
KEEP_RELEASES=3 python3 -m morphe_auto cleanup --dry-run # Preview with a per-app release limit
KEYSTORE_PATH=morphe-release.p12 KEYSTORE_PASSWORD=... \
python3 -m morphe_auto run --no-publish --app youtube # Build into out/ without a release or Discord notification
For --dry-run to compare against the previous build, fill in [forgejo] in the config and set FORGEJO_TOKEN (required for private repositories). Without both, every app is shown as BUILD.
For local cleanup, fill in [forgejo] (or set GITHUB_SERVER_URL and GITHUB_REPOSITORY). Dry-run needs a token for private repositories; actual deletion always requires FORGEJO_TOKEN. Compare the preview with Forgejo Releases and confirm each app's newest release is absent before deleting. After deletion, verify the R2 bucket's usage falls and the next daily patch run skips unchanged apps.
Troubleshooting
- Build fails with an "is not supported" message:
apk_urlpoints to a version unsupported by the current patches. The error is reported immediately after download, before Morphe runs, and lists supported versions; change the URL to one of them. The pipeline intentionally does not publish in this case because Morphe would silently skip most patches. - New patches are available: Discord and the release notes report new patches. With
[apps.patches], they follow the selected base (recommendedornone); without it, they use Morphe defaults. Runinit-optionsto add option values, then review the selection withpick-patches. - Unknown or incompatible patch name: Check the suggested spelling in the error, or run
pick-patches --app youtubeto select valid names and remove stale entries. SIGNING: Keystore does not contain entry: the alias or password is wrong. For PKCS12/JKS keystores, the pipeline converts the alias to lowercase because Morphe converts the keystore to BKS with a lowercase alias.- Release upload fails with 400/413: see step 5 (
ALLOWED_TYPES,client_max_body_size). - Discord notifications: Each published repository group sends one success message to every configured webhook with a release download button and a patch changelog button; success pings
@everyone, but build and publish failures do not ping and link to workflow logs when available. WhenDISCORD_PROVIDER_USER_IDis set, only successful build notifications includeProvided byfollowed by a mention of that account; failure notifications omit it. A failure at one webhook does not stop delivery to the others. APKs are not sent through webhooks (the default upload limit is 20 MiB). Long messages include adetails.mdattachment with the full text and logs. Each webhook URL automatically getswith_components=truefor buttons; to post in a thread, append?thread_id=<id>to that URL. If the ping does not notify anyone, allow Mention @everyone, @here, and All Roles for the webhook in that channel's permissions.
License and legal
This project is licensed under the GNU General Public License v3.0 or later (GPL-3.0-or-later). Copyright (C) 2026 nezumi.
Upstream components
This repository does not contain or redistribute the Morphe CLI or the patches; the workflow downloads them at run time.
| Component | License |
|---|---|
| MorpheApp/morphe-patches | GPLv3 with additional terms under section 7 (NOTICE) |
| crimera/piko | GPLv3 with additional terms under section 7b (NOTICE) |
| SysAdminDoc/HushFacebook | GPLv3 with additional terms under section 7 (NOTICE) |
| SysAdminDoc/HushMessenger | GPLv3 with additional terms under section 7 (NOTICE) |
| SysAdminDoc/HushFeed | GPLv3 with additional terms under section 7 (NOTICE) |
| MorpheApp/morphe-desktop (CLI) | GPLv3 with the same section 7 terms (NOTICE) |
Published APKs
A patched APK contains code from its patches repository, so it is a GPLv3 binary and every release:
- says it is an unofficial build (section 7c),
- attaches the upstream NOTICE of the exact patches version as
NOTICE-{repo_name}.txt(for exampleNOTICE-morphe-patches.txt,NOTICE-piko.txt,NOTICE-HushFacebook.txt,NOTICE-HushMessenger.txt, orNOTICE-HushFeed.txt, section 7b), - links to the source of that patches tag under "License and source".
If you fork this project, keep those parts of the release body. Section 7e also means the name "Morphe" and its logos are not licensed to you: name your own project and builds distinctly, and do not present them as official Morphe releases.
When a build applies GmsCore support or PoToken provider, the release body also has a "Required companion apps" section that links to the latest MicroG-RE or PotHelper release. These apps are only linked, never attached: PotHelper contains native code that may not be distributed together with GPLv3 code.
Disclaimer
This project is not affiliated with or endorsed by the Morphe project, Google, or any app publisher. Names such as YouTube belong to their owners and are used only to identify the app. The software is provided "as is", without warranty (see LICENSE).
The GPL covers Morphe's code and this tool, not the source app. A patched APK is a modified copy of third-party proprietary software, and you are responsible for having the right to download and redistribute it. Releases of a public repository are public: if you do not have that right, make the repository private or delete the releases.