From 8efffb92d97c6ad9a00c5fb91a3e50c70442e600 Mon Sep 17 00:00:00 2001 From: Mantri Ramkishor Date: Mon, 9 Sep 2024 17:39:32 +0530 Subject: [PATCH] TP-77216 | Release Management Action changes (#882) Co-authored-by: Varnit Goyal --- .github/workflows/newBuild.yml | 114 ++++++++++++++++++++++++ src/common/BlockerScreen.tsx | 10 ++- src/components/utlis/commonFunctions.ts | 5 +- src/reducer/metadataSlice.ts | 4 +- 4 files changed, 126 insertions(+), 7 deletions(-) diff --git a/.github/workflows/newBuild.yml b/.github/workflows/newBuild.yml index 40d3183b..558b1cdf 100644 --- a/.github/workflows/newBuild.yml +++ b/.github/workflows/newBuild.yml @@ -17,6 +17,14 @@ on: options: - fieldAgents - callingAgents + releaseType: + description: Choose release type + required: true + type: choice + options: + - TEST_BUILD + - SOFT_RELEASE + - HARD_RELEASE type: description: Choose build type required: true @@ -95,9 +103,115 @@ jobs: - name: Assemble with Stacktrace - Calling PROD release if: ((github.event.inputs.environment == 'Prod' || inputs.environment == 'Prod') && (github.event.flavor.type == 'callingAgents' || inputs.flavor == 'callingAgents')) run: yarn move:prod && cd android && ./gradlew assemblefieldAgentsProdRelease + - name: Give server ack + if: ((github.event.inputs.releaseType != 'TEST_BUILD' || inputs.releaseType != 'TEST_BUILD')) + run: | + ls + ls -asl + pwd + baseUrl=${{secrets.LONGHORN_QA_BASE_URL}} + if [ "${{ github.event.inputs.environment }}" == "Prod" ] || [ "${{ inputs.environment }}" == "Prod" ]; then + echo "Prod" + baseUrl=${{secrets.LONGHORN_PROD_BASE_URL}} + fi + echo "$baseUrl" + getPreSignedURL="$baseUrl/app/upload-url?appType=${{github.event.inputs.flavor || inputs.flavor}}&buildNumber=${{github.event.inputs.version_code || inputs.version_code}}&appVersion=${{github.event.inputs.version_name || inputs.version_name}}&releaseType=${{github.event.inputs.releaseType || inputs.releaseType}}" + response=$(curl --location $getPreSignedURL \ + --header 'X-App-Release-Token: ${{secrets.LONGHORN_HEADER}}' + ) + + echo "$response" + + upload_url=$(echo "$response" | awk -F'"' '/uploadPreSignedUrl/{print $4}') + id=$(echo "$response" | awk -F'"referenceId":' '{print $2}' | awk -F',' '{print $1}' | tr -d '[:space:]' | tr -d '"}') + + + echo "$id" + + ls + + chmod +r ./android/app/build/outputs/apk/${{ github.event.inputs.flavor || inputs.flavor }}${{github.event.inputs.environment || inputs.environment}}/${{github.event.inputs.type || inputs.type}}/app-${{github.event.inputs.flavor}}${{github.event.inputs.environment}}-release.apk + + curl --location --request PUT "$upload_url" \ + --data-binary "@./android/app/build/outputs/apk/${{ github.event.inputs.flavor || inputs.flavor }}${{github.event.inputs.environment || inputs.environment}}/${{github.event.inputs.type || inputs.type}}/app-fieldAgentsQA-release.apk" + + + echo "upload compleate" + + echo "ack url" + + ack_url=("$baseUrl/app/upload-ack?referenceId=${id}&releaseType=${{github.event.inputs.releaseType || inputs.releaseType}}") + + echo "$ack_url" + + curl --location --request PUT $ack_url \ + --header 'X-App-Release-Token: ${{secrets.LONGHORN_HEADER}}' - name: Upload APK as Artifact uses: actions/upload-artifact@v3 with: name: app-${{ github.event.inputs.type || inputs.type }}-v${{ github.event.inputs.version_code || inputs.version_code }}-name-${{github.event.inputs.version_name || inputs.version_name}} path: android/app/build/outputs/apk/${{ github.event.inputs.flavor || inputs.flavor }}${{github.event.inputs.environment || inputs.environment}}/${{github.event.inputs.type || inputs.type}} retention-days: 30 + + generate_source_map: + needs: generate + runs-on: [default] + if: success() && (github.event.inputs.environment == 'Prod') && (github.event.inputs.releaseType == 'HARD_RELEASE' || inputs.releaseType == 'HARD_RELEASE') # Only create source map for Prod releases and not for test builds + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + token: ${{ secrets.MY_REPO_PAT }} + submodules: recursive + + - name: Set Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Install yarn + run: npm install --global yarn + - name: Install dependency + run: yarn + + - name: Generate Android Bundle and Source Map + run: | + npx react-native bundle \ + --dev false \ + --minify false \ + --platform android \ + --entry-file index.js \ + --reset-cache \ + --bundle-output index.android.bundle \ + --sourcemap-output index.android.bundle.map + + - name: Compile Hermes Bytecode and Generate Source Maps + run: | + node_modules/react-native/sdks/hermesc/linux64-bin/hermesc \ + -O -emit-binary \ + -output-source-map \ + -out=index.android.bundle.hbc \ + index.android.bundle + + # Remove the original bundle to prevent duplication + rm -f index.android.bundle + + # Rename the Hermes bundle and source map + mv index.android.bundle.hbc index.android.bundle + mv index.android.bundle.map index.android.bundle.packager.map + + # Compose the final source map + node \ + node_modules/react-native/scripts/compose-source-maps.js \ + index.android.bundle.packager.map \ + index.android.bundle.hbc.map \ + -o index.android.bundle.map + + # Clean up the temporary files + rm -f index.android.bundle.packager.map + + - name: Upload Source Map + uses: actions/upload-artifact@v3 + with: + name: source-map + path: index.android.bundle.map + diff --git a/src/common/BlockerScreen.tsx b/src/common/BlockerScreen.tsx index 5749be53..7ebe3ac4 100644 --- a/src/common/BlockerScreen.tsx +++ b/src/common/BlockerScreen.tsx @@ -84,7 +84,7 @@ const BlockerScreen = (props: IBlockerScreen) => { if (!buildToCompare) return; let flavorToUpdate: IAppState; if (GLOBAL.BUILD_FLAVOUR.includes('fieldAgents')) { - flavorToUpdate = appState?.fieldAgent; + flavorToUpdate = appState?.fieldAgents; } else { flavorToUpdate = appState?.telecallingAgents; } @@ -92,7 +92,11 @@ const BlockerScreen = (props: IBlockerScreen) => { if (!flavorToUpdate) return; const currentBuildNumber = getBuildVersion(); - if (currentBuildNumber && currentBuildNumber < flavorToUpdate.buildNumber) { + if ( + currentBuildNumber && + !isNaN(currentBuildNumber) && + currentBuildNumber < flavorToUpdate.version + ) { setShouldUpdate(true); } else { setShouldUpdate(false); @@ -131,7 +135,7 @@ const BlockerScreen = (props: IBlockerScreen) => { const handleAppUpdate = () => { let appUpdateUrl; if (GLOBAL.BUILD_FLAVOUR.includes(BUILD_FOR_FIELD)) { - appUpdateUrl = appState?.fieldAgent.currentProdAPK; + appUpdateUrl = appState?.fieldAgents.currentProdAPK; } else { appUpdateUrl = appState?.telecallingAgents.currentProdAPK; } diff --git a/src/components/utlis/commonFunctions.ts b/src/components/utlis/commonFunctions.ts index 3361fc0b..db979800 100644 --- a/src/components/utlis/commonFunctions.ts +++ b/src/components/utlis/commonFunctions.ts @@ -281,8 +281,9 @@ export function getAppVersion(): string { return packageJson.version; } -export const getBuildVersion = (): string => { - return packageJson?.buildNumber || VersionNumber.buildVersion; +export const getBuildVersion = (): number => { + const buildNumber = packageJson?.buildNumber || VersionNumber.buildVersion; + return Number(buildNumber); }; export const getDocumentList = (caseDetails: CaseDetail) => { diff --git a/src/reducer/metadataSlice.ts b/src/reducer/metadataSlice.ts index 279ec026..47c64422 100644 --- a/src/reducer/metadataSlice.ts +++ b/src/reducer/metadataSlice.ts @@ -9,7 +9,7 @@ export interface UninstallInformation { } export interface IAppState { - buildNumber: string; + version: number; currentProdAPK?: string; } @@ -18,7 +18,7 @@ interface IMetadata { forceUninstall: Record; isWifiOrCellularOn: boolean; appState: { - fieldAgent: IAppState, + fieldAgents: IAppState, telecallingAgents: IAppState }; lastFirebaseResyncTimestamp: string;