From e2840e8fb5394372c2cb5e69aa0572ba26af1b2e Mon Sep 17 00:00:00 2001 From: hilpitome Date: Thu, 25 Aug 2022 16:14:41 +0300 Subject: [PATCH 1/3] add release.yml file --- .github/workflows/release.yml | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..7caf7604c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +# 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: Snapshot Release + +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+-SNAPSHOT + - v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-SNAPSHOT + - v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-[0-9a-zA-Z]+-SNAPSHOT +env: + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Cancel previous workflow runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + - 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: Run unit tests with Gradle + run: ./gradlew :opensrp-client-chw-hf:clean :opensrp-client-chw-hf:testDebugUnitTest --stacktrace + + - name: Generate & upload library snapshot artifact AAR (Android Archive) file + run: ./gradlew :opensrp-client-chw-hf:uploadArchives -PmavenLocal=false --stacktrace -PsonatypeUsername=${{ secrets.NEXUS_USERNAME }} -PsonatypePassword=${{ secrets.NEXUS_PASSWORD }} + + - name: Github Release + uses: softprops/action-gh-release@v1 + with: + prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') }} From 3074844ce5f96194e6c8a8c30858e9e1bd8f58f4 Mon Sep 17 00:00:00 2001 From: hilpitome Date: Thu, 25 Aug 2022 17:05:32 +0300 Subject: [PATCH 2/3] update release.yml and create properties.gradle file --- .github/workflows/release.yml | 57 +++++++++++++++++++++++++++-------- .gitignore | 1 + opensrp-chw-hf/build.gradle | 16 ++++++++++ properties.gradle | 14 +++++++++ 4 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 properties.gradle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7caf7604c..0586b3d84 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,16 @@ # 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: Snapshot Release +name: APK Release on: push: tags: - - v[0-9]+.[0-9]+.[0-9]+-SNAPSHOT - - v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-SNAPSHOT - - v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-[0-9a-zA-Z]+-SNAPSHOT + - 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: - NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} jobs: release: @@ -22,6 +21,11 @@ jobs: with: access_token: ${{ github.token }} + - name: Decode Keystore file + run: echo $ENCODED_KEYSTORE | base64 -di > "${HOME}"/zeir.keystore.jks + env: + ENCODED_KEYSTORE: ${{ secrets.KEYSTORE_FILE }} + - name: Checkout 🛎️ uses: actions/checkout@v2 with: @@ -35,13 +39,42 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Run unit tests with Gradle - run: ./gradlew :opensrp-client-chw-hf:clean :opensrp-client-chw-hf:testDebugUnitTest --stacktrace + - name: Decode & Generate local.properties file + run: echo $LOCAL_PROPERTIES | base64 -di > local.properties + env: + LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }} + + - 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 & upload library snapshot artifact AAR (Android Archive) file - run: ./gradlew :opensrp-client-chw-hf:uploadArchives -PmavenLocal=false --stacktrace -PsonatypeUsername=${{ secrets.NEXUS_USERNAME }} -PsonatypePassword=${{ secrets.NEXUS_PASSWORD }} + - name: Generate APK (Android App PacKage) file + run: ./gradlew :opensrp-chw-hf:assembleRelease -x :opensrp-chw-hf:testDebugUnitTest --stacktrace - - name: Github Release - uses: softprops/action-gh-release@v1 + - 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 diff --git a/.gitignore b/.gitignore index 549d5ba5b..d6b0dafce 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ project.properties .settings build/ jacoco.exec +keystore.properties \ No newline at end of file diff --git a/opensrp-chw-hf/build.gradle b/opensrp-chw-hf/build.gradle index f5064b0b8..a9875e0cd 100644 --- a/opensrp-chw-hf/build.gradle +++ b/opensrp-chw-hf/build.gradle @@ -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 { @@ -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" diff --git a/properties.gradle b/properties.gradle new file mode 100644 index 000000000..988abffc8 --- /dev/null +++ b/properties.gradle @@ -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)) + } +} \ No newline at end of file From 317c871e882eb2901638125e2d980ad07fc01aa1 Mon Sep 17 00:00:00 2001 From: hilpitome Date: Fri, 26 Aug 2022 13:00:36 +0300 Subject: [PATCH 3/3] remove unnecessary release task --- .github/workflows/release.yml | 7 +------ opensrp-chw-hf/build.gradle | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0586b3d84..7d510ac28 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: access_token: ${{ github.token }} - name: Decode Keystore file - run: echo $ENCODED_KEYSTORE | base64 -di > "${HOME}"/zeir.keystore.jks + run: echo $ENCODED_KEYSTORE | base64 -di > "${HOME}"/ba.keystore.jks env: ENCODED_KEYSTORE: ${{ secrets.KEYSTORE_FILE }} @@ -39,11 +39,6 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Decode & Generate local.properties file - run: echo $LOCAL_PROPERTIES | base64 -di > local.properties - env: - LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }} - - name: Decode & Generate keystore.properties file run: echo $KEYSTORE_PROPERTIES | base64 -di > keystore.properties env: diff --git a/opensrp-chw-hf/build.gradle b/opensrp-chw-hf/build.gradle index a9875e0cd..3ec5f370a 100644 --- a/opensrp-chw-hf/build.gradle +++ b/opensrp-chw-hf/build.gradle @@ -75,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'