Refactor android job

This commit is contained in:
Diego Mello 2023-06-21 10:15:56 -03:00
parent 5839327baa
commit e7bdef461b
1 changed files with 144 additions and 86 deletions

View File

@ -99,102 +99,102 @@ commands:
- ~/.pods
- ios/Pods
android-build:
description: "Build Android app"
steps:
- checkout
# android-build:
# description: "Build Android app"
# steps:
# - checkout
- restore_cache: *restore-npm-cache-linux
# - restore_cache: *restore-npm-cache-linux
- run: *install-npm-modules
# - run: *install-npm-modules
- restore_cache: *restore-gradle-cache
# - restore_cache: *restore-gradle-cache
- run:
name: Configure Gradle
command: |
echo -e "" > ./gradle.properties
echo -e "android.useAndroidX=true" >> ./gradle.properties
echo -e "android.enableJetifier=true" >> ./gradle.properties
echo -e "newArchEnabled=false" >> ./gradle.properties
echo -e "hermesEnabled=true" >> ./gradle.properties
echo -e "FLIPPER_VERSION=0.125.0" >> ./gradle.properties
echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties
# - run:
# name: Configure Gradle
# command: |
# echo -e "" > ./gradle.properties
# echo -e "android.useAndroidX=true" >> ./gradle.properties
# echo -e "android.enableJetifier=true" >> ./gradle.properties
# echo -e "newArchEnabled=false" >> ./gradle.properties
# echo -e "hermesEnabled=true" >> ./gradle.properties
# echo -e "FLIPPER_VERSION=0.125.0" >> ./gradle.properties
# echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties
if [[ $CIRCLE_JOB == "android-build-official" ]]; then
echo -e "APPLICATION_ID=chat.rocket.android" >> ./gradle.properties
echo -e "BugsnagAPIKey=$BUGSNAG_KEY_OFFICIAL" >> ./gradle.properties
echo $KEYSTORE_OFFICIAL_BASE64 | base64 --decode > ./app/$KEYSTORE_OFFICIAL
echo -e "KEYSTORE=$KEYSTORE_OFFICIAL" >> ./gradle.properties
echo -e "KEYSTORE_PASSWORD=$KEYSTORE_OFFICIAL_PASSWORD" >> ./gradle.properties
echo -e "KEY_ALIAS=$KEYSTORE_OFFICIAL_ALIAS" >> ./gradle.properties
echo -e "KEY_PASSWORD=$KEYSTORE_OFFICIAL_PASSWORD" >> ./gradle.properties
else
echo -e "APPLICATION_ID=chat.rocket.reactnative" >> ./gradle.properties
echo -e "BugsnagAPIKey=$BUGSNAG_KEY" >> ./gradle.properties
echo $KEYSTORE_EXPERIMENTAL_BASE64 | base64 --decode > ./app/$KEYSTORE_EXPERIMENTAL
echo -e "KEYSTORE=$KEYSTORE_EXPERIMENTAL" >> ./gradle.properties
echo -e "KEYSTORE_PASSWORD=$KEYSTORE_EXPERIMENTAL_PASSWORD" >> ./gradle.properties
echo -e "KEY_ALIAS=$KEYSTORE_EXPERIMENTAL_ALIAS" >> ./gradle.properties
echo -e "KEY_PASSWORD=$KEYSTORE_EXPERIMENTAL_PASSWORD" >> ./gradle.properties
fi
working_directory: android
# if [[ $CIRCLE_JOB == "android-build-official" ]]; then
# echo -e "APPLICATION_ID=chat.rocket.android" >> ./gradle.properties
# echo -e "BugsnagAPIKey=$BUGSNAG_KEY_OFFICIAL" >> ./gradle.properties
# echo $KEYSTORE_OFFICIAL_BASE64 | base64 --decode > ./app/$KEYSTORE_OFFICIAL
# echo -e "KEYSTORE=$KEYSTORE_OFFICIAL" >> ./gradle.properties
# echo -e "KEYSTORE_PASSWORD=$KEYSTORE_OFFICIAL_PASSWORD" >> ./gradle.properties
# echo -e "KEY_ALIAS=$KEYSTORE_OFFICIAL_ALIAS" >> ./gradle.properties
# echo -e "KEY_PASSWORD=$KEYSTORE_OFFICIAL_PASSWORD" >> ./gradle.properties
# else
# echo -e "APPLICATION_ID=chat.rocket.reactnative" >> ./gradle.properties
# echo -e "BugsnagAPIKey=$BUGSNAG_KEY" >> ./gradle.properties
# echo $KEYSTORE_EXPERIMENTAL_BASE64 | base64 --decode > ./app/$KEYSTORE_EXPERIMENTAL
# echo -e "KEYSTORE=$KEYSTORE_EXPERIMENTAL" >> ./gradle.properties
# echo -e "KEYSTORE_PASSWORD=$KEYSTORE_EXPERIMENTAL_PASSWORD" >> ./gradle.properties
# echo -e "KEY_ALIAS=$KEYSTORE_EXPERIMENTAL_ALIAS" >> ./gradle.properties
# echo -e "KEY_PASSWORD=$KEYSTORE_EXPERIMENTAL_PASSWORD" >> ./gradle.properties
# fi
# working_directory: android
- run:
name: Set Google Services
command: |
if [[ $GOOGLE_SERVICES_ANDROID ]]; then
echo $GOOGLE_SERVICES_ANDROID | base64 --decode > google-services.json
fi
working_directory: android/app
# - run:
# name: Set Google Services
# command: |
# if [[ $GOOGLE_SERVICES_ANDROID ]]; then
# echo $GOOGLE_SERVICES_ANDROID | base64 --decode > google-services.json
# fi
# working_directory: android/app
- run:
name: Build App
no_output_timeout: 40m
command: |
sudo apt install -y libicu-dev
if [[ $CIRCLE_JOB == "android-build-official" ]]; then
./gradlew bundleOfficialPlayRelease
fi
if [[ $CIRCLE_JOB == "android-build-experimental" || "android-automatic-build-experimental" ]]; then
./gradlew bundleExperimentalPlayRelease
fi
if [[ ! $GOOGLE_SERVICES_ANDROID ]]; then
./gradlew assembleExperimentalPlayDebug
fi
working_directory: android
# - run:
# name: Build App
# no_output_timeout: 40m
# command: |
# sudo apt install -y libicu-dev
# if [[ $CIRCLE_JOB == "android-build-official" ]]; then
# ./gradlew bundleOfficialPlayRelease
# fi
# if [[ $CIRCLE_JOB == "android-build-experimental" || "android-automatic-build-experimental" ]]; then
# ./gradlew bundleExperimentalPlayRelease
# fi
# if [[ ! $GOOGLE_SERVICES_ANDROID ]]; then
# ./gradlew assembleExperimentalPlayDebug
# fi
# working_directory: android
- run:
name: Upload sourcemaps to Bugsnag
command: |
if [[ $CIRCLE_JOB == "android-build-official" ]]; then
npx bugsnag-source-maps upload-react-native \
--api-key=$BUGSNAG_KEY_OFFICIAL \
--app-version-code=$CIRCLE_BUILD_NUM \
--platform android \
--source-map=android/app/build/generated/sourcemaps/react/officialPlayRelease/index.android.bundle.map \
--bundle android/app/build/ASSETS/createBundleOfficialPlayReleaseJsAndAssets/index.android.bundle
fi
if [[ $CIRCLE_JOB == "android-build-experimental" || "android-automatic-build-experimental" ]]; then
npx bugsnag-source-maps upload-react-native \
--api-key=$BUGSNAG_KEY \
--app-version-code=$CIRCLE_BUILD_NUM \
--platform android \
--source-map=android/app/build/generated/sourcemaps/react/experimentalPlayRelease/index.android.bundle.map \
--bundle android/app/build/ASSETS/createBundleExperimentalPlayReleaseJsAndAssets/index.android.bundle
fi
# - run:
# name: Upload sourcemaps to Bugsnag
# command: |
# if [[ $CIRCLE_JOB == "android-build-official" ]]; then
# npx bugsnag-source-maps upload-react-native \
# --api-key=$BUGSNAG_KEY_OFFICIAL \
# --app-version-code=$CIRCLE_BUILD_NUM \
# --platform android \
# --source-map=android/app/build/generated/sourcemaps/react/officialPlayRelease/index.android.bundle.map \
# --bundle android/app/build/ASSETS/createBundleOfficialPlayReleaseJsAndAssets/index.android.bundle
# fi
# if [[ $CIRCLE_JOB == "android-build-experimental" || "android-automatic-build-experimental" ]]; then
# npx bugsnag-source-maps upload-react-native \
# --api-key=$BUGSNAG_KEY \
# --app-version-code=$CIRCLE_BUILD_NUM \
# --platform android \
# --source-map=android/app/build/generated/sourcemaps/react/experimentalPlayRelease/index.android.bundle.map \
# --bundle android/app/build/ASSETS/createBundleExperimentalPlayReleaseJsAndAssets/index.android.bundle
# fi
- store_artifacts:
path: android/app/build/outputs
# - store_artifacts:
# path: android/app/build/outputs
- save_cache: *save-npm-cache-linux
# - save_cache: *save-npm-cache-linux
- save_cache: *save-gradle-cache
# - save_cache: *save-gradle-cache
- persist_to_workspace:
root: .
paths:
- android/app/build/outputs
# - persist_to_workspace:
# root: .
# paths:
# - android/app/build/outputs
# ios-build:
# description: "Build iOS app"
@ -365,7 +365,66 @@ jobs:
<<: *bash-env
resource_class: xlarge
steps:
- android-build
- checkout
- restore_cache: *restore-npm-cache-linux
- run: *install-npm-modules
- restore_cache: *restore-gradle-cache
- run:
name: Configure Gradle
command: |
echo -e "" > ./gradle.properties
echo -e "android.useAndroidX=true" >> ./gradle.properties
echo -e "android.enableJetifier=true" >> ./gradle.properties
echo -e "newArchEnabled=false" >> ./gradle.properties
echo -e "hermesEnabled=true" >> ./gradle.properties
echo -e "FLIPPER_VERSION=0.125.0" >> ./gradle.properties
echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties
echo -e "APPLICATION_ID=chat.rocket.android" >> ./gradle.properties
echo -e "BugsnagAPIKey=$BUGSNAG_KEY_OFFICIAL" >> ./gradle.properties
echo $KEYSTORE_OFFICIAL_BASE64 | base64 --decode > ./app/$KEYSTORE_OFFICIAL
echo -e "KEYSTORE=$KEYSTORE_OFFICIAL" >> ./gradle.properties
echo -e "KEYSTORE_PASSWORD=$KEYSTORE_OFFICIAL_PASSWORD" >> ./gradle.properties
echo -e "KEY_ALIAS=$KEYSTORE_OFFICIAL_ALIAS" >> ./gradle.properties
echo -e "KEY_PASSWORD=$KEYSTORE_OFFICIAL_PASSWORD" >> ./gradle.properties
working_directory: android
- run:
name: Set Google Services
command: |
if [[ $GOOGLE_SERVICES_ANDROID ]]; then
echo $GOOGLE_SERVICES_ANDROID | base64 --decode > google-services.json
fi
working_directory: android/app
- run:
name: Build App
no_output_timeout: 40m
command: |
sudo apt install -y libicu-dev
if [[ $CIRCLE_JOB == "android-build" ]]; then
./gradlew bundlePlayRelease
fi
if [[ ! $GOOGLE_SERVICES_ANDROID ]]; then
./gradlew assemblePlayDebug
fi
working_directory: android
- run:
name: Upload sourcemaps to Bugsnag
command: |
if [[ $CIRCLE_JOB == "android-build" ]]; then
npx bugsnag-source-maps upload-react-native \
--api-key=$BUGSNAG_KEY_OFFICIAL \
--app-version-code=$CIRCLE_BUILD_NUM \
--platform android \
--source-map=android/app/build/generated/sourcemaps/react/officialPlayRelease/index.android.bundle.map \
--bundle android/app/build/ASSETS/createBundleOfficialPlayReleaseJsAndAssets/index.android.bundle
fi
- store_artifacts:
path: android/app/build/outputs
- save_cache: *save-npm-cache-linux
- save_cache: *save-gradle-cache
- persist_to_workspace:
root: .
paths:
- android/app/build/outputs
# # Android automatic builds
# android-automatic-build-experimental:
@ -496,7 +555,6 @@ jobs:
ios-build:
executor: mac-env
description: "Build iOS app"
steps:
- checkout
- restore_cache: *restore-gems-cache