From 97bd5bf34ae8f6432c2a6479f90571c90dd542f2 Mon Sep 17 00:00:00 2001
From: "lennart.kramer" <lennart.kramer@stud.uni-goettingen.de>
Date: Tue, 30 Aug 2022 13:46:01 +0200
Subject: [PATCH] allow tags for one stackmaxima version in build

---
 build.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/build.sh b/build.sh
index 754032f..51e5cac 100755
--- a/build.sh
+++ b/build.sh
@@ -3,11 +3,17 @@
 #
 # Run with two arguments:
 # arg1: REGISTRY or dockerhub id to use. If given, teh built container is pushed there with tag -dev.
-# arg2: goemaxima version number, used to tag the containers that are built.
+# arg2: goemaxima version number, used to tag the containers that are built. If there is a dash, then
+#       with a tag like 2022071300-1.1.5, only the container for stackmaxima version 2022071300 would
+#       be built and tagged with 2022071300-1.1.5 and 2022071300-latest
 
 REGISTRY=$1
-grep -v '^#' versions | cut -f1 | \
-while read -r ver; do
-	goemaxima_version="$2"
+# note that cut by default outputs the whole line if there is no delimiter
+goemaxima_version="$(echo "$2" | cut -f2 -d-)"
+stack_versions="$(echo "$2" | cut -f1 -d- -s)"
+if [ -z "$stack_versions" ]; then
+	stack_versions="$(grep -v '^#' versions | cut -f1)"
+fi
+for ver in $stack_versions; do
 	/bin/sh buildimage.sh "$ver" "${REGISTRY}" "$goemaxima_version" || exit 1
 done
-- 
GitLab