Automatic Build Versioning

Automatic Build Versioning
COMMENTS ()
Tweet

The steps required for automatic build versioning have been mentioned as follows:

We need to make our application versioning system to apple generic as mentioned in the image below, and also make sure to set the current project version to 1.0.0.0

magento paypal

 

Our Version will have Following Numbers

1. 1.0.0.1 i.e (Major).(feature).(revision).(build)
2. We change major version if we change the overall theme of the application and hence has a totally different from existing app
3. Feature or minor is used to track the feature we are working on.
4. Revision number is used to track the revisions take place for that specific feature
5. Last number is important for our usual builds which we shared with qa for testing purpose and until we finish that feature we always increase that version.
6. Things become hectic when we have multiple environments/targets and also having multiple info.plist files so whenever we want to generate build for each environment then we might need to update the version number in each target settings and the chances of human error increases.
7. Solution: Create a single script to increase that version for you instead of manually updating the version.
8. Our commands will use the avgtool so make sure you have it installed before running these commands.

Setting Feature Version

When we start a new feature we want to give that feature a new version number also, for that we can use below simple commands.

magento paypal

 

Let’s discuss above commands in detail

1.Command at line#1 will fetch the current project version.
2.Command at line#2 will ask you to provide the new version for example 1.0.1
3.Command at line#3 will update the version number for each info.plist file so you don’t need to update it manually for each target, specially in the case when each target has different plist so it usually become so messy to maintain.
4.Command at line#4 will update the builds string and set it to 1.0.1.1
5.Command at line#5 will echo the current build string just for your confirmation.

Updating Build String

When we want to share a new build for testing we intend to update the build string so that qa can differentiate between the last build and new build, also if we using some task/bug tracking system and we have mark some tickets with specific fix version then also need to make sure that the build string for that build matches with the bug tracking tool.

Again instead of updating build string inside the each target will be hectic and can introduce a human error so what about making a script for that so it updates the build string for each target automatically.

magento paypal

We will use below command for updating the build string

magento paypal

For executing the different functions associated with automatic build versioning, the code has been provided as follows:

#!/bin/bash

#########################
# The command line help #
#########################
display_help() {
    echo "Usage: $0 [option...] {-set_ver|-bump_ver|-bump_build}" >&2
    echo
    echo "   set_ver		Set new version number for new feature"
    echo "   bump_ver		Increament the version number for new feature "
    echo "   bump_build	Increase the build version for the new build"
    echo
    exit 1
}

update_version_number(){
	agvtool new-marketing-version "$1" > /dev/null
	agvtool new-version -all "$1".1  > /dev/null	
	
	echo " (i) New version number: $1"
    echo " (i) New build String:   `agvtool vers -terse`"
}

set_version_number() {
	version_number=$(agvtool mvers -terse1)
	read -p "Enter new version number [current=$version_number]: " version_number
	update_version_number $version_number
}

bump_version_number() {
	version_number=$(agvtool mvers -terse1)
    echo " (i) Current version number: $version_number"
    echo " (i) Current build String:   `agvtool vers -terse`"
            
    # increment version number
    minor_version_number=$(echo $version_number | awk -F "." '{print $3}')
    ((minor_version_number++))
    version_number=$(echo $version_number | awk -F "." '{print $1 "." $2 ".'$minor_version_number'"}')
    update_version_number $version_number            
}

bump_build_string() {
	echo " (i) Current build String: `agvtool vers -terse`"
	agvtool bump -increment-minor-version -all > /dev/null
	echo " (i) New build String:     `agvtool vers -terse`"
}            


################################
# Check if parameters options  #
# are given on the commandline #
################################

#If want to set the version number
if [ "$1" == "set_ver" ]; then
	set_version_number
elif [ "$1" == "bump_ver" ]; then
	#If user want to bump the version string i.e 1.0.0 to 1.0.1
	bump_version_number
elif [ "$1" == "bump_build" ]; then
	#If user want to bump the build string i.e 1.0.0.1 to 1.0.0.2
	bump_build_string
else
	#If user didn't select any option than show help menu
	display_help
	exit 0
fi

 

CALL

USA408 365 4638

VISIT

1301 Shoreway Road, Suite 160,

Belmont, CA 94002

Contact us

Whether you are a large enterprise looking to augment your teams with experts resources or an SME looking to scale your business or a startup looking to build something.
We are your digital growth partner.

Tel: +1 408 365 4638
Support: +1 (408) 512 1812