Files
gandc 008379a09a
Build Futon with Niadd patch / Build Futon Niadd debug APK (push) Failing after 10m25s
fix
2026-08-10 01:22:32 +03:00

416 lines
12 KiB
YAML

name: Build Futon with Niadd patch
on:
push:
branches:
- main
paths:
- ".gitea/workflows/build.yml"
- "scripts/**"
- "patches/**"
workflow_dispatch:
env:
FUTON_REPOSITORY: "https://github.com/AppFuton/Futon.git"
FUTON_REF: "devel"
PARSERS_REPOSITORY: "https://github.com/Kotatsu-Redo/kotatsu-parsers-redo.git"
PARSERS_REF: "master"
ANDROID_PLATFORM: "36"
ANDROID_BUILD_TOOLS: "36.0.0"
jobs:
build:
name: Build Futon Niadd debug APK
runs-on: android-futon
steps:
- name: Checkout CI repository
uses: https://github.com/actions/checkout@v4
- name: Verify Android build environment
shell: bash
run: |
set -euxo pipefail
echo "=== Android SDK ==="
echo "ANDROID_HOME=${ANDROID_HOME}"
echo "ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT:-}"
echo "=== Installed build tools ==="
test -x "${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS}/aapt"
test -x "${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS}/aapt2"
echo "=== Java ==="
java -version
echo "=== Python ==="
python3 --version
echo "=== Git ==="
git --version
- name: Verify patch scripts
shell: bash
run: |
set -euxo pipefail
test -f scripts/patch_futon_niadd.py
test -f scripts/patch_ninemanga_niadd.py
test -f patches/futon-niadd-range-download.patch
python3 -m py_compile \
scripts/patch_futon_niadd.py \
scripts/patch_ninemanga_niadd.py
- name: Clone upstream repositories
shell: bash
run: |
set -euxo pipefail
rm -rf work
mkdir -p work
git clone \
--depth 1 \
--branch "${FUTON_REF}" \
"${FUTON_REPOSITORY}" \
work/Futon
git clone \
--depth 1 \
--branch "${PARSERS_REF}" \
"${PARSERS_REPOSITORY}" \
work/kotatsu-parsers-redo
echo "=== Futon upstream ==="
git -C work/Futon remote -v
git -C work/Futon rev-parse HEAD
echo "=== Parsers upstream ==="
git -C work/kotatsu-parsers-redo remote -v
git -C work/kotatsu-parsers-redo rev-parse HEAD
- name: Configure standalone Futon Niadd variant
shell: bash
run: |
set -euxo pipefail
python3 scripts/patch_futon_niadd.py \
work/Futon
echo "=== Verify applicationId suffix ==="
grep -F "applicationIdSuffix = '.niadd'" \
work/Futon/app/build.gradle
echo "=== Verify application name ==="
grep -F '>Futon Niadd</string>' \
work/Futon/app/src/debug/res/values/strings.xml
echo "=== Verify Niadd sync identifiers ==="
grep -F 'io.github.landwarderer.futon.niadd.sync' \
work/Futon/app/src/debug/res/values/constants.xml
grep -F 'io.github.landwarderer.futon.niadd.history' \
work/Futon/app/src/debug/res/values/constants.xml
grep -F 'io.github.landwarderer.futon.niadd.favourites' \
work/Futon/app/src/debug/res/values/constants.xml
echo "=== Ensure old debug identifiers are gone ==="
if grep -F 'org.futon.debug.sync' \
work/Futon/app/src/debug/res/values/constants.xml; then
echo "ERROR: old debug sync account type is still present"
exit 1
fi
if grep -F 'org.koitharu.futon.debug.history' \
work/Futon/app/src/debug/res/values/constants.xml; then
echo "ERROR: old debug history authority is still present"
exit 1
fi
if grep -F 'org.koitharu.futon.debug.favourites' \
work/Futon/app/src/debug/res/values/constants.xml; then
echo "ERROR: old debug favourites authority is still present"
exit 1
fi
echo "=== Futon resulting diff ==="
git -C work/Futon diff -- \
app/build.gradle \
app/src/debug/res/values/strings.xml \
app/src/debug/res/values/constants.xml
git -C work/Futon diff --check
- name: Apply Niadd range-download workaround
shell: bash
run: |
set -euxo pipefail
patch --dry-run -p1 \
-d work/Futon \
< patches/futon-niadd-range-download.patch
patch -p1 \
-d work/Futon \
< patches/futon-niadd-range-download.patch
PAGE_LOADER="work/Futon/app/src/main/kotlin/io/github/landwarderer/futon/reader/domain/PageLoader.kt"
grep -F 'NIADD_RANGE_CHUNK_SIZE = 16L * 1024L' \
"${PAGE_LOADER}"
grep -F 'MangaParserSource.NINEMANGA_RU' \
"${PAGE_LOADER}"
grep -F '.header("Range", "bytes=$offset-$requestedEnd")' \
"${PAGE_LOADER}"
git -C work/Futon diff --check
- name: Apply Niadd parser modifications
shell: bash
run: |
set -euxo pipefail
python3 scripts/patch_ninemanga_niadd.py \
work/kotatsu-parsers-redo
PARSER_FILE="work/kotatsu-parsers-redo/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt"
test -f "${PARSER_FILE}"
echo "=== Verify Niadd domain ==="
grep -F '"ru.niadd.com"' \
"${PARSER_FILE}"
echo "=== Verify source annotation ==="
grep -F '@MangaSourceParser("NINEMANGA_RU", "Niadd Русский", "ru")' \
"${PARSER_FILE}"
echo "=== Verify Niadd pagination ==="
grep -F 'domain.endsWith("niadd.com")' \
"${PARSER_FILE}"
grep -F 'append(".html")' \
"${PARSER_FILE}"
echo "=== Ensure old Russian domain is gone ==="
if grep -F '"ru.ninemanga.com"' "${PARSER_FILE}"; then
echo "ERROR: old ru.ninemanga.com domain is still present"
exit 1
fi
echo "=== Ensure Russian source is no longer marked Broken ==="
if grep -B1 \
'@MangaSourceParser("NINEMANGA_RU", "Niadd Русский", "ru")' \
"${PARSER_FILE}" | grep -F '@Broken'; then
echo "ERROR: Niadd Russian source is still marked @Broken"
exit 1
fi
echo "=== Parsers resulting diff ==="
git -C work/kotatsu-parsers-redo diff -- \
src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt
git -C work/kotatsu-parsers-redo diff --check
- name: Connect Futon to patched local parsers
shell: bash
run: |
set -euxo pipefail
cat >> work/Futon/settings.gradle <<'EOF'
// Added by futon-niadd-gitea-ci.
// Replace the JitPack kotatsu-parsers-redo dependency
// with the patched local parser source tree.
includeBuild('../kotatsu-parsers-redo') {
dependencySubstitution {
substitute module('com.github.clquwu:kotatsu-parsers-redo') using project(':')
}
}
EOF
echo "=== Resulting settings.gradle tail ==="
tail -n 20 work/Futon/settings.gradle
grep -F "includeBuild('../kotatsu-parsers-redo')" \
work/Futon/settings.gradle
grep -F "com.github.clquwu:kotatsu-parsers-redo" \
work/Futon/settings.gradle
- name: Build Futon Niadd debug APK
shell: bash
working-directory: work/Futon
env:
GRADLE_USER_HOME: /root/.gradle
GRADLE_OPTS: >-
-Dorg.gradle.daemon=false
-Dorg.gradle.jvmargs=-Xmx4g
run: |
set -euxo pipefail
chmod +x gradlew
echo "=== Build ==="
./gradlew \
--no-daemon \
--stacktrace \
--max-workers=6 \
:app:assembleDebug
- name: Verify APK identity
shell: bash
run: |
set -euxo pipefail
APK="work/Futon/app/build/outputs/apk/debug/app-debug.apk"
test -s "${APK}"
AAPT="${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS}/aapt"
AAPT2="${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS}/aapt2"
test -x "${AAPT}"
test -x "${AAPT2}"
echo "=== APK file ==="
ls -lh "${APK}"
echo "=== Extract APK badging ==="
"${AAPT}" dump badging "${APK}" \
> /tmp/futon-niadd-badging.txt
head -n 30 /tmp/futon-niadd-badging.txt
echo "=== Verify package name ==="
PACKAGE_INFO="$(
grep '^package:' /tmp/futon-niadd-badging.txt
)"
echo "${PACKAGE_INFO}"
echo "${PACKAGE_INFO}" |
grep -F "name='io.github.landwarderer.futon.niadd'"
echo "=== Ensure original Futon package is NOT used ==="
if echo "${PACKAGE_INFO}" |
grep -F "name='io.github.landwarderer.futon'"; then
echo "ERROR: APK uses the original Futon applicationId"
exit 1
fi
echo "=== Verify application label ==="
APP_LABEL="$(
grep '^application-label:' /tmp/futon-niadd-badging.txt
)"
echo "${APP_LABEL}"
echo "${APP_LABEL}" |
grep -F "application-label:'Futon Niadd'"
echo "=== Verify compiled Niadd resource values ==="
"${AAPT2}" dump resources "${APK}" \
> /tmp/futon-niadd-resources.txt
grep -F "io.github.landwarderer.futon.niadd.sync" \
/tmp/futon-niadd-resources.txt
grep -F "io.github.landwarderer.futon.niadd.history" \
/tmp/futon-niadd-resources.txt
grep -F "io.github.landwarderer.futon.niadd.favourites" \
/tmp/futon-niadd-resources.txt
echo "=== APK identity verification successful ==="
- name: Prepare build artifacts
shell: bash
run: |
set -euxo pipefail
APK="work/Futon/app/build/outputs/apk/debug/app-debug.apk"
test -s "${APK}"
rm -rf dist
mkdir -p dist
cp \
"${APK}" \
dist/Futon-Niadd-debug.apk
FUTON_SHA="$(
git -C work/Futon rev-parse HEAD
)"
PARSERS_SHA="$(
git -C work/kotatsu-parsers-redo rev-parse HEAD
)"
{
echo "Build: Futon Niadd"
echo
echo "Application ID: io.github.landwarderer.futon.niadd"
echo "Application name: Futon Niadd"
echo
echo "Futon repository: ${FUTON_REPOSITORY}"
echo "Futon ref: ${FUTON_REF}"
echo "Futon commit: ${FUTON_SHA}"
echo
echo "Parsers repository: ${PARSERS_REPOSITORY}"
echo "Parsers ref: ${PARSERS_REF}"
echo "Parsers commit: ${PARSERS_SHA}"
echo
echo "Android platform: ${ANDROID_PLATFORM}"
echo "Android build tools: ${ANDROID_BUILD_TOOLS}"
echo
echo "Java:"
java -version 2>&1
} > dist/build-info.txt
(
cd dist
sha256sum Futon-Niadd-debug.apk > SHA256SUMS
)
echo "=== Build artifacts ==="
ls -lh dist
echo "=== SHA256 ==="
cat dist/SHA256SUMS
echo "=== Build info ==="
cat dist/build-info.txt
- name: Upload APK
uses: https://github.com/actions/upload-artifact@v3.2.2-node20
with:
name: Futon-Niadd-debug
path: dist/
if-no-files-found: error
retention-days: 30