Skip to content

Commit

Permalink
F-Droid build changes
Browse files Browse the repository at this point in the history
* Remove FDROID_BUILD environment variable
* Split Android CI process for primary and F-Droid
* Change F-Droid CI process to remove parts of build.gradle scripts that are not needed for the build
  • Loading branch information
michaelkourlas committed Feb 3, 2024
1 parent 2c7de62 commit b9c11fb
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 44 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/android-fdroid.yml
@@ -0,0 +1,26 @@
name: Android CI (F-Droid)

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Prepare source for F-Droid build
run: sed -i "/fdroid-remove-start/,/fdroid-remove-end/d" build.gradle voipms-sms/build.gradle
- name: Build with Gradle (F-Droid)
run: ./gradlew assembleFdroidFullRelease
@@ -1,4 +1,4 @@
name: Android CI
name: Android CI (primary)

on:
push:
Expand All @@ -11,24 +11,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'
- name: set up Python 3.10
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Create google-services.json
env:
google_services_json: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: echo $google_services_json | base64 -d > voipms-sms/src/primary/google-services.json
- name: Build with Gradle (primary)
run: ./gradlew build
env:
FDROID_BUILD: '0'
- name: Build with Gradle (F-Droid)
run: ./gradlew build
env:
FDROID_BUILD: '1'
- name: Build with Gradle
run: ./gradlew assemblePrimaryFullRelease
8 changes: 4 additions & 4 deletions build.gradle
Expand Up @@ -9,10 +9,10 @@ buildscript {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20'
classpath 'com.github.michaelkourlas:oss-licenses-plugin:0.0.2'

if (System.getenv("FDROID_BUILD") != "1") {
classpath 'com.google.gms:google-services:4.4.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
}
// fdroid-remove-start
classpath 'com.google.gms:google-services:4.4.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
// fdroid-remove-end
}
}

Expand Down
58 changes: 29 additions & 29 deletions voipms-sms/build.gradle
Expand Up @@ -22,17 +22,16 @@ android {
}
flavorDimensions = ["version", "demo"]
productFlavors {
if (System.getenv("FDROID_BUILD") != "1") {
primary {
dimension "version"
buildConfigField "boolean", "IS_FDROID", "false"
}
} else {
fdroid {
dimension "version"
versionNameSuffix "-fdroid"
buildConfigField "boolean", "IS_FDROID", "true"
}
// fdroid-remove-start
primary {
dimension "version"
buildConfigField "boolean", "IS_FDROID", "false"
}
// fdroid-remove-end
fdroid {
dimension "version"
versionNameSuffix "-fdroid"
buildConfigField "boolean", "IS_FDROID", "true"
}
full {
dimension "demo"
Expand Down Expand Up @@ -79,11 +78,10 @@ android {
}
sourceSets {
main.java.srcDirs += "src/main/kotlin"
if (System.getenv("FDROID_BUILD") != "1") {
primary.java.srcDirs += "src/primary/kotlin"
} else {
fdroid.java.srcDirs += "src/fdroid/kotlin"
}
// fdroid-remove-start
primary.java.srcDirs += "src/primary/kotlin"
// fdroid-remove-end
fdroid.java.srcDirs += "src/fdroid/kotlin"
}
lint {
abortOnError false
Expand Down Expand Up @@ -115,16 +113,18 @@ dependencies {
implementation "com.google.android.material:material:1.11.0"
ksp "androidx.room:room-compiler:$room_version"

if (System.getenv("FDROID_BUILD") != "1") {
// Firebase libraries
primaryImplementation platform("com.google.firebase:firebase-bom:32.7.1")
primaryImplementation "com.google.firebase:firebase-analytics-ktx"
primaryImplementation "com.google.firebase:firebase-crashlytics-ktx"
primaryImplementation "com.google.firebase:firebase-messaging-ktx"
// fdroid-remove-start

// Google Play libraries
primaryImplementation "com.android.billingclient:billing-ktx:6.1.0"
}
// Firebase libraries
primaryImplementation platform("com.google.firebase:firebase-bom:32.7.1")
primaryImplementation "com.google.firebase:firebase-analytics-ktx"
primaryImplementation "com.google.firebase:firebase-crashlytics-ktx"
primaryImplementation "com.google.firebase:firebase-messaging-ktx"

// Google Play libraries
primaryImplementation "com.android.billingclient:billing-ktx:6.1.0"

// fdroid-remove-end

// Other third-party libraries
implementation "com.squareup.moshi:moshi-adapters:$moshi_version"
Expand Down Expand Up @@ -168,7 +168,7 @@ android.applicationVariants.configureEach { variant ->
generatePackageLicenses.dependsOn cleanAssets
}

if (System.getenv("FDROID_BUILD") != "1") {
apply plugin: "com.google.gms.google-services"
apply plugin: "com.google.firebase.crashlytics"
}
// fdroid-remove-start
apply plugin: "com.google.gms.google-services"
apply plugin: "com.google.firebase.crashlytics"
// fdroid-remove-end

0 comments on commit b9c11fb

Please sign in to comment.