Adds option to use tag version when targeting a branch.

This commit is contained in:
Llewellyn van der Merwe 2023-02-13 23:11:17 +02:00
parent b77e7ab45d
commit 050be81a73
Signed by: Llewellyn
GPG Key ID: A9201372263741E7

View File

@ -385,7 +385,7 @@ function setFiles() {
[ -z "${VDM_PACKAGE_VERSION}" ] && [ -z "${VDM_PACKAGE_VERSION}" ] &&
[ "${VDM_PACKAGE_VERSION_ID}" = "${VDM_ID}" ]; then [ "${VDM_PACKAGE_VERSION_ID}" = "${VDM_ID}" ]; then
# set the package version # set the package version
VDM_PACKAGE_VERSION="${VDM_ZIP_NAME}" VDM_PACKAGE_VERSION="${VDM_ZIP_VERSION:-$VDM_ZIP_NAME}"
export VDM_PACKAGE_VERSION export VDM_PACKAGE_VERSION
fi fi
# we have a file # we have a file
@ -424,6 +424,7 @@ function clearFileEnv() {
unset VDM_MODE unset VDM_MODE
# SET IN: getFileByKey || getFileByRelease || getFileByTag # SET IN: getFileByKey || getFileByRelease || getFileByTag
unset VDM_ZIP_NAME unset VDM_ZIP_NAME
unset VDM_ZIP_VERSION
unset VDM_ZIP_MESSAGE unset VDM_ZIP_MESSAGE
unset VDM_RELEASE_ID unset VDM_RELEASE_ID
unset VDM_ASSET_ID unset VDM_ASSET_ID
@ -447,6 +448,8 @@ function getZipFile() {
return 11 return 11
fi fi
else else
# make API call
callGiteaAPI "tags" "${VDM_OWNER}" "${VDM_REPO}" "${VDM_API}" "${VDM_TOKEN}" || return 11
# get the file by key/branch/tag # get the file by key/branch/tag
getFileByKey || return 11 getFileByKey || return 11
fi fi
@ -551,6 +554,11 @@ function getFileByKey() {
VDM_ZIP_NAME="${VDM_MODE}" VDM_ZIP_NAME="${VDM_MODE}"
# get the message # get the message
VDM_ZIP_MESSAGE="${VDM_MODE}" VDM_ZIP_MESSAGE="${VDM_MODE}"
# get the name
getValueFromJson "VDM_ZIP_VERSION" ".name" "${VDM_API_BUCKET}" || {
_echo "[error] Tag name not found in VDM_API_BUCKET. (but ignored since we are getting file by key)"
VDM_ZIP_VERSION="${VDM_MODE}"
}
# download the zip file if not already set # download the zip file if not already set
if [ ! -f "${VDM_PACKAGE_SRC_DIR}/${VDM_OWNER}__${VDM_REPO}__${VDM_ZIP_NAME}.zip" ]; then if [ ! -f "${VDM_PACKAGE_SRC_DIR}/${VDM_OWNER}__${VDM_REPO}__${VDM_ZIP_NAME}.zip" ]; then
# give message # give message
@ -565,6 +573,7 @@ function getFileByKey() {
# move the tag values to global scope # move the tag values to global scope
export VDM_ZIP_NAME export VDM_ZIP_NAME
export VDM_ZIP_MESSAGE export VDM_ZIP_MESSAGE
export VDM_ZIP_VERSION
# add file to xml # add file to xml
setFileToXML setFileToXML
# update the readme # update the readme
@ -1021,7 +1030,7 @@ function setGitRepository() {
} }
# Set Git user details based on environment variables # Set Git user details based on environment variables
setUserDetails () { function setUserDetails () {
# Set Git author name # Set Git author name
if [ -n "${GIT_AUTHOR_NAME+x}" ]; then if [ -n "${GIT_AUTHOR_NAME+x}" ]; then
git config user.name "${GIT_AUTHOR_NAME}" git config user.name "${GIT_AUTHOR_NAME}"