Commit 40488ef4 authored by Arnold Hendriks's avatar Arnold Hendriks

Semantic version tagging fixes

Generate semver based on branding.h number and tag
Don't compile semver into binaries, get it from buildinfo and record it into an environment variable
parent 4af4dafe
......@@ -11,6 +11,7 @@ DOCKERBUILDARGS=()
DESTDIR="`pwd`"
cd `dirname $0`
source $WEBHARE_DIR/lib/wh-functions.sh
source ./functions.sh
while [[ $1 =~ ^-.* ]]; do
......@@ -222,6 +223,7 @@ committag=$CI_COMMIT_SHA
builddate=`date +'%Y-%m-%d'`
buildtime=`date +'%H:%M:%S'`
branch=$CI_COMMIT_REF_NAME
version=$WEBHARE_VERSION
HERE
echo "Docker build args: ${DOCKERBUILDARGS[@]}"
......
# Get current version this webhare, to calculate branch head extra tag (eg 4.10)
# returns version in WHVERSION
get_whversion()
{
WHVERSION=`(awk -- '/define BLEX_BRANDING_PRODUCT_VERSION / { print $3 }' < ../../blex/branding.h) | tr -d \"`
if [ -z "$WHVERSION" ]; then
echo "Unable to retrieve version #"
exit 1
fi
}
# Get absolute path
get_absolute_path()
{
......@@ -43,10 +32,7 @@ get_finaltag()
PUSH_BUILD_IMAGES=
local MAINTAG
get_whversion
echo "WebHare version: $WHVERSION"
echo ""
getbaseversioninfo
# are we running on CI?
if [ -n "$CI_COMMIT_SHA" ]; then
......@@ -54,19 +40,33 @@ get_finaltag()
# CI may push images to the CI repos
PUSH_BUILD_IMAGES=1
# calculate main tag based on branch name
if [ "${CI_COMMIT_REF_NAME:0:8}" == "release/" ]; then
# Release branch
MAINTAG="${CI_COMMIT_REF_NAME:8}"
elif [ "${CI_COMMIT_REF_NAME:0:3}" == "rc/" ]; then
# Release branch
MAINTAG="${CI_COMMIT_REF_NAME:3}-rc"
if [ "$CI_COMMIT_TAG" != "" ]; then
if ! [[ $CI_COMMIT_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]$ ]]; then
echo "I do not understand the commit tag: $CI_COMMIT_TAG"
exit 1
fi
# we are building a specific tag, eg 4.28.0. git tag == docker tag == calculated semantic version
MAINTAG=$CI_COMMIT_TAG
if [ "$MAINTAG" != "$WEBHARE_VERSION" ]; then
echo "Expected to be tagged '$WEBHARE_VERSION' but the tag was '$MAINTAG'"
exit 1
fi
elif [ "${CI_COMMIT_REF_NAME:0:8}" == "release/" ]; then
# Release branch - eg release/4.27.
MAINTAG="${CI_COMMIT_REF_NAME:8}-prerelease" #Push as webhare/platform:4.27-prerelease
WEBHARE_VERSION=${WEBHARE_VERSION}-prerelease #Name eg 4.27.2-prerelease
elif [ "${CI_COMMIT_REF_NAME}" == "master" ]; then
# Master branch
MAINTAG="master"
WEBHARE_VERSION=${WEBHARE_VERSION}-master
elif [ "${CI_COMMIT_REF_NAME:0:7}" == "custom/" ]; then
# Custom builds
MAINTAG="${CI_COMMIT_REF_NAME:7}" #Push as webhare/platform:<customtag>
WEBHARE_VERSION="${WEBHARE_VERSION}-${CI_COMMIT_REF_NAME:7}"
else
# Other branch
MAINTAG="$CI_COMMIT_REF_SLUG"
WEBHARE_VERSION="${WEBHARE_VERSION}-$CI_COMMIT_REF_SLUG"
fi
# check if there is a CI registry
......@@ -88,6 +88,8 @@ get_finaltag()
BUILD_IMAGE="webhare/webhare-extern:localbuild${WEBHARE_LOCALBUILDIMAGEPOSTFIX}"
fi
echo "Semantic version: $WEBHARE_VERSION"
echo ""
echo "Building images with tags:"
echo "BUILD_IMAGE= $BUILD_IMAGE"
echo ""
......
#include <ap/libwebhare/allincludes.h>
#include <blex/branding.h>
#include <blex/path.h>
#include <blex/logfile.h>
#include <blex/getopt.h>
......@@ -62,7 +61,7 @@ int DBServer::Execute (std::vector<std::string> const &args)
if (!optparse.Parse(args))
{
std::cerr << "WebHare database server " << BLEX_BRANDING_PRODUCT_VERSION << "\n\nSyntax: dbserver [options]\n\n";
std::cerr << "Syntax: dbserver [options]\n\n";
// --xxxxxxxxxxxxxxxxxxxxxxxxx ddddddddddddddddddddddddddddddddddddddddddddddd\n
std::cerr << "--restore <file> Restore the backup starting with file <file>\n";
......
......@@ -649,7 +649,6 @@ void PUB_GetPublisherState(HSVM *vm, HSVM_VariableId id_set)
void SYS_WebHareVersion(HSVM *vm, HSVM_VariableId id_set)
{
HSVM_SetDefault(vm, id_set, HSVM_VAR_Record);
HSVM_StringSetSTD(vm, HSVM_RecordCreate(vm, id_set, HSVM_GetColumnId(vm, "VERSION")), BLEX_BRANDING_PRODUCT_VERSION);
HSVM_IntegerSet(vm, HSVM_RecordCreate(vm, id_set, HSVM_GetColumnId(vm, "VERSIONNUM")), BLEX_BRANDING_PRODUCT_VERSION_NUMBER);
}
......
......@@ -11,7 +11,6 @@
#include <cstdio>
#include <csignal>
#include <ap/libwebhare/whcore.h>
#include <blex/branding.h>
#include <blex/threads.h>
#include <blex/path.h>
#include <blex/pipestream.h>
......@@ -399,7 +398,7 @@ void WHService::MainLoop()
Blex::DateTime nextcompileservercheck = now + Blex::DateTime::Msecs(50);
Blex::DateTime nextlogflush = now + Blex::DateTime::Seconds(3);
Log(ServiceManager, "Starting service (" BLEX_BRANDING_PRODUCT_VERSION " " + Blex::GetEnvironVariable("WEBHARE_DISPLAYBUILDINFO") + ")");
Log(ServiceManager, "Starting service (" + Blex::GetEnvironVariable("WEBHARE_DISPLAYBUILDINFO") + ")");
ReadKeyConfig();
......
......@@ -2,6 +2,5 @@
#define blex_branding
#define BLEX_BRANDING_PRODUCT_VERSION_NUMBER 42800
#define BLEX_BRANDING_PRODUCT_VERSION "4.28.0" //Semantic version of the above number
#endif
......@@ -385,11 +385,18 @@ setup_buildsystem()
setup_webhare_envsettings()
{
if [ -f $WEBHARE_DIR/modules/system/whres/buildinfo ]; then
export WEBHARE_VERSION=$( source $WEBHARE_DIR/modules/system/whres/buildinfo ; echo -n "$version" )
export WEBHARE_DISPLAYBUILDINFO=$(
source $WEBHARE_DIR/modules/system/whres/buildinfo
echo -n "branch $branch, commit ${committag:0:10}"
)
else
getbaseversioninfo
if [ -z "$WEBHARE_VERSION" ]; then
echo Cannot determine WebHare version
exit 1
fi
export WEBHARE_VERSION="${WEBHARE_VERSION}-dev"
export WEBHARE_DISPLAYBUILDINFO=$(
cd $WEBHARE_DIR
GIT_HEAD_SHA1=$(git rev-parse HEAD)
......@@ -715,6 +722,7 @@ case $INSTR in
getwhparameters
setup_webhare_envsettings "$DEBUGTAGS"
echo "WebHare version: $WEBHARE_VERSION"
if [ "$DEBUGTAGS" == "" ]; then
# no processing needed, just exec
......
getbaseversioninfo()
{
local WHNUMERICVERSION
WHNUMERICVERSION=`(awk -- '/define BLEX_BRANDING_PRODUCT_VERSION_NUMBER / { print $3 }' < $WEBHARE_CHECKEDOUT_TO/blex/branding.h)`
if [ -z "$WHNUMERICVERSION" ]; then
echo "Unable to retrieve version # from branding.h"
exit 1
fi
WEBHARE_VERSION=${WHNUMERICVERSION:0:1}.$((${WHNUMERICVERSION:1:2})).$((${WHNUMERICVERSION:3:2}))
}
loadshellconfig()
{
if [ -n "$LOADEDSHELLCONFIG" ]; then
......
......@@ -33,6 +33,9 @@ The user currently accessing the server. You should ensure this is set to the us
### WEBHARE_IN_DOCKER
Set if we're running inside a docker environment, and not from a source installation
### WEBHARE_VERSION
Current semantic WebHare version number, eg 4.27.0
## Tweaks
### WEBHARE_CHECKEDOUT_TO
......
......@@ -73,14 +73,17 @@ PUBLIC RECORD FUNCTION GetWebhareVersionInfo()
}
}
RETURN CELL[ ...__SYSTEM_WEBHAREVERSION()
, builddate := ""
, buildtime := ""
, branch := ""
, committag := ""
, ...buildinfo
, docker := GetEnvironmentVariable("WEBHARE_IN_DOCKER") != ""
];
RECORD versioninfo := CELL[ ...__SYSTEM_WEBHAREVERSION()
, builddate := ""
, buildtime := ""
, branch := ""
, committag := ""
, ...buildinfo
, docker := GetEnvironmentVariable("WEBHARE_IN_DOCKER") != ""
, version := GetEnvironmentVariable("WEBHARE_VERSION")
];
RETURN versioninfo;
}
/** @short Is a specific module installed ?
......@@ -107,7 +110,7 @@ PUBLIC STRING FUNCTION GetModuleStorageRoot(STRING modulename)
@return The WebHare version (eg "WebHare Platform v4.26.3") */
PUBLIC STRING FUNCTION GetWebhareVersion()
{
RETURN "WebHare Platform " || __SYSTEM_WEBHAREVERSION().version;
RETURN "WebHare Platform " || GetWebhareVersionInfo().version;
}
/** @short Get the version number of this WebHare installation
@return The WebHare version number (eg 42603 for version 4.26.3) */
......
......@@ -101,7 +101,7 @@ PUBLIC RECORD FUNCTION GetcachedWebHareConfig()
PUBLIC RECORD FUNCTION GetMyApplicabilityInfo()
{
RETURN [ versionnum := __SYSTEM_WEBHAREVERSION().versionnum
, version := __SYSTEM_WEBHAREVERSION().version
, version := GetEnvironmentVariable("WEBHARE_VERSION")
, dtapstage := GetDtapStage()
, installationtype := IsRestoredWebHare() ? "restore" : "production"
, servername := GetEnvironmentVariable("WEBHARE_SERVERNAME") ?? GetcachedWebHareConfig().servername
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment