Skip to content

Commit

Permalink
Add staging build type
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Nov 18, 2023
1 parent 7d05559 commit 637cb7d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ android {
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
// Staging build (a release build with a ID)
create("staging") {
initWith(getByName("release"))
applicationIdSuffix = ".staging"
versionNameSuffix = "-staging"
}
// Debug build (GitHub)
create("dev") {
initWith(getByName("debug"))
Expand Down
4 changes: 4 additions & 0 deletions app/src/staging/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name" translatable="false">Trail Sense (Staging)</string>
</resources>
22 changes: 22 additions & 0 deletions scripts/staging-builds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Takes 1 argument: path to signing config file

# Signing config file format:
# Path to keystore
# Keystore password
# Key alias
# Key password
# Destination folder

# Assemble the APK
sh "${BASH_SOURCE%/*}"/../gradlew assembleStaging \
-Pandroid.injected.signing.store.file=$(head -n 1 "$1") \
-Pandroid.injected.signing.store.password=$(head -n 2 "$1" | tail -n 1) \
-Pandroid.injected.signing.key.alias=$(head -n 3 "$1" | tail -n 1) \
-Pandroid.injected.signing.key.password=$(head -n 4 "$1" | tail -n 1)

# Get the version name from the gradle file
export VERSION_CODE=$(LC_ALL=C.UTF-8 grep -oP '(?<=versionCode = )\d+' "${BASH_SOURCE%/*}"/../app/build.gradle.kts)

# Copy the files to the destination folder (line 5 of the signing config file)
echo "Copying files to $(head -n 5 "$1" | tail -n 1)"
cp "${BASH_SOURCE%/*}"/../app/build/outputs/apk/staging/app-staging.apk $(head -n 5 "$1" | tail -n 1)/${VERSION_CODE}-staging.apk
1 change: 1 addition & 0 deletions staging-builds-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sh scripts/staging-builds.sh ../trail_sense_release_signing_config.txt

0 comments on commit 637cb7d

Please sign in to comment.