Modern Apps git

← Modern-Apps.git

general: update workflow for fdroid

Commit
5a569950d105991036eccc557dc0fb123d681f00
Author
Vayun Mathur <[email protected]>
When
2026-02-21 18:16 UTC (9 months ago)
Parents
c6e590f

Diff

.github/workflows/android.yml
diff --git a/.github/workflows/android.yml b/.github/workflows/android.ymlindex 892ab4a1e2..bec479bfbe 100644--- a/.github/workflows/android.yml+++ b/.github/workflows/android.yml@@ -2,11 +2,6 @@ name: "๐Ÿš€ Auto-Increment & Release"  on:   workflow_dispatch:-    inputs:-      version_name:-        description: 'New Version Name (e.g. v2.0)'-        required: true-        default: 'v1.0'  env:   ks_filename: release_keystore.jks@@ -39,43 +34,63 @@ jobs:       - name: Change Gradle Wrapper Permissions         run: chmod +x ./gradlew -      # 1. BUMP VERSION NAME & CODE-      - name: Bump Version Name and Code+      # 1. READ version.txt AND INJECT into build.gradle.kts+      - name: Read and Inject Version+        id: version_info         run: |-          NEW_NAME="${{ github.event.inputs.version_name }}"-          echo "Updating to Version Name: $NEW_NAME"+          VERSION_FILE="version.txt"           -          # Find all build.gradle files-          find . -name "build.gradle*" | while read file; do-            # Update versionName-            sed -i "s/versionName\([[:space:]]*=[[:space:]]*\|[[:space:]]*\)\"[^\"]*\"/versionName\1\"$NEW_NAME\"/g" "$file"+          if [ ! -f "$VERSION_FILE" ]; then+            echo "Error: $VERSION_FILE not found! Please create it with version code on line 1 and name on line 2."+            exit 1+          fi++          # Read values exactly as they are in the file+          VERSION_CODE=$(sed -n '1p' "$VERSION_FILE" | tr -d '\r' | xargs)+          VERSION_NAME=$(sed -n '2p' "$VERSION_FILE" | tr -d '\r' | xargs)++          echo "Using Version Name: $VERSION_NAME"+          echo "Using Version Code: $VERSION_CODE"+          +          # 2. INJECT variables into the defaultConfig block+          # This finds the line containing 'defaultConfig {' and appends the hardcoded +          # version assignments immediately after it. +          # It also handles overwriting versionCode/versionName lines if they existed.+          find . -name "build.gradle.kts" | while read file; do+            echo "Processing $file..."+          +            # First, remove any existing versionCode or versionName lines to avoid duplicates+            sed -i '/versionCode[[:space:]]*=[[:space:]]*/d' "$file"+            sed -i '/versionName[[:space:]]*=[[:space:]]*/d' "$file"           -            # Find current versionCode, increment it, and replace it-            CURRENT_CODE=$(grep -E "versionCode\s*(=?)\s*[0-9]+" "$file" | sed 's/[^0-9]*//g' | head -1)-            if [ ! -z "$CURRENT_CODE" ]; then-              NEXT_CODE=$((CURRENT_CODE + 1))-              echo "Bumping $file: Code $CURRENT_CODE -> $NEXT_CODE"-              sed -i "s/versionCode\([[:space:]]*=[[:space:]]*\|[[:space:]]*\)$CURRENT_CODE/versionCode\1$NEXT_CODE/g" "$file"-            fi+            # Now, inject the new hardcoded values right after 'defaultConfig {'+            # \a matches the line after the pattern+            sed -i "/defaultConfig[[:space:]]*{/a \        versionCode = $VERSION_CODE\n        versionName = \"$VERSION_NAME\"" "$file"           done -      # 2. COMMIT CHANGES-      - name: Commit & Push Changes+          # Export for later steps+          echo "version_name=$VERSION_NAME" >> $GITHUB_OUTPUT+          echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT++      # 3. COMMIT, TAG & PUSH+      - name: Commit, Tag & Push Changes         run: |           git config --global user.name "github-actions[bot]"           git config --global user.email "github-actions[bot]@users.noreply.github.com"           git add .-          git commit -m "chore: bump version to ${{ github.event.inputs.version_name }}" || echo "No changes to commit"-          git push+          +          TAG_NAME="v${{ steps.version_info.outputs.version_name }}"+          git commit -m "chore: prepare release $TAG_NAME (${{ steps.version_info.outputs.version_code }})" || echo "No changes to commit"+          +          git tag -f "$TAG_NAME"+          git push origin HEAD+          git push origin "$TAG_NAME" --force -      # 3. IMPROVED DETECTION: Search for modules with 'versionCode'+      # 4. DETECTION       - name: Detect App Modules         run: |-          # Finds directories containing build.gradle files that have a 'versionCode' entry-          # 1. Search for 'versionCode' in build.gradle files-          # 2. Extract the directory name (the module name)-          # 3. Filter out '.' (root) and duplicates-          MODULES=$(grep -rl "versionCode" . --include="build.gradle*" | awk -F/ '{print $(NF-1)}' | grep -vE "^\.$" | sort -u | tr '\n' ' ')+          # Detect modules by searching for the versionCode we just injected+          MODULES=$(grep -rl "versionCode" . --include="build.gradle.kts" | awk -F/ '{print $(NF-1)}' | grep -vE "^\.$" | sort -u | tr '\n' ' ')           echo "Detected modules: $MODULES"           echo "modules=$MODULES" >> $GITHUB_ENV @@ -84,15 +99,12 @@ jobs:           mkdir -p .github/lib           curl -L https://github.com/google/bundletool/releases/download/1.17.2/bundletool-all-1.17.2.jar -o .github/lib/bundletool.jar -      # 4. BUILD & SIGN+      # 5. BUILD & SIGN       - name: Build and Sign         run: |           mkdir -p distribution_apks           for module in ${{ env.modules }}; do-            echo "--------------------------------------------"             echo "Building: $module"-            echo "--------------------------------------------"-                       ./gradlew :$module:bundleRelease                        java -jar ".github/lib/bundletool.jar" build-apks \@@ -107,13 +119,16 @@ jobs:             unzip -p $module/build/outputs/bundle/release/$module.apks universal.apk > distribution_apks/$module-release.apk           done -      # 5. CREATE RELEASE & TAG+      # 6. CREATE RELEASE       - name: Create GitHub Release         uses: softprops/action-gh-release@v2         with:-          tag_name: ${{ github.event.inputs.version_name }}-          name: "Release ${{ github.event.inputs.version_name }}"-          body: "Automated release for version ${{ github.event.inputs.version_name }}. VersionCode has been auto-incremented."+          tag_name: "v${{ steps.version_info.outputs.version_name }}"+          name: "Release ${{ steps.version_info.outputs.version_name }}"+          body: |+            Automated release from version.txt.+            Version Name: ${{ steps.version_info.outputs.version_name }}+            Version Code: ${{ steps.version_info.outputs.version_code }}           files: distribution_apks/*.apk         env:           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\ No newline at end of file
build.gradle.kts
diff --git a/build.gradle.kts b/build.gradle.ktsindex 160871b496..8f822d6954 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -7,6 +7,21 @@ plugins {     alias(libs.plugins.ksp) apply false } +fun readVersionInfo(): Pair<Int, String> {+    val versionFile = File(projectDir, "version.txt")++    return if (versionFile.exists()) {+        val lines = versionFile.readLines()+        if (lines.size >= 2) {+            val code = lines[0].trim().toIntOrNull() ?: 1+            val name = lines[1].trim()+            code to name+        } else throw IllegalStateException("Invalid version.txt format")+    } else throw IllegalStateException("version.txt not found")+}++val (appVersionCode, appVersionName) = readVersionInfo()+ subprojects {     if(name == "app") return@subprojects @@ -35,6 +50,8 @@ subprojects {              defaultConfig {                 minSdk = 31+                versionCode = appVersionCode+                versionName = appVersionName                  //testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"             }
calendar/build.gradle.kts
diff --git a/calendar/build.gradle.kts b/calendar/build.gradle.ktsindex a764f4f83a..b8ff34f3d4 100644--- a/calendar/build.gradle.kts+++ b/calendar/build.gradle.kts@@ -1,8 +1,6 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.calendar"-        versionCode = 23-        versionName = "v2.0.0"     } } 
contacts/build.gradle.kts
diff --git a/contacts/build.gradle.kts b/contacts/build.gradle.ktsindex 2aefcacb0a..a8a674cd1d 100644--- a/contacts/build.gradle.kts+++ b/contacts/build.gradle.kts@@ -1,8 +1,6 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.contacts"-        versionCode = 23-        versionName = "v2.0.0"     } } 
crypto/build.gradle.kts
diff --git a/crypto/build.gradle.kts b/crypto/build.gradle.ktsindex fa4595cc81..46b42680c9 100644--- a/crypto/build.gradle.kts+++ b/crypto/build.gradle.kts@@ -1,8 +1,6 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.crypto"-        versionCode = 23-        versionName = "v2.0.0"     } } 
files/build.gradle.kts
diff --git a/files/build.gradle.kts b/files/build.gradle.ktsindex 78a28c0570..7bf4cc74f0 100644--- a/files/build.gradle.kts+++ b/files/build.gradle.kts@@ -1,7 +1,5 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.files"-        versionCode = 22-        versionName = "v2.0.0"     } }\ No newline at end of file
findfamily/build.gradle.kts
diff --git a/findfamily/build.gradle.kts b/findfamily/build.gradle.ktsindex 7d30253314..8aa715b3d5 100644--- a/findfamily/build.gradle.kts+++ b/findfamily/build.gradle.kts@@ -1,8 +1,6 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.findfamily"-        versionCode = 1-        versionName = "1.0"     } } 
games/chess/build.gradle.kts
diff --git a/games/chess/build.gradle.kts b/games/chess/build.gradle.ktsindex 62350262bd..7e07158953 100644--- a/games/chess/build.gradle.kts+++ b/games/chess/build.gradle.kts@@ -1,8 +1,6 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.games.chess"-        versionCode = 23-        versionName = "v2.0.0"     }      externalNativeBuild {
games/unblockjam/build.gradle.kts
diff --git a/games/unblockjam/build.gradle.kts b/games/unblockjam/build.gradle.ktsindex 05f095559a..6f73727dd9 100644--- a/games/unblockjam/build.gradle.kts+++ b/games/unblockjam/build.gradle.kts@@ -1,7 +1,5 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.games.unblockjam"-        versionCode = 2-        versionName = "1.1"     } }\ No newline at end of file
games/wordmaker/build.gradle.kts
diff --git a/games/wordmaker/build.gradle.kts b/games/wordmaker/build.gradle.ktsindex 0cbc3d1f28..2952198fd9 100644--- a/games/wordmaker/build.gradle.kts+++ b/games/wordmaker/build.gradle.kts@@ -1,8 +1,6 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.games.wordmaker"-        versionCode = 5-        versionName = "1.4"     } } 
health/build.gradle.kts
diff --git a/health/build.gradle.kts b/health/build.gradle.ktsindex aa23121dee..720340587e 100644--- a/health/build.gradle.kts+++ b/health/build.gradle.kts@@ -6,8 +6,6 @@ plugins { android {     defaultConfig {         applicationId = "com.vayunmathur.health"-        versionCode = 22-        versionName = "v2.0.0"     } } 
maps/build.gradle.kts
diff --git a/maps/build.gradle.kts b/maps/build.gradle.ktsindex f6aec3d65b..64d08b75ce 100644--- a/maps/build.gradle.kts+++ b/maps/build.gradle.kts@@ -5,8 +5,6 @@ plugins { android {     defaultConfig {         applicationId = "com.vayunmathur.maps"-        versionCode = 1-        versionName = "1.0"     } } 
music/build.gradle.kts
diff --git a/music/build.gradle.kts b/music/build.gradle.ktsindex cf72ace9be..1cfaf377a9 100644--- a/music/build.gradle.kts+++ b/music/build.gradle.kts@@ -1,8 +1,6 @@ android {     defaultConfig {         applicationId = "com.vayunmathur.music"-        versionCode = 1-        versionName = "1.0"     } } 
notes/build.gradle.kts
diff --git a/notes/build.gradle.kts b/notes/build.gradle.ktsindex 53bc2fb4d8..4cf0bda171 100644--- a/notes/build.gradle.kts+++ b/notes/build.gradle.kts@@ -5,8 +5,6 @@ plugins { android {     defaultConfig {         applicationId = "com.vayunmathur.notes"-        versionCode = 22-        versionName = "v2.0.0"     } } 
openassistant/build.gradle.kts
diff --git a/openassistant/build.gradle.kts b/openassistant/build.gradle.ktsindex 6fb03fc6f8..58d4b8700c 100644--- a/openassistant/build.gradle.kts+++ b/openassistant/build.gradle.kts@@ -5,8 +5,6 @@ plugins { android {     defaultConfig {         applicationId = "com.vayunmathur.openassistant"-        versionCode = 23-        versionName = "v2.0.0"     } } 
passwords/build.gradle.kts
diff --git a/passwords/build.gradle.kts b/passwords/build.gradle.ktsindex 16b8c22d75..c200dbf130 100644--- a/passwords/build.gradle.kts+++ b/passwords/build.gradle.kts@@ -2,8 +2,6 @@ android {     defaultConfig {         minSdk = 35         applicationId = "com.vayunmathur.passwords"-        versionCode = 22-        versionName = "v2.0.0"     } } 
pdf/build.gradle.kts
diff --git a/pdf/build.gradle.kts b/pdf/build.gradle.ktsindex b08cf038df..e72fbe8d24 100644--- a/pdf/build.gradle.kts+++ b/pdf/build.gradle.kts@@ -2,8 +2,6 @@ android {     defaultConfig {         minSdk = 35         applicationId = "com.vayunmathur.pdf"-        versionCode = 23-        versionName = "v2.0.0"     } } 
photos/build.gradle.kts
diff --git a/photos/build.gradle.kts b/photos/build.gradle.ktsindex 54d5789169..87837857e3 100644--- a/photos/build.gradle.kts+++ b/photos/build.gradle.kts@@ -5,8 +5,6 @@ plugins { android {     defaultConfig {         applicationId = "com.vayunmathur.photos"-        versionCode = 22-        versionName = "v2.0.0"     } } 
version.txt
diff --git a/version.txt b/version.txtnew file mode 100644index 0000000000..2cea3aafb8--- /dev/null+++ b/version.txt@@ -0,0 +1,2 @@+20260221+v2.0.0\ No newline at end of file
youpipe/build.gradle.kts
diff --git a/youpipe/build.gradle.kts b/youpipe/build.gradle.ktsindex 9cf5884c21..927a3c634f 100644--- a/youpipe/build.gradle.kts+++ b/youpipe/build.gradle.kts@@ -5,8 +5,6 @@ plugins { android {     defaultConfig {         applicationId = "com.vayunmathur.youpipe"-        versionCode = 1-        versionName = "1.0"     } }