diff --git a/.fdroid.yml b/.fdroid.yml index 5a37570..005e2b0 100644 --- a/.fdroid.yml +++ b/.fdroid.yml @@ -11,21 +11,19 @@ RepoType: git Repo: https://github.com/andre487/AndroidMegaProxy.git Builds: - - versionName: 0.0.4 - versionCode: 4 - commit: v0.0.4 + - versionName: 0.0.5 + versionCode: 5 + commit: v0.0.5 subdir: app ndk: 29.0.14206865 sudo: - apt-get update - - apt-get install -t bookworm-backports -y golang-go + - apt-get install -t trixie-backports -y golang-go - apt-get install -y gcc libc-dev make gradle: - yes srclibs: - go@go1.26.3 - rm: - - libs/megaproxy-sources.jar binary: https://github.com/andre487/AndroidMegaProxy/releases/download/v%v/mega-proxy-universal.apk build: - pushd $$go$$/src @@ -34,14 +32,9 @@ Builds: - export GOROOT=$$go$$ - export GOPATH=$HOME/go - export PATH=$GOROOT/bin:$GOPATH/bin:$PATH - - cd ../native - - go install golang.org/x/mobile/cmd/gomobile@v0.0.0-20260821190718-4776eadac327 - - go install golang.org/x/mobile/cmd/gobind@v0.0.0-20260821190718-4776eadac327 - - gomobile init - - gomobile bind -target=android -androidapi 26 -trimpath -ldflags='-s -w -buildid=' - -o ../app/libs/megaproxy.aar ./mobile + - ../scripts/build-fdroid-native.sh AutoUpdateMode: Version UpdateCheckMode: Tags -CurrentVersion: 0.0.4 -CurrentVersionCode: 4 +CurrentVersion: 0.0.5 +CurrentVersionCode: 5 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4efcf2f..10e02c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,21 +67,8 @@ jobs: "ndk;29.0.14206865" echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/29.0.14206865" >> "$GITHUB_ENV" - - name: Install gomobile - run: | - go install golang.org/x/mobile/cmd/gomobile@v0.0.0-20260821190718-4776eadac327 - gomobile init - - - name: Build arm64 Android AAR - working-directory: native - run: | - mkdir -p ../app/libs - gomobile bind \ - -target=android/arm64 \ - -androidapi 26 \ - -trimpath \ - -o ../app/libs/megaproxy.aar \ - ./mobile + - name: Build native library using the F-Droid recipe + run: ./scripts/build-fdroid-native.sh - - name: Run Android unit tests, lint, and debug build - run: ./gradlew --no-daemon testDebugUnitTest lintDebug assembleDebug + - name: Run Android tests, checks, and clean-store builds + run: ./gradlew --no-daemon testDebugUnitTest lintDebug assembleDebug assembleRelease diff --git a/.github/workflows/fdroid-recipe.yml b/.github/workflows/fdroid-recipe.yml new file mode 100644 index 0000000..e80ce2d --- /dev/null +++ b/.github/workflows/fdroid-recipe.yml @@ -0,0 +1,35 @@ +name: F-Droid recipe + +on: + push: + branches: + - main + paths: + - .fdroid.yml + - app/build.gradle.kts + - native/** + - scripts/build-fdroid-native.sh + - scripts/check-fdroid-metadata-sync.sh + - .github/workflows/fdroid-recipe.yml + schedule: + - cron: "17 6 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: fdroid-recipe-${{ github.ref }} + cancel-in-progress: true + +jobs: + metadata-sync: + name: Check fdroiddata synchronization + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Check out repository + uses: actions/checkout@v6 + + - name: Compare the recipe with fdroiddata + run: ./scripts/check-fdroid-metadata-sync.sh diff --git a/.gitignore b/.gitignore index 7be93a8..b8ad376 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .gradle/ +.kotlin/ .idea/ local.properties **/build/ diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 53f86e3..83d9f40 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -28,8 +28,8 @@ android { applicationId = "net.megaproxy487" minSdk = 26 targetSdk = 35 - versionCode = 4 - versionName = "0.0.4" + versionCode = 5 + versionName = "0.0.5" buildConfigField("String", "GIT_COMMIT_HASH", "\"$gitCommitHash\"") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/fastlane/metadata/android/en-US/changelogs/5.txt b/fastlane/metadata/android/en-US/changelogs/5.txt new file mode 100644 index 0000000..251d204 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/5.txt @@ -0,0 +1,3 @@ +Make the F-Droid build recipe easier to maintain and verify. + +GitHub Actions now exercises the same native release build path, while a scheduled check reports when fdroiddata needs to be updated. diff --git a/fastlane/metadata/android/ru-RU/changelogs/5.txt b/fastlane/metadata/android/ru-RU/changelogs/5.txt new file mode 100644 index 0000000..219cd4e --- /dev/null +++ b/fastlane/metadata/android/ru-RU/changelogs/5.txt @@ -0,0 +1,3 @@ +Упрощена поддержка и проверка рецепта сборки F-Droid. + +GitHub Actions теперь проверяет тот же путь сборки нативной release-библиотеки, а плановая проверка сообщает, когда требуется обновить fdroiddata. diff --git a/scripts/build-fdroid-native.sh b/scripts/build-fdroid-native.sh new file mode 100755 index 0000000..255fc46 --- /dev/null +++ b/scripts/build-fdroid-native.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -euo pipefail + +script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +project_dir="$(cd -- "$script_dir/.." && pwd)" +gomobile_version="v0.0.0-20260821190718-4776eadac327" + +: "${ANDROID_HOME:?ANDROID_HOME must point to the Android SDK}" + +export GOPATH="${GOPATH:-$HOME/go}" +export PATH="${GOROOT:+$GOROOT/bin:}$GOPATH/bin:$PATH" + +go install "golang.org/x/mobile/cmd/gomobile@$gomobile_version" +go install "golang.org/x/mobile/cmd/gobind@$gomobile_version" +gomobile init + +mkdir -p "$project_dir/app/libs" +cd "$project_dir/native" +gomobile bind \ + -target=android \ + -androidapi 26 \ + -trimpath \ + -ldflags='-s -w -buildid=' \ + -o "$project_dir/app/libs/megaproxy.aar" \ + ./mobile diff --git a/scripts/check-fdroid-metadata-sync.sh b/scripts/check-fdroid-metadata-sync.sh new file mode 100755 index 0000000..5cc68ff --- /dev/null +++ b/scripts/check-fdroid-metadata-sync.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -euo pipefail + +script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +project_dir="$(cd -- "$script_dir/.." && pwd)" +local_metadata="$project_dir/.fdroid.yml" +temporary_metadata="$(mktemp)" +trap 'rm -f "$temporary_metadata"' EXIT + +upstream_url="https://gitlab.com/fdroid/fdroiddata/-/raw/master/metadata/net.megaproxy487.yml" +pending_url="https://gitlab.com/andre487/fdroiddata/-/raw/net.megaproxy487/metadata/net.megaproxy487.yml" + +if curl --fail --silent --show-error --location "$upstream_url" > "$temporary_metadata"; then + metadata_url="$upstream_url" +elif curl --fail --silent --show-error --location "$pending_url" > "$temporary_metadata"; then + metadata_url="$pending_url" +else + echo "Unable to download MegaProxy metadata from fdroiddata or its pending fork." >&2 + exit 1 +fi + +ruby -ryaml -e ' + keys = %w[ + AllowedAPKSigningKeys Builds AutoUpdateMode UpdateCheckMode + CurrentVersion CurrentVersionCode + ] + local = YAML.safe_load(File.read(ARGV[0]), permitted_classes: [], aliases: false) + remote = YAML.safe_load(File.read(ARGV[1]), permitted_classes: [], aliases: false) + local_recipe = local.select { |key, _| keys.include?(key) } + remote_recipe = remote.select { |key, _| keys.include?(key) } + exit 0 if local_recipe == remote_recipe + + warn "The F-Droid recipe is out of sync with #{ARGV[2]}." + warn "Update metadata/net.megaproxy487.yml in fdroiddata after merging the app change." + warn "Local recipe: #{local_recipe.inspect}" + warn "Remote recipe: #{remote_recipe.inspect}" + exit 1 +' "$local_metadata" "$temporary_metadata" "$metadata_url" + +echo "F-Droid metadata matches $metadata_url"