-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit_utils.cfg
33 lines (27 loc) · 1.35 KB
/
git_utils.cfg
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
#!/bin/bash
#
# Custom config for git_utils.
# Name of the project on GitHub (or any other online git tool).
GIT_REPO_FULL_NAME='cooperka/git-utils'
# 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() {
# Save the version number in an example config file...
echo "$1" > "$2/example.cfg"
# ...Or perhaps you'd like to edit an iOS Info.plist?
local iosConfig="$2/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.
# ...Or an Android Gradle config?
local androidConfig="$2/android/build.gradle"
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}"
# Commit the change.
git add "$2/example.cfg" "${iosConfig}" "${androidConfig}"
git commit -m ":gem: Bump version to $1" -m "Auto-change using build script v${BUILD_SCRIPT_VERSION}."
}