Skip to content

Commit

Permalink
Adds support for a full CI/CD pipeline using GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrowlands committed Oct 26, 2023
1 parent 748282e commit a521ca4
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 182 deletions.
234 changes: 118 additions & 116 deletions .github/workflows/android-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,119 +93,121 @@ jobs:
sed -i "s/versionCode [0-9]\+/versionCode ${{ env.VERSION_CODE }}/g" networksurvey/build.gradle
sed -i "s/versionName \"[^\"]*\"/versionName \"${{ env.VERSION_NAME }}\"/g" networksurvey/build.gradle
# - name: Commit and push changes
# run: |
# git config user.email "[email protected]"
# git config user.name "Github Actions"
# git commit -am "Bump version code and change version name to ${{ env.VERSION_NAME }}"
# git push origin HEAD

# buildRelease:
# needs: bumpVersion
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout the code
# uses: actions/checkout@v4
#
# - name: Cache dependencies
# uses: actions/cache@v2
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
#
# - name: Set up JDK 11
# uses: actions/setup-java@v2
# with:
# java-version: 11
# distribution: 'adopt'
#
# - name: Save Keystore
# env:
# KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
# run: echo $KEYSTORE_FILE | base64 -d > my.keystore
#
# - name: Build Regular Release APK
# env:
# KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
# KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
# KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
# run: ./gradlew assembleRegularRelease
# -Pandroid.injected.signing.store.file=$(pwd)/my.keystore
# -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
# -Pandroid.injected.signing.key.alias=$KEY_ALIAS
# -Pandroid.injected.signing.key.password=$KEY_PASSWORD
#
# - name: Get APK name
# run: echo "base_name=`./gradlew :networksurvey:properties -q | grep 'archivesBaseName:' | awk '{print $2}'`" >> $GITHUB_ENV
#
# - name: Upload Regular APK
# uses: actions/upload-artifact@v3
# with:
# name: Network Survey Regular Release APK
# path: networksurvey/build/outputs/apk/regular/release/${{ env.base_name }}-regular-release.apk
#
# - name: Build CDR Release APK
# env:
# KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
# KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
# KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
# run: ./gradlew assembleCdrRelease
# -Pandroid.injected.signing.store.file=$(pwd)/my.keystore
# -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
# -Pandroid.injected.signing.key.alias=$KEY_ALIAS
# -Pandroid.injected.signing.key.password=$KEY_PASSWORD
#
# - name: Upload CDR APK
# uses: actions/upload-artifact@v3
# with:
# name: Network Survey CDR Release APK
# path: networksurvey/build/outputs/apk/cdr/release/${{ env.base_name }}-cdr-no-tracking-release.apk
#
# - name: Build Regular Release Bundle
# env:
# KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
# KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
# KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
# run: ./gradlew bundleRelease
# -Pandroid.injected.signing.store.file=$(pwd)/my.keystore
# -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
# -Pandroid.injected.signing.key.alias=$KEY_ALIAS
# -Pandroid.injected.signing.key.password=$KEY_PASSWORD
#
# - name: Upload Regular Bundle
# uses: actions/upload-artifact@v3
# with:
# name: regular-appbundle
# path: networksurvey/build/outputs/bundle/regularRelease/${{ env.base_name }}-regular-release.aab
#
# - name: Create a Release in GitHub
# uses: ncipollo/release-action@v1
# with:
# artifacts: "networksurvey/build/outputs/apk/cdr/release/*.apk,networksurvey/build/outputs/apk/regular/release/*.apk,networksurvey/build/outputs/bundle/regularRelease/*.aab"
# token: ${{ secrets.GH_TOKEN }}
# tag: ${{ steps.version.outputs.content }}
# commit: ${{ github.sha }}
#
#
# release:
# name: Release app to internal track
# needs: [ buildRelease ]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - name: Get appbundle from artifacts
# uses: actions/download-artifact@v2
# with:
# name: regular-appbundle
#
# - name: Release app to internal track
# uses: r0adkll/upload-google-play@v1
# with:
# serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }}
# packageName: com.craxiom.networksurvey
# releaseFiles: ${{ env.base_name }}-regular-release.aab
# track: internal
# status: draft
- name: Commit and push changes
run: |
git config user.email "[email protected]"
git config user.name "Github Actions"
git commit -am "Bump version code and change version name to ${{ env.VERSION_NAME }}"
git push origin HEAD
buildRelease:
needs: bumpVersion
runs-on: ubuntu-latest

