Last active
July 14, 2021 07:21
-
-
Save tuantvk/16d5a5914bf7d4e8aede685e863f8ea7 to your computer and use it in GitHub Desktop.
Build script on Android for React Native.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# change env to dev | |
cat env.dev > .env; | |
cat documents/google-services/google-services-dev.json > android/app/google-services.json; | |
cat <<END >android/app/src/main/res/values/strings.xml | |
<resources> | |
<string name="app_name">Dev Example</string> | |
</resources> | |
END | |
# auto open file on VS Code (Only on Ubuntu) | |
if [[ "$OSTYPE" != "darwin"* ]]; then | |
code -r package.json; | |
code -r .env; | |
code -r android/app/build.gradle; | |
code -r android/app/google-services.json; | |
code -r android/app/src/main/res/values/strings.xml; | |
fi | |
PACKAGE_VERSION=$(cat package.json \ | |
| grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",\t ]//g') | |
APPLICATION_ID=$(cat android/app/build.gradle \ | |
| grep applicationId \ | |
| head -1 \ | |
| awk '{ print $2 }' \ | |
| sed 's/[",\t ]//g') | |
VERSION_CODE=$(cat android/app/build.gradle \ | |
| grep versionCode \ | |
| head -1 \ | |
| awk '{ print $2 }' \ | |
| sed 's/[\t ]//g') | |
VERSION_NAME=$(cat android/app/build.gradle \ | |
| grep versionName \ | |
| head -1 \ | |
| awk '{ print $2 }' \ | |
| sed 's/[",\t ]//g') | |
PACKAGE_NAME=$(cat android/app/google-services.json \ | |
| grep package_name \ | |
| head -1 \ | |
| awk '{ print $2 }' \ | |
| sed 's/[",\t ]//g') | |
APP_NAME=$(cat android/app/src/main/res/values/strings.xml \ | |
| grep app_name \ | |
| head -1 \ | |
| awk -F'[<>]' '/"app_name"/ {print $3}' \ | |
| sed 's/["]//g') | |
echo "version:" $PACKAGE_VERSION; | |
echo "application_id:" $APPLICATION_ID; | |
echo "version_code:" $VERSION_CODE; | |
echo "version_name:" $VERSION_NAME; | |
echo "package_name:" $PACKAGE_NAME; | |
echo "app_name:" $APP_NAME; | |
cat .env; echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment