forked from Sage-Bionetworks/Synapse-Repository-Services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pomSnapshotToGitHash.sh
20 lines (20 loc) · 859 Bytes
/
pomSnapshotToGitHash.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
#This script will change the vesion of all pom.xml files from:
#<version>develop-SNAPSHOT</version>
# to
#<version>yyyy-mm-dd-hash</version>
# The new version number is <date>-<hash>. The <hash> is the abbreviated hash of the last commit
args=("$@")
buildNumber=${args[0]}
if [ -z "$buildNumber" ] ;
then buildNumber="??"
fi
echo $buildNumber
abbreviatedCommitHash="<version>"$(date +%Y-%m-%d)"-"`git log -n 1 --pretty=format:%h`"-$buildNumber</version>"
echo "Changing all pom.xml to version=$abbreviatedCommitHash"
#sed "s|<version>develop-SNAPSHOT</version>|$abbreviatedCommitHash|g" pom.xml > temp-pom.xml
for f in `find -name "pom.xml"` ; do
echo "Changing version of $f"
#We are using sed to replaces all 'develop-SNAPSHOT' verions with the new
sed "s|<version>develop-SNAPSHOT</version>|$abbreviatedCommitHash|g" -i $f
done