Allow to just build the artifact without upload using -n
authorSofian Brabez <sofian.brabez@gonitro.com>
Thu, 22 Aug 2019 14:33:20 +0000 (15:33 +0100)
committerSofian Brabez <sofian.brabez@gonitro.com>
Thu, 5 Sep 2019 13:48:12 +0000 (14:48 +0100)
release.sh

index 9e4561f6baf6e03159189726174e8aa76d04fb98..fa7472615b5b5308077aa2be8303390f712ec740 100755 (executable)
@@ -19,8 +19,9 @@ usage() {
 
     Options:
 
-    -s Dry run (simulate)
     -h Help
+    -s Dry run (simulate)
+    -n Does not upload artifact (just build)
 EOF
     exit 1
 }
@@ -34,7 +35,7 @@ do
     }
 done
 
-while getopts ":b:hs" opt; do
+while getopts ":b:hsu" opt; do
     case ${opt} in
         b ) BUCKET=${OPTARG}
             ;;
@@ -42,6 +43,8 @@ while getopts ":b:hs" opt; do
             ;;
         s ) DRY_RUN="echo "
             ;;
+        u ) NO_UPLOAD=1
+            ;;
         \?) echo "Invalid Option: -${OPTARG}" 1>&2; exit 1
             ;;
     esac
@@ -53,6 +56,7 @@ TAG="gonitro/docker-gc-build:${COMMIT}"
 AWS_REGION=us-west-2
 BUCKET=${BUCKET:-nitro-apt-repo}
 DRY_RUN=${DRY_RUN:-}
+NO_UPLOAD=${NO_UPLOAD:-}
 KEYSERVER=${KEYSERVER:-pgpkeys.eu}
 NITRO_GPG_KEY=$(gpg \
     --keyserver "${KEYSERVER}" \
@@ -74,12 +78,14 @@ $DRY_RUN docker run -v /tmp/:/tmp "${TAG}" /bin/bash -c 'cp /docker-gc*.deb /tmp
 package=$(ls /tmp/*.deb || :)
 printf "[+] Debian Package generated into '%s'\n" "${package}"
 
+if [[ -z ${NO_UPLOAD} ]]; then
 $DRY_RUN deb-s3 upload \
-    --access-key-id=${AWS_ACCESS_KEY_ID} \
-    --secret-access-key=${AWS_SECRET_ACCESS_KEY} \
-    --s3-region=${AWS_REGION} \
-    --bucket=${BUCKET} \
-    --sign=${NITRO_GPG_KEY} ${package} || exit 1
-printf "[+] Successfully uploaded package into %s\n" ${BUCKET}
+    --access-key-id="${AWS_ACCESS_KEY_ID}" \
+    --secret-access-key="${AWS_SECRET_ACCESS_KEY}" \
+    --s3-region="${AWS_REGION}" \
+    --bucket="${BUCKET}" \
+    --sign="${NITRO_GPG_KEY}" "${package}" || exit 1
+printf "[+] Successfully uploaded package into '%s'\n" "${BUCKET}"
+fi
 
 exit 0