VOL-1996 Use v-prefixed versions with golang projects
Change-Id: I0de8742fa41b957fe3c6f13ace5b63836ead7993
diff --git a/jjb/shell/tagcollisionreject.sh b/jjb/shell/tagcollisionreject.sh
index 49d6e21..309e35c 100755
--- a/jjb/shell/tagcollisionreject.sh
+++ b/jjb/shell/tagcollisionreject.sh
@@ -21,6 +21,7 @@
VERSIONFILE="" # file path to file containing version number
NEW_VERSION="" # version number found in $VERSIONFILE
+TAG_VERSION="" # version file that might have a leading v to work around go mod funkyness
SEMVER_STRICT=${SEMVER_STRICT:-0} # require semver versions
@@ -37,13 +38,25 @@
then
NEW_VERSION=$(head -n1 "VERSION")
VERSIONFILE="VERSION"
+
+ # If this is a golang project, use funky v-prefixed versions
+ if [ -f "Gopkg.toml" ] || [ -f "go.mod" ]
+ then
+ echo "go-based project found, using v-prefixed version for git tags: v${NEW_VERSION}"
+ TAG_VERSION=v${NEW_VERSION}
+ else
+ TAG_VERSION=${NEW_VERSION}
+ fi
+
elif [ -f "package.json" ]
then
NEW_VERSION=$(python -c 'import json,sys;obj=json.load(sys.stdin); print obj["version"]' < package.json)
+ TAG_VERSION=$NEW_VERSION
VERSIONFILE="package.json"
elif [ -f "pom.xml" ]
then
NEW_VERSION=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml)
+ TAG_VERSION=$NEW_VERSION
VERSIONFILE="pom.xml"
else
echo "ERROR: No versioning file found!"
@@ -51,18 +64,6 @@
fi
}
-# check if the version is already a tag in git
-function is_git_tag_duplicated {
- for existing_tag in $(git tag)
- do
- if [ "$NEW_VERSION" = "$existing_tag" ]
- then
- echo "ERROR: Duplicate tag: $existing_tag"
- exit 2
- fi
- done
-}
-
# check if the version is a released version
function check_if_releaseversion {
if [[ "$NEW_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]
@@ -80,6 +81,18 @@
fi
}
+# check if the version is already a tag in git
+function is_git_tag_duplicated {
+ for existing_tag in $(git tag)
+ do
+ if [ "$TAG_VERSION" = "$existing_tag" ]
+ then
+ echo "ERROR: Duplicate tag: $existing_tag"
+ exit 2
+ fi
+ done
+}
+
# check if Dockerfiles have a released version as their parent
function dockerfile_parentcheck {
while IFS= read -r -d '' dockerfile