
Initially maven-properties.sh was intended to make maven projects use git versioning, that's how it got the name. However this filename is inappropriate because it's just a generic script that retrieves git version info to allow builds to version their artifacts. version-properties.sh is a much more appropriate name for this script. Change-Id: I3ffc3e9e29bb626f4af5449f0413608a30ee79a0
29 lines
907 B
Bash
Executable File
29 lines
907 B
Bash
Executable File
#!/bin/bash -ex
|
|
|
|
# This is a script that helps us version build artifacts. It retrieves
|
|
# git info and generates version strings.
|
|
|
|
# get version info from scm
|
|
SCM_TAG=`git describe --abbrev=0 --tags` || true
|
|
SCM_SHA=`git rev-parse --short HEAD` || true
|
|
|
|
# assumes format is like this '0.0.4-2-g135721c'
|
|
COMMITS_SINCE_TAG=`git describe | awk '{split($0,a,"-"); print a[2]}'` || true
|
|
|
|
# just use git sha if there is no tag yet.
|
|
if [[ "${SCM_TAG}" == "" ]]; then
|
|
SCM_TAG=$SCM_SHA
|
|
fi
|
|
|
|
# General build version should be something like '0.0.4.3.d4ee90c'
|
|
# Release build version should be something like '0.0.5'
|
|
if [[ "${COMMITS_SINCE_TAG}" == "" ]]; then
|
|
PROJECT_VER=$SCM_TAG
|
|
else
|
|
PROJECT_VER="$SCM_TAG.$COMMITS_SINCE_TAG.$SCM_SHA";
|
|
fi
|
|
|
|
echo "SCM_SHA=$SCM_SHA" >version.properties
|
|
echo "PROJECT_VER=$PROJECT_VER" >>version.properties
|
|
echo "COMMITS_SINCE_TAG=$COMMITS_SINCE_TAG" >>version.properties
|