Add: feature to build a specific tag

This commit is contained in:
leafee98 2023-01-21 11:17:08 -05:00
parent ef5f2d5ff3
commit 1f844d0e35

View file

@ -10,6 +10,7 @@ PACK_DIR="${SCRIPT_PATH}/package"
BUILD_DIR="$REPO_DIR/bin" BUILD_DIR="$REPO_DIR/bin"
ROOTFS="${SCRIPT_PATH}/rootfs" ROOTFS="${SCRIPT_PATH}/rootfs"
TARGET_TAG=""
ACTION="initialze" ACTION="initialze"
@ -24,17 +25,22 @@ function usage()
{ {
echo "$0 usage:" echo "$0 usage:"
echo " -b the build release number" echo " -b the build release number"
echo " -t specify the tag to build, instead of the latest one"
} }
BUILD_REL="" BUILD_REL=""
while getopts ":b" arg while getopts ":b:t:" arg
do do
case "$arg" in case "$arg" in
b) b)
BUILD_REL="$OPTARG" BUILD_REL="$OPTARG"
;; ;;
t)
TARGET_TAG="$OPTARG"
;;
*) *)
usage usage
exit 1
;; ;;
esac esac
done done
@ -51,9 +57,18 @@ function download()
git -C "$REPO_DIR" fetch --all git -C "$REPO_DIR" fetch --all
fi fi
LATEST_TAG=$(git -C "$REPO_DIR" tag --sort=-version:refname --list 'v*' | head -n 1) }
echo "switching to tag: $LATEST_TAG"
git -C "$REPO_DIR" switch --detach "$LATEST_TAG" function switch_tag()
{
ACTION="switch tag"
if [ -z "$TARGET_TAG" ]
then
TARGET_TAG=$(git -C "$REPO_DIR" tag --sort=-version:refname --list 'v*' | head -n 1)
fi
echo "switching to tag: $TARGET_TAG"
git -C "$REPO_DIR" switch --detach "$TARGET_TAG"
} }
function build() function build()
@ -100,6 +115,7 @@ EOF
download download
switch_tag
build build
package package