From 266e7b36d4db871a0e0b21248a386403b8561fc3 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 28 Nov 2025 11:59:00 +0100 Subject: [PATCH] Update run.sh to generate net.aliasvault.app.yml with latest version and branch for proper F-Droid build (#1405) --- apps/mobile-app/android/fdroid/.gitignore | 1 + ...pp.yml => net.aliasvault.app.yml.template} | 7 ++- apps/mobile-app/android/fdroid/run.sh | 55 ++++++++++++++++++- 3 files changed, 57 insertions(+), 6 deletions(-) rename apps/mobile-app/android/fdroid/{net.aliasvault.app.yml => net.aliasvault.app.yml.template} (92%) diff --git a/apps/mobile-app/android/fdroid/.gitignore b/apps/mobile-app/android/fdroid/.gitignore index 30f68ef89..e8a47d513 100644 --- a/apps/mobile-app/android/fdroid/.gitignore +++ b/apps/mobile-app/android/fdroid/.gitignore @@ -1,2 +1,3 @@ fdroiddata fdroidserver +net.aliasvault.app.yml diff --git a/apps/mobile-app/android/fdroid/net.aliasvault.app.yml b/apps/mobile-app/android/fdroid/net.aliasvault.app.yml.template similarity index 92% rename from apps/mobile-app/android/fdroid/net.aliasvault.app.yml rename to apps/mobile-app/android/fdroid/net.aliasvault.app.yml.template index 8be62b2cf..489aa4780 100644 --- a/apps/mobile-app/android/fdroid/net.aliasvault.app.yml +++ b/apps/mobile-app/android/fdroid/net.aliasvault.app.yml.template @@ -13,9 +13,9 @@ RepoType: git Repo: https://github.com/aliasvault/aliasvault.git Builds: - - versionName: 0.1.0 - versionCode: 1 - commit: main + - versionName: __VERSION_NAME__ + versionCode: __VERSION_CODE__ + commit: __COMMIT__ subdir: apps/mobile-app/android/app/ sudo: - sysctl fs.inotify.max_user_watches=524288 || true @@ -44,6 +44,7 @@ Builds: - apps/mobile-app/node_modules/react-native-context-menu-view/android/build.gradle - apps/mobile-app/node_modules/react-native-get-random-values/android/build.gradle - apps/mobile-app/node_modules/react-native-svg/android/build.gradle + - apps/mobile-app/node_modules/react-native-vision-camera/android/build.gradle scandelete: - apps/mobile-app/node_modules/ diff --git a/apps/mobile-app/android/fdroid/run.sh b/apps/mobile-app/android/fdroid/run.sh index da4b5fd9d..a5441211d 100755 --- a/apps/mobile-app/android/fdroid/run.sh +++ b/apps/mobile-app/android/fdroid/run.sh @@ -2,15 +2,64 @@ set -e # Exit on any error, except where explicitly ignored trap 'echo "🛑 Interrupted. Exiting..."; exit 130' INT # Handle Ctrl+C cleanly +# Get the directory where this script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BUILD_GRADLE="${SCRIPT_DIR}/../app/build.gradle" +TEMPLATE_FILE="${SCRIPT_DIR}/net.aliasvault.app.yml.template" +OUTPUT_FILE="${SCRIPT_DIR}/net.aliasvault.app.yml" + +# Check if template exists +if [ ! -f "$TEMPLATE_FILE" ]; then + echo "❌ Error: Template file not found: $TEMPLATE_FILE" + exit 1 +fi + +# Check if build.gradle exists +if [ ! -f "$BUILD_GRADLE" ]; then + echo "❌ Error: build.gradle not found: $BUILD_GRADLE" + exit 1 +fi + +# Extract version information from build.gradle +echo "📱 Extracting version information from build.gradle..." +VERSION_CODE=$(grep -E '^\s*versionCode\s+' "$BUILD_GRADLE" | sed -E 's/.*versionCode\s+([0-9]+).*/\1/') +VERSION_NAME=$(grep -E '^\s*versionName\s+' "$BUILD_GRADLE" | sed -E 's/.*versionName\s+"([^"]+)".*/\1/') + +if [ -z "$VERSION_CODE" ] || [ -z "$VERSION_NAME" ]; then + echo "❌ Error: Could not extract version information from build.gradle" + echo " versionCode: ${VERSION_CODE:-not found}" + echo " versionName: ${VERSION_NAME:-not found}" + exit 1 +fi + +# Get current git branch +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main") + +echo "✅ Version information extracted:" +echo " versionCode: $VERSION_CODE" +echo " versionName: $VERSION_NAME" +echo " commit: $CURRENT_BRANCH" + +# Generate the F-Droid metadata file from template +echo "📝 Generating F-Droid metadata file..." +sed -e "s/__VERSION_NAME__/$VERSION_NAME/g" \ + -e "s/__VERSION_CODE__/$VERSION_CODE/g" \ + -e "s/__COMMIT__/$CURRENT_BRANCH/g" \ + "$TEMPLATE_FILE" > "$OUTPUT_FILE" + +echo "✅ Generated: $OUTPUT_FILE" + # Create outputs bind dir and set correct permissions mkdir -p outputs sudo chown -R 1000:1000 outputs # Build and run the Docker environment -echo "Building Docker images..." +echo "🐳 Building Docker images..." if ! docker compose build; then echo "⚠️ Warning: Docker build failed, continuing..." fi -echo "Running fdroid-buildserver..." -docker compose run --rm fdroid-buildserver \ No newline at end of file +echo "🚀 Running fdroid-buildserver..." +docker compose run --rm fdroid-buildserver + +echo "✅ F-Droid build completed!"