Add release script, fix sed for MacOS
[policy/parent.git] / integration / src / release_scripts / mkart.sh
index ed27852..62ec030 100755 (executable)
@@ -5,6 +5,7 @@
 # ONAP
 # =========================================================================
 # Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+# Modifications Copyright (C) 2022 Nordix Foundation.
 # =========================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # can get through the firewall.
 #
 
+# Use the bash internal OSTYPE variable to check for MacOS
+if [[ "$OSTYPE" == "darwin"* ]]
+then
+    SED="gsed"
+else
+    SED="sed"
+fi
+
+set -e
+
 has_docker_images=false
 
 if [ "$1" == "-d" ]
@@ -57,20 +68,20 @@ fi
 echo Branch: ${BRANCH}
 
 PROJECT=$(awk -F= '$1 == "project" { print $2 }' "${TOPDIR}/.gitreview" |
-            sed 's/.git$//')
+            $SED 's/.git$//')
 if [ -z "${PROJECT}" ]; then
     echo "cannot extract project from ${TOPDIR}/.gitreview" >&2
     exit 1
 fi
 echo Project: ${PROJECT}
-TPROJ=$(echo ${PROJECT} | sed 's!/!%2F!')
-DPROJ=$(echo ${PROJECT} | sed 's!/!-!')
+TPROJ=$(echo ${PROJECT} | $SED 's!/!%2F!')
+DPROJ=$(echo ${PROJECT} | $SED 's!/!-!')
 
 VERSION=$(
     xmllint --xpath \
         '/*[local-name()="project"]/*[local-name()="version"]/text()' \
         "${TOPDIR}/pom.xml" |
-    sed 's!-SNAPSHOT!!'
+    $SED 's!-SNAPSHOT!!'
     )
 if [ -z "${VERSION}" ]; then
     echo "cannot extract version from ${TOPDIR}/pom.xml" >&2
@@ -82,7 +93,7 @@ prefix='https://jenkins.onap.org/view/policy/job/'
 STAGE_ID=$(
     curl --silent ${prefix}${DPROJ}-maven-stage-${BRANCH}/ |
     grep "Last completed build" |
-    sed -e 's!.*Last completed build .#!!' -e 's!).*!!' |
+    $SED -e 's!.*Last completed build .#!!' -e 's!).*!!' |
     head -1
     )
 if [ -z "${STAGE_ID}" ]; then