From cbd9d31003472526473b92817e5e2fb3d73211ee Mon Sep 17 00:00:00 2001 From: adityankannan-tw Date: Fri, 27 Oct 2023 14:02:17 +0530 Subject: [PATCH] feat(MOSIP-29236): Add reusable workflows --- .github/workflows/internal-build.yml | 137 ++++++++++++++++++ .github/workflows/push-triggers.yml | 41 ++++++ android/fastlane/Fastfile | 9 +- .../{verify-build.sh => android-build.sh} | 2 +- ios/fastlane/Fastfile | 41 +----- 5 files changed, 189 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/internal-build.yml create mode 100644 .github/workflows/push-triggers.yml rename android/scripts/{verify-build.sh => android-build.sh} (82%) diff --git a/.github/workflows/internal-build.yml b/.github/workflows/internal-build.yml new file mode 100644 index 000000000..1d0d8fbc0 --- /dev/null +++ b/.github/workflows/internal-build.yml @@ -0,0 +1,137 @@ +name: Internal Build [Android & IOS] +run-name: ${{ inputs.buildname }} + +on: + workflow_dispatch: + inputs: + beta-release: + description: 'Beta release?' + required: true + default: 'false' + type: choice + options: + - false + - true + buildname: + description: 'Build App For' + required: true + default: 'Sprint-x/Collab/release-x.x.x' + type: string + mimotoBackendServiceUrl: + description: 'Mimoto backend service URL' + required: true + default: 'https://api.sandbox.mosip.net' + type: string + esignetBackendServiceUrl: + description: 'Esignet backend service URL' + required: true + default: 'https://api.sandbox.mosip.net' + type: string + internal-testers: + description: 'Internal Testers Group' + required: true + default: 'QA-Triple' + type: choice + options: + - Dev-testing + - MEC + - QA + - MOSIP-Collab + - MOSIP-Dev-testing + theme: + description: 'Application Theme' + required: true + default: 'orange' + type: choice + options: + - orange + - purple + buildDescription: + description: 'What to test' + required: true + default: 'QA-Triple environment' + type: string + allow_env_edit: + description: 'Edit ENV' + required: true + default: 'true' + type: choice + options: + - false + - true + +jobs: + build-android: + uses: tw-mosip/kattu/.github/workflows/android-publish.yml@add-inji-workflows + with: + BETA_RELEASE: ${{ inputs.beta-release }} + NODE_VERSION: '16.x' + RELEASE_KEYSTORE_ALIAS: androidreleasekey + MIMOTO_HOST: ${{ inputs.mimotoBackendServiceUrl }} + ESIGNET_HOST: ${{ inputs.esignetBackendServiceUrl }} + APPLICATION_THEME: ${{ inputs.theme }} + BUILD_DESCRIPTION: ${{ inputs.buildDescription }} + ALLOW_ENV_EDIT: ${{ inputs.allow_env_edit }} + BUILD_NAME: ${{ inputs.buildname }} + secrets: + ANDROID_KEYSTORE_FILE: ${{ secrets.INJI_ANDROID_RELEASE_KEYSTORE }} + RELEASE_KEYSTORE_PASSWORD: '${{ secrets.INJI_ANDROID_RELEASE_STOREPASS }}' + INJI_ANDROID_PLAY_STORE_CONFIG_JSON: ${{ secrets.INJI_ANDROID_PLAY_STORE_CONFIG_JSON }} + ENV_FILE: ${{ secrets.ENV_FILE }} + SLACK_URL: '${{ secrets.SLACK_WEBHOOK }}' + + build-android-beta: + if: ${{ inputs.beta-release == 'true' }} + uses: tw-mosip/kattu/.github/workflows/android-publish.yml@add-inji-workflows + with: + BETA_RELEASE: ${{ inputs.beta-release }} + NODE_VERSION: '16.x' + RELEASE_KEYSTORE_ALIAS: androidreleasekey + MIMOTO_HOST: ${{ inputs.mimotoBackendServiceUrl }} + ESIGNET_HOST: ${{ inputs.esignetBackendServiceUrl }} + APPLICATION_THEME: ${{ inputs.theme }} + BUILD_DESCRIPTION: ${{ inputs.buildDescription }} + ALLOW_ENV_EDIT: ${{ inputs.allow_env_edit }} + BUILD_NAME: ${{ inputs.buildname }} + secrets: + ANDROID_KEYSTORE_FILE: ${{ secrets.INJI_ANDROID_RELEASE_KEYSTORE }} + RELEASE_KEYSTORE_PASSWORD: '${{ secrets.INJI_ANDROID_RELEASE_STOREPASS }}' + INJI_ANDROID_PLAY_STORE_CONFIG_JSON: ${{ secrets.INJI_ANDROID_PLAY_STORE_CONFIG_JSON }} + ENV_FILE: ${{ secrets.ENV_FILE }} + SLACK_URL: '${{ secrets.SLACK_WEBHOOK }}' + + build-ios: + uses: tw-mosip/kattu/.github/workflows/ios-publish.yml@add-inji-workflows + with: + NODE_VERSION: '18.x' + MIMOTO_HOST: ${{ inputs.mimotoBackendServiceUrl }} + ESIGNET_HOST: ${{ inputs.esignetBackendServiceUrl }} + APPLICATION_THEME: ${{ inputs.theme }} + TESTFLIGHT_BETA_APP_DESCRIPTION: ${{ inputs.buildDescription }} + ALLOW_ENV_EDIT: ${{ inputs.allow_env_edit }} + TESTFLIGHT_INTERNAL_TESTERS_GROUP: ${{ inputs.internal-testers }} + secrets: + APP_STORE_CONNECT_TEAM_ID: '${{ secrets.APP_STORE_CONNECT_TEAM_ID }}' + DEVELOPER_APP_ID: '${{ secrets.IOS_INJI_DEVELOPER_APP_ID }}' + INJI_IOS_DEVELOPER_APP_IDENTIFIER: '${{ secrets.INJI_IOS_DEVELOPER_APP_IDENTIFIER }}' + INJI_IOS_DEVELOPER_PORTAL_TEAM_ID: '${{ secrets.INJI_IOS_DEVELOPER_PORTAL_TEAM_ID }}' + INJI_IOS_FASTLANE_APPLE_ID: '${{ secrets.INJI_IOS_FASTLANE_APPLE_ID }}' + INJI_IOS_FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: '${{ secrets.INJI_IOS_FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}' + GIT_AUTHORIZATION: '${{ secrets.GIT_AUTHORIZATION }}' + INJI_IOS_PROVISIONING_PROFILE_SPECIFIER: '${{ secrets.INJI_IOS_PROVISIONING_PROFILE_SPECIFIER }}' + INJI_IOS_TEMP_KEYCHAIN_PASSWORD: '${{ secrets.INJI_IOS_TEMP_KEYCHAIN_PASSWORD }}' + INJI_IOS_TEMP_KEYCHAIN_USER: '${{ secrets.INJI_IOS_TEMP_KEYCHAIN_USER }}' + APPLE_KEY_ID: '${{ secrets.APPLE_KEY_ID }}' + APPLE_ISSUER_ID: '${{ secrets.APPLE_ISSUER_ID }}' + APPLE_KEY_CONTENT: '${{ secrets.APPLE_KEY_CONTENT }}' + MATCH_PASSWORD: '${{ secrets.INJI_IOS_MATCH_PASSWORD }}' + SLACK_URL: '${{ secrets.SLACK_WEBHOOK }}' + + sonar-check: + uses: tw-mosip/kattu/.github/workflows/sonar.yml@add-inji-workflows + secrets: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io + SONAR_ORGANIZATION: ${{ secrets.ORG_KEY }} + SLACK_URL: '${{ secrets.SLACK_WEBHOOK }}' + \ No newline at end of file diff --git a/.github/workflows/push-triggers.yml b/.github/workflows/push-triggers.yml new file mode 100644 index 000000000..94d94d93f --- /dev/null +++ b/.github/workflows/push-triggers.yml @@ -0,0 +1,41 @@ +name: Push-Triggers + +on: + push: + branches: + - main + - develop + - qa-develop + - 'release-**' + release: + types: [published] + pull_request: + types: [opened, reopened, synchronize] + branches: + - main + - develop + - qa-develop + - 'release-**' + +jobs: + build-android: + uses: tw-mosip/kattu/.github/workflows/android-build.yml@add-inji-workflows + with: + NODE_VERSION: "16.x" + DEBUG_KEYSTORE_ALIAS: androiddebugkey + secrets: + DEBUG_KEYSTORE_PASSWORD: '${{ secrets.INJI_ANDROID_DEBUG_STOREPASS }}' + + build-ios: + uses: tw-mosip/kattu/.github/workflows/ios-build.yml@add-inji-workflows + with: + NODE_VERSION: "16.x" + + sonar-check: + if: ${{ github.event_name == 'push' }} + uses: tw-mosip/kattu/.github/workflows/sonar.yml@add-inji-workflows + secrets: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io + SONAR_ORGANIZATION: ${{ secrets.ORG_KEY }} + SLACK_URL: '${{ secrets.SLACK_WEBHOOK }}' diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index 44489aba6..bc2266a1d 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -4,20 +4,21 @@ MIMOTO_HOST = ENV["MIMOTO_HOST"] ESIGNET_HOST = ENV["ESIGNET_HOST"] APPLICATION_THEME = ENV["APPLICATION_THEME"] RELEASE_KEYSTORE_ALIAS = ENV["RELEASE_KEYSTORE_ALIAS"] +DEBUG_KEYSTORE_ALIAS = ENV["DEBUG_KEYSTORE_ALIAS"] RELEASE_KEYSTORE_PASSWORD = ENV["RELEASE_KEYSTORE_PASSWORD"] +DEBUG_KEYSTORE_PASSWORD = ENV["DEBUG_KEYSTORE_PASSWORD"] PLAY_CONSOLE_RELEASE_DESCRIPTION = ENV["PLAY_CONSOLE_RELEASE_DESCRIPTION"] SLACK_URL = ENV["SLACK_URL"] CREDENTIAL_REGISTRY_EDIT = ENV["CREDENTIAL_REGISTRY_EDIT"] desc "Verify Build for Android" -lane :android_build_verify do - gradle( - task: "assembleMosipDebug", - ) +lane :android_build do + gradle(task: "assembleMosipDebug") end desc "Deploy an Internal testing version to the Google Play" lane :android_build_internal do + previous_build_number = google_play_track_version_codes( package_name: "io.mosip.residentapp", track: "internal", diff --git a/android/scripts/verify-build.sh b/android/scripts/android-build.sh similarity index 82% rename from android/scripts/verify-build.sh rename to android/scripts/android-build.sh index 48fab8512..20ec199e3 100755 --- a/android/scripts/verify-build.sh +++ b/android/scripts/android-build.sh @@ -7,4 +7,4 @@ yes | sudo gem install bundler yes | sudo fastlane install_plugins -bundle exec fastlane android_build_verify +bundle exec fastlane android_build diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index a99dfc75e..dd127943e 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -19,6 +19,10 @@ FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT = "120" TESTFLIGHT_INTERNAL_TESTERS_GROUP = ENV["TESTFLIGHT_INTERNAL_TESTERS_GROUP"] TESTFLIGHT_BETA_APP_DESCRIPTION = ENV["TESTFLIGHT_BETA_APP_DESCRIPTION"] DEVELOPER_APP_ID = ENV["DEVELOPER_APP_ID"] +MIMOTO_HOST = ENV["MIMOTO_HOST"] +ESIGNET_HOST = ENV["ESIGNET_HOST"] +APPLICATION_THEME = ENV["APPLICATION_THEME"] +CREDENTIAL_REGISTRY_EDIT = ENV["CREDENTIAL_REGISTRY_EDIT"] def delete_temp_keychain(name) delete_keychain( @@ -123,42 +127,7 @@ platform :ios do ) end - lane :build_verify do - keychain_name = TEMP_KEYCHAIN_USER - keychain_password = TEMP_KEYCHAIN_PASSWORD - ensure_temp_keychain(keychain_name, keychain_password) - - api_key = app_store_connect_api_key( - key_id: "#{APPLE_KEY_ID}", - issuer_id: "#{APPLE_ISSUER_ID}", - key_content: "#{APPLE_KEY_CONTENT}", - duration: 1200, - in_house: false, - is_key_content_base64: true - ) - - match( - type: 'appstore', - app_identifier: "#{DEVELOPER_APP_IDENTIFIER}", - git_basic_authorization: Base64.strict_encode64("#{GIT_AUTHORIZATION}"), - readonly: false, - keychain_name: keychain_name, - keychain_password: keychain_password, - api_key: api_key - ) - - gym( - configuration: "Release", - workspace: "Inji.xcworkspace", - scheme: "Inji", - export_method: "app-store", - ) - - delete_temp_keychain(keychain_name) - - end - - lane :build_app_for_automation_on_simulator do + lane :build_app do custom_output_directory = "./Inji_app_file" sh("mkdir -p '#{custom_output_directory}'")