Skip to content

Commit 118e4df

Browse files
committed
📝 Improve the example config
Convert plist to XML; gsed in place; clean up.
1 parent 6946120 commit 118e4df

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

git_utils.cfg

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ perform_version_bump() {
1515
echo "$1" > "$2/example.cfg"
1616

1717
# ...Or perhaps you'd like to edit an iOS Info.plist?
18-
local currVersion=defaults read "$2/Info.plist" 'CFBundleVersion'
19-
defaults write "$2/Info.plist" 'CFBundleVersion' -string "${currVersion}"
20-
defaults write "$2/Info.plist" 'CFBundleShortVersionString' -string "$1"
18+
local iosConfig="$2/ios/Info.plist"
19+
local currVersion="$(defaults read "${iosConfig}" 'CFBundleVersion')"
20+
defaults write "${iosConfig}" 'CFBundleVersion' -string "$((${currVersion} + 1))"
21+
defaults write "${iosConfig}" 'CFBundleShortVersionString' -string "$1"
22+
plutil -convert xml1 "${iosConfig}" # Convert plist back to XML.
2123

2224
# ...Or an Android Gradle config?
23-
gsed -r 's/(.*)(versionName )(.*)/echo "\1\2\\"$1\\""/ge' "$2/build.gradle"
24-
gsed -r 's/(.*)(versionCode )([0-9]+)(.*)/echo "\1\2$((\3+1))\4"/ge' "$2/build.gradle"
25+
local androidConfig="$2/android/build.gradle"
26+
export TEMP=$1 # Make it global in order to expose this var to `sed`
27+
gsed -ri 's/(.*)(versionName )(.*)/echo "\1\2\\"${TEMP}\\""/ge' "${androidConfig}"
28+
gsed -ri 's/(.*)(versionCode )([0-9]+)(.*)/echo "\1\2$((\3 + 1))\4"/ge' "${androidConfig}"
2529

2630
# Commit the change.
27-
git add "$2/{example.cfg, Info.plist, build.gradle}"
31+
git add "$2/example.cfg" "${iosConfig}" "${androidConfig}"
2832
git commit -m ":gem: Bump version to $1" -m "Auto-change using build script v${BUILD_SCRIPT_VERSION}."
2933
}

0 commit comments

Comments
 (0)