forked from cooperka/bash-git-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_utils.cfg
More file actions
46 lines (36 loc) · 1.68 KB
/
git_utils.cfg
File metadata and controls
46 lines (36 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# Custom config for git_utils.
# Name of the project on GitHub (or any other online git tool).
GIT_REPO_FULL_NAME='cribspot/apps'
# Attempting to push to master will cause the scripts to abort unless this is set to `true`.
GIT_ALLOW_PUSH_TO_MASTER=false
# @param $1 version name to update to.
# @param $2 root directory of project.
perform_version_bump() {
local iosConfig="$2/ios/HomeApp/Info.plist"
local androidConfig="$2/android/app/build.gradle"
# Update iOS Info.plist
local currVersion="$(defaults read "${iosConfig}" 'CFBundleVersion')"
defaults write "${iosConfig}" 'CFBundleVersion' -string "$((${currVersion} + 1))"
defaults write "${iosConfig}" 'CFBundleShortVersionString' -string "$1"
plutil -convert xml1 "${iosConfig}" # Convert plist back to XML.
# Update Gradle config
export TEMP=$1 # Make it global in order to expose this var to `sed`
gsed -ri 's/(.*)(versionName )(.*)/echo "\1\2\\"${TEMP}\\""/ge' "${androidConfig}"
gsed -ri 's/(.*)(versionCode )([0-9]+)(.*)/echo "\1\2$((\3 + 1))\4"/ge' "${androidConfig}"
perform_bundle_bump "$2" 'no'
# Commit the change.
git add "${iosConfig}" "${androidConfig}"
git commit -m ":gem: Bump version to $1" -m "Auto-change using build script v${BUILD_SCRIPT_VERSION}."
}
# @param $1 root directory of project.
# @param $2 any non-empty string iff it should be "silent" and not commit the change.
perform_bundle_bump() {
local config="$1/src/constants.js"
gsed -ri 's/(.*)(CODE_BUNDLE_ID:.*)([0-9]+)(.*)/echo "\1\2$((\3 + 1))\4"/ge' "${config}"
git add "${config}"
if [ -z $2 ]; then
git commit -m ":gem: Bump CodePush bundle ID" -m "Auto-change using build script v${BUILD_SCRIPT_VERSION}."
fi
}