Merge pull request #542 from status-im/feature/build-version

git-commit and tag based versioning
This commit is contained in:
Roman Volosovskyi 2016-12-08 16:34:14 +02:00 committed by GitHub
commit 97c5bebafe
2 changed files with 39 additions and 11 deletions

View File

@ -79,6 +79,26 @@ def enableSeparateBuildPerCPUArchitecture = false
*/
def enableProguardInReleaseBuilds = false
def getVersionCode = { ->
new ByteArrayOutputStream().withStream { stdOut ->
exec {
commandLine "git", "rev-list", "--count", "HEAD"
standardOutput = stdOut
}
return stdOut.toString().toInteger()
}
}
def getVersionName = { ->
new ByteArrayOutputStream().withStream { stdOut ->
exec {
commandLine "git", "describe", "--tags", "--always", "--dirty=+"
standardOutput = stdOut
}
return stdOut.toString().replaceAll("\\s","")
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
@ -87,8 +107,8 @@ android {
applicationId "im.status.ethereum"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionCode getVersionCode()
versionName getVersionName()
ndk {
abiFilters "armeabi-v7a", "x86"
}
@ -113,6 +133,9 @@ android {
}
}
buildTypes {
debug {
versionNameSuffix "-SNAPSHOT"
}
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

View File

@ -46,7 +46,6 @@
8E55E6877F950B81C8D711C5 /* libPods-StatusIm.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 101A4045637A2ADF57D28EF5 /* libPods-StatusIm.a */; };
9E0B01A11DDC5DA7002B0359 /* SF-UI-Text-Light.otf in Resources */ = {isa = PBXBuildFile; fileRef = 9E0B01A01DDC5DA7002B0359 /* SF-UI-Text-Light.otf */; };
9E3AB6D01D87DB2B008846B4 /* libReact-Native-Webview-Bridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E3AB6C61D87DA2B008846B4 /* libReact-Native-Webview-Bridge.a */; };
9E982B241DE3036A00EC0D84 /* libSplashScreen.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E982B211DE3035800EC0D84 /* libSplashScreen.a */; };
9ED2F45E1D9D535A00B36508 /* SF-UI-Text-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 9ED2F45D1D9D52DD00B36508 /* SF-UI-Text-Regular.otf */; };
9ED2F45F1D9D535A00B36508 /* SF-UI-Text-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = 9ED2F45C1D9D52C100B36508 /* SF-UI-Text-Medium.otf */; };
9ED2F4611D9D579900B36508 /* SF-UI-Text-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 9ED2F4601D9D577B00B36508 /* SF-UI-Text-Bold.otf */; };
@ -845,14 +844,6 @@
name = Products;
sourceTree = "<group>";
};
9E982AEA1DE3033C00EC0D84 /* Products */ = {
isa = PBXGroup;
children = (
9E982B211DE3035800EC0D84 /* libSplashScreen.a */,
);
name = Products;
sourceTree = "<group>";
};
A97BA941B2FB44B4B66EE6D3 /* Frameworks */ = {
isa = PBXGroup;
children = (
@ -938,6 +929,7 @@
20B6B6891D92C42700CC5C6A /* Embed Frameworks */,
9E71BA90038083A3D24E18E9 /* [CP] Embed Pods Frameworks */,
E883D1F9B22B8292CC879292 /* [CP] Copy Pods Resources */,
E3914A731DF919ED00EBB515 /* ShellScript */,
);
buildRules = (
);
@ -1498,6 +1490,19 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-StatusIm/Pods-StatusIm-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
E3914A731DF919ED00EBB515 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#!/bin/bash\n\n# This script automatically sets the version and short version string of\n# an Xcode project from the Git repository containing the project.\n#\n# To use this script in Xcode, add the script's path to a \"Run Script\" build\n# phase for your application target.\n\nset -o errexit\nset -o nounset\n\n# First, check for git in $PATH\nhash git 2>/dev/null || { echo >&2 \"Git required, not installed. Aborting build number update script.\"; exit 0; }\n\n# Alternatively, we could use Xcode's copy of the Git binary,\n# but old Xcodes don't have this.\n#GIT=$(xcrun -find git)\n\n# Run Script build phases that operate on product files of the target that defines them should use the value of this build setting [TARGET_BUILD_DIR]. But Run Script build phases that operate on product files of other targets should use “BUILT_PRODUCTS_DIR” instead.\nINFO_PLIST=\"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\n\n# Build version (closest-tag-or-branch \"-\" commits-since-tag \"-\" short-hash dirty-flag)\nBUILD_VERSION=$(git describe --tags --always --dirty=+)\n\n# Use the latest tag for short version (expected tag format \"vn[.n[.n]]\")\n# or if there are no tags, we make up version 0.0.<commit count>\nLATEST_TAG=$(git describe --tags --match 'v*' --abbrev=0 2>/dev/null) || LATEST_TAG=\"HEAD\"\nif [ $LATEST_TAG = \"HEAD\" ]\nthen COMMIT_COUNT=$(git rev-list --count HEAD)\n LATEST_TAG=\"0.0.$COMMIT_COUNT\"\n COMMIT_COUNT_SINCE_TAG=0\nelse\n COMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..)\n LATEST_TAG=${LATEST_TAG##v} # Remove the \"v\" from the front of the tag\nfi\nif [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then\n SHORT_VERSION=\"$LATEST_TAG\"\nelse\n # increment final digit of tag and append \"d\" + commit-count-since-tag\n # e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1\n # this is the bit that requires /bin/bash\n OLD_IFS=$IFS\n IFS=\".\"\n VERSION_PARTS=($LATEST_TAG)\n LAST_PART=$((${#VERSION_PARTS[@]}-1))\n VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1))\n SHORT_VERSION=\"${VERSION_PARTS[*]}d${COMMIT_COUNT_SINCE_TAG}\"\n IFS=$OLD_IFS\nfi\n \n# Bundle version (commits-on-master[-until-branch \".\" commits-on-branch])\n# Assumes that two release branches will not diverge from the same commit on master.\nif [ $(git rev-parse --abbrev-ref HEAD) = \"master\" ]; then\n MASTER_COMMIT_COUNT=$(git rev-list --count HEAD)\n BRANCH_COMMIT_COUNT=0\n BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\nelse\n MASTER_COMMIT_COUNT=$(git rev-list --count $(git rev-list master.. | tail -n 1)^)\n BRANCH_COMMIT_COUNT=$(git rev-list --count master..)\n if [ $BRANCH_COMMIT_COUNT = 0 ]\n then BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\n else BUNDLE_VERSION=\"${MASTER_COMMIT_COUNT}.${BRANCH_COMMIT_COUNT}\"\n fi\nfi\n \n# For debugging:\necho \"BUILD VERSION: $BUILD_VERSION\"\necho \"LATEST_TAG: $LATEST_TAG\"\necho \"COMMIT_COUNT_SINCE_TAG: $COMMIT_COUNT_SINCE_TAG\"\necho \"SHORT VERSION: $SHORT_VERSION\"\necho \"MASTER_COMMIT_COUNT: $MASTER_COMMIT_COUNT\"\necho \"BRANCH_COMMIT_COUNT: $BRANCH_COMMIT_COUNT\"\necho \"BUNDLE_VERSION: $BUNDLE_VERSION\"\n \n/usr/libexec/PlistBuddy -c \"Add :CFBundleBuildVersion string $BUILD_VERSION\" \"$INFO_PLIST\" 2>/dev/null || /usr/libexec/PlistBuddy -c \"Set :CFBundleBuildVersion $BUILD_VERSION\" \"$INFO_PLIST\"\n/usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $SHORT_VERSION\" \"$INFO_PLIST\"\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $BUNDLE_VERSION\" \"$INFO_PLIST\"";
};
E883D1F9B22B8292CC879292 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;