steps:
- name: Checkout the code
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'adopt'

- name: Save Keystore
env:
KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
run: echo $KEYSTORE_FILE | base64 -d > my.keystore

- name: Build Regular Release APK
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew assembleRegularRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD

- name: Get APK name
run: echo "base_name=`./gradlew :networksurvey:properties -q | grep 'archivesBaseName:' | awk '{print $2}'`" >> $GITHUB_ENV

- name: Upload Regular APK
uses: actions/upload-artifact@v3
with:
name: Network Survey Regular Release APK
path: networksurvey/build/outputs/apk/regular/release/${{ env.base_name }}-regular-release.apk

- name: Build CDR Release APK
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew assembleCdrRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD

- name: Upload CDR APK
uses: actions/upload-artifact@v3
with:
name: Network Survey CDR Release APK
path: networksurvey/build/outputs/apk/cdr/release/${{ env.base_name }}-cdr-no-tracking-release.apk

- name: Build Regular Release Bundle
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew bundleRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD

- name: Upload Regular Bundle
uses: actions/upload-artifact@v3
with:
name: regular-appbundle
path: networksurvey/build/outputs/bundle/regularRelease/${{ env.base_name }}-regular-release.aab

- name: Create a Release in GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "networksurvey/build/outputs/apk/cdr/release/*.apk,networksurvey/build/outputs/apk/regular/release/*.apk,networksurvey/build/outputs/bundle/regularRelease/*.aab"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
body: "The regular-release apk is the same as what can be found on the Google Play Store. The cdr-no-tracking-release apk is the same as the regular-release apk, but with the full CDR support (See README.md for more details) and it also does not contain any tracking libraries such as Google Analytics."
generateReleaseNotes: true


release:
name: Release app to internal track
needs: [ buildRelease ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get appbundle from artifacts
uses: actions/download-artifact@v2
with:
name: regular-appbundle

- name: Release app to internal track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }}
packageName: com.craxiom.networksurvey
releaseFiles: ${{ env.base_name }}-regular-release.aab
track: internal
status: draft
2 changes: 1 addition & 1 deletion .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Network Survey CDR Debug APK
path: networksurvey/build/outputs/apk/cdr/debug/${{ env.base_name }}-cdr-debug.apk
path: networksurvey/build/outputs/apk/cdr/debug/${{ env.base_name }}-cdr-no-tracking-debug.apk


test:
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//classpath 'com.google.gms:google-services:4.3.15'
//classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.6'
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.6'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3"
}
}
Expand Down
55 changes: 0 additions & 55 deletions cloudbuild.yaml

This file was deleted.

16 changes: 9 additions & 7 deletions networksurvey/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: "androidx.navigation.safeargs"
//apply plugin: "com.google.gms.google-services"
//apply plugin: "com.google.firebase.crashlytics"
apply plugin: "com.google.gms.google-services"
apply plugin: "com.google.firebase.crashlytics"
apply plugin: 'kotlin-android'


Expand Down Expand Up @@ -56,12 +56,14 @@ android {

flavorDimensions "version"
productFlavors {
// Regular is for Google Play that contains Firebase tracking features such as crashlytics
regular {
versionNameSuffix ""
}

// Has the extra CDR features and does not contain any tracking
cdr {
versionNameSuffix "-cdr"
versionNameSuffix "-cdr-no-tracking"
}
}
}
Expand Down Expand Up @@ -107,10 +109,10 @@ dependencies {
implementation 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'

// Import the Firebase BoM
//implementation platform('com.google.firebase:firebase-bom:31.2.3')
//implementation 'com.google.firebase:firebase-analytics'
//implementation 'com.google.firebase:firebase-crashlytics'
// Only include firebase in the google play build
regularImplementation platform('com.google.firebase:firebase-bom:31.2.3')
regularImplementation 'com.google.firebase:firebase-analytics'
regularImplementation 'com.google.firebase:firebase-crashlytics'

testImplementation 'junit:junit:4.13.2'
implementation 'androidx.annotation:annotation:1.6.0'
Expand Down

0 comments on commit a521ca4

Please sign in to comment.