Skip to content

Instantly share code, notes, and snippets.

@bensig
Created September 22, 2021 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bensig/43cb3391b99b9799e12351d577af8191 to your computer and use it in GitHub Desktop.
Save bensig/43cb3391b99b9799e12351d577af8191 to your computer and use it in GitHub Desktop.
Simple bash script to bump the version of an xcodeproj and gradle to the same version number
#!/bin/sh
# simple bash script to update the build number to whatever is entered.
appname="yourname"
# variables
pbxproj="ios/$appname.xcodeproj/project.pbxproj";
gradle='android/app/build.gradle';
# get current versions
androidVersion=`cat $gradle |grep -m1 "versionName" | cut -d'"' -f2 | tr -d ';' | tr -d ' '`
iosVersion=`cat $pbxproj | grep -m1 'MARKETING_VERSION' | cut -d'=' -f2 | tr -d ';' | tr -d ' '`
# show current versions
echo "Current iOS Version: $iosVersion"
echo "Current Android Version: $androidVersion"
# get new version from user input
read -p "Please enter the version number to set: " version
# confirm new version change
read -p "Changing to $version - continue?"
# change to new version
sed -i '' -e 's/'"$iosVersion"'/'"$version"'/g' $pbxproj
sed -i '' -e 's/'"$androidVersion"'/'"$version"'/g' $gradle
# get new versions
androidVersion=`cat $gradle |grep -m1 "versionName" | cut -d'"' -f2 | tr -d ';' | tr -d ' '`
iosVersion=`cat $pbxproj | grep -m1 'MARKETING_VERSION' | cut -d'=' -f2 | tr -d ';' | tr -d ' '`
# display new versions
echo "New iOS Version: $iosVersion"
echo "New Android Version: $androidVersion"
# tag version for release
git add .
git tag release-$version
git commit -m "Increment version for release-$version"
echo "Now run: git push --tags && git push"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment