From 198f78f28ea1e232fa16c896be50b130c7172670 Mon Sep 17 00:00:00 2001 From: manu Date: Wed, 22 May 2024 11:06:35 +0200 Subject: [PATCH] ci: [ANDROAPP-6167] deploy release job --- .github/workflows/deploy-release.yml | 104 ++++++++++++++---- .../utils/granularsync/GranularSyncModule.kt | 10 ++ 2 files changed, 92 insertions(+), 22 deletions(-) diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 12ae94f7ee..8ff9e8a61d 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -1,32 +1,92 @@ -# This is a basic workflow that is manually triggered - name: Deploy Release -# Controls when the action will run. Workflow runs when manually triggered using the UI -# or API. +env: + main_project_module: app + on: workflow_dispatch: - # Inputs the workflow accepts. inputs: - name: - # Friendly description to be shown in the UI instead of 'name' - description: 'Person to greet' - # Default value if no value is explicitly provided - default: 'World' - # Input has to be provided for the workflow to run + github_release: + description: 'enable github release' + required: true + type: boolean + google_play_release: + description: 'enable google play release' + required: true + type: boolean + release_tag_name: + description: 'tag' required: true - # The data type of the input type: string - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel + is_patch: + description: 'Is the new version a patch' + required: true + type: boolean + default: false + jobs: - # This workflow contains a single job called "greet" - greet: - # The type of runner that the job will run on + Build-Apk: runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Runs a single command using the runners shell - - name: Send greeting - run: echo "Hello ${{ inputs.name }}" + - uses: actions/checkout@v3 + - name: Set repository name as env variable + run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + - name: Read version name from file + working-directory: ./gradle + id: read-version + run: echo "::set-output name=vName::$(grep 'vName' libs.versions.toml | awk -F' = ' '{print $2}' | tr -d '"')" + - name: Set Up JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' # See 'Supported distributions' for available options + java-version: '17' + cache: 'gradle' + - name: Change wrapper permissions + run: chmod +x ./gradlew + - name: Decode Keystore + id: decode_keystore + uses: timheuer/base64-to-file@v1 + with: + fileName: 'dhis_keystore.jks' + encodedString: ${{ secrets.KEYSTORE }} + - name: Build release apk + run: ./gradlew app:assembleRelease app:assembleDhisDebug + env: + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + SIGNING_KEY_ALIAS: ${{ secrets.KEY_ALIAS }} + SIGNING_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} + SIGNING_STORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} + SIGNING_KEYSTORE_PATH: ${{ steps.decode_keystore.outputs.filePath }} + + - name: Upload to Play Store + if: ${{ inputs.google_play_release }} + uses: r0adkll/upload-google-play@v1 + with: + serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} + packageName: com.dhis2 + releaseFile: ${{ env.main_project_module }}/build/outputs/apk/dhisPlayServices/release/dhis2-v${{ steps.read-version.outputs.vName }}-dhis-release.apk + track: alpha + whatsNewDirectory: /whatsnew + + + - name: Github Patch Release + if: ${{ (inputs.github_release == true) && (inputs.is_patch == true) }} + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + draft: true + generateReleaseNotes: true + name: "Android Capture App for DHIS 2 (v${{ inputs.release_tag_name }}) - Patch version" + tag: ${{ inputs.release_tag_name }} + artifacts: ${{ env.main_project_module }}/build/outputs/apk/dhis/release/dhis2-v${{ steps.read-version.outputs.vName }}-dhis-release.apk,${{ env.main_project_module }}/build/outputs/apk/dhisPlayServices/release/dhis2-v${{ steps.read-version.outputs.vName }}-dhisPlayServices-release.apk,${{ env.main_project_module }}/build/outputs/apk/dhis/debug/dhis2-v${{ steps.read-version.outputs.vName }}-dhis-debug.apk + + - name: Github New Release + if: ${{ (inputs.github_release == true) && (inputs.is_patch == false) }} + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + draft: true + generateReleaseNotes: true + name: "Android Capture App for DHIS 2 (v${{ inputs.release_tag_name }})" + tag: ${{ inputs.release_tag_name }} + artifacts: ${{ env.main_project_module }}/build/outputs/apk/dhis/release/dhis2-v${{ steps.read-version.outputs.vName }}-dhis-release.apk,${{ env.main_project_module }}/build/outputs/apk/dhisPlayServices/release/dhis2-v${{ steps.read-version.outputs.vName }}-dhisPlayServices-release.apk,${{ env.main_project_module }}/build/outputs/apk/dhis/debug/dhis2-v${{ steps.read-version.outputs.vName }}-dhis-debug.apk diff --git a/app/src/dhisPlayServices/java/org/dhis2/utils/granularsync/GranularSyncModule.kt b/app/src/dhisPlayServices/java/org/dhis2/utils/granularsync/GranularSyncModule.kt index 44ec6a4b02..d40e2a78ec 100644 --- a/app/src/dhisPlayServices/java/org/dhis2/utils/granularsync/GranularSyncModule.kt +++ b/app/src/dhisPlayServices/java/org/dhis2/utils/granularsync/GranularSyncModule.kt @@ -73,6 +73,15 @@ class GranularSyncModule( ) } + @Provides + fun provideDispatchers() = object : DispatcherProvider { + override fun io() = Dispatchers.IO + + override fun computation() = Dispatchers.Default + + override fun ui() = Dispatchers.Main + } + @Provides fun granularSyncRepository( d2: D2, @@ -87,6 +96,7 @@ class GranularSyncModule( dhisProgramUtils, periodUtils, resourceManager, + provideDispatchers(), ) @Provides