Skip to content

Commit

Permalink
Merge pull request #141 from opensrp/setup-release-ci
Browse files Browse the repository at this point in the history
add release.yml file
  • Loading branch information
hilpitome authored Aug 26, 2022
2 parents 6583e75 + 0881dba commit 70b819c
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: APK Release

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+
- v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-[0-9a-zA-Z]+
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Cancel previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Decode Keystore file
run: echo $ENCODED_KEYSTORE | base64 -di > "${HOME}"/ba.keystore.jks
env:
ENCODED_KEYSTORE: ${{ secrets.KEYSTORE_FILE }}

- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Decode & Generate keystore.properties file
run: echo $KEYSTORE_PROPERTIES | base64 -di > keystore.properties
env:
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}

- name: Decode google-services.json
env:
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
run: echo $FIREBASE_CONFIG > opensrp-chw-hf/google-services.json

- name: Generate AAB (Android App Bundle) file
run: ./gradlew :opensrp-chw-hf:bundleRelease -x :opensrp-chw-hf:testDebugUnitTest --stacktrace

- name: Upload AAB file to tag assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: opensrp-chw-hf/build/outputs/bundle/release/opensrp-chw-hf-release.aab
asset_name: "opensrp-chw-hf-$tag.aab"
tag: ${{ github.ref }}
overwrite: true

- name: Generate APK (Android App PacKage) file
run: ./gradlew :opensrp-chw-hf:assembleRelease -x :opensrp-chw-hf:testDebugUnitTest --stacktrace

- name: Upload APK file to tag assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: opensrp-chw-hf/build/outputs/apk/release/opensrp-chw-hf-release.apk
asset_name: "opensrp-chw-hf-$tag.apk"
tag: ${{ github.ref }}
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') }}
overwrite: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ project.properties
.settings
build/
jacoco.exec
keystore.properties
17 changes: 17 additions & 0 deletions opensrp-chw-hf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'io.fabric'
apply from: '../properties.gradle'

buildscript {
repositories {
Expand All @@ -24,6 +25,21 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
release {

v1SigningEnabled true
v2SigningEnabled true

//Store your keystore.properties file in the project root folder
keyAlias System.getenv("KEYSTORE_ALIAS")?: project.KEYSTORE_ALIAS
keyPassword System.getenv("KEY_PASSWORD") ?: project.KEY_PASSWORD
storePassword System.getenv("KEYSTORE_PASSWORD") ?: project.KEYSTORE_PASSWORD

//Save your keystore file as ~/ba.keystore.jks (in your home directory)
storeFile file(System.getProperty("user.home") + "/ba.keystore.jks")
}
}

defaultConfig {
applicationId "org.smartregister.chw.hf"
Expand Down Expand Up @@ -59,6 +75,7 @@ android {
// debuggable true //Useful when debugging release builds
minifyEnabled false
zipAlignEnabled true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
Expand Down
14 changes: 14 additions & 0 deletions properties.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ext.props = new Properties()

//KEYSTORE CREDENTIALS
def keystoreAuthArray = ["KEYSTORE_ALIAS", "KEY_PASSWORD", "KEYSTORE_PASSWORD"]
if (rootProject.file("keystore.properties").exists()) {
props.load(rootProject.file("keystore.properties").newDataInputStream())

keystoreAuthArray.each { arrayProp -> project.ext.set(arrayProp, props.getProperty(arrayProp, "sample"))
}
} else {
println("keystore.properties does not exist. The following values are required " + keystoreAuthArray.join(", "))
keystoreAuthArray.each { arrayProp -> project.ext.set(arrayProp, props.getProperty(arrayProp, "sample_" + arrayProp))
}
}

0 comments on commit 70b819c

Please sign in to comment.