X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Frelease-job.sh;h=befa09bed637d07142a4c0d791e5419b31ce1043;hb=413bdb2e77dcc2055e05476930f13874a2fae244;hp=3ad45306837d13913830f2c2ab25928d9c378a7a;hpb=89144786dbd6e556bc251aeff6b397d6e28eddeb;p=releng%2Fglobal-jjb.git diff --git a/shell/release-job.sh b/shell/release-job.sh index 3ad45306..befa09be 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -11,12 +11,12 @@ echo "---> release-job.sh" set -eu -o pipefail -echo "INFO: creating virtual environment" -virtualenv -p python3 /tmp/venv -PATH=/tmp/venv/bin:$PATH -pipup="python -m pip install -q --upgrade pip idna==2.8 lftools jsonschema twine yq" -echo "INFO: $pipup" -$pipup +# shellcheck disable=SC1090 +source ~/lf-env.sh + +# Version controlled by JJB_VERSION +lf-activate-venv lftools pip idna==2.9 lftools jsonschema twine yq readline + # show installed versions python -m pip --version python -m pip freeze @@ -81,6 +81,7 @@ set_variables_common(){ printf "\t%-30s %s\n" PROJECT-DASHED: "${PROJECT//\//-}" printf "\t%-30s %s\n" TAG_RELEASE: "$TAG_RELEASE" printf "\t%-30s %s\n" DISTRIBUTION_TYPE: "$DISTRIBUTION_TYPE" + printf "\t%-30s %s\n" OVERRIDE_SEMVER_REGEX: "${OVERRIDE_SEMVER_REGEX:-None}" } set_variables_maven(){ @@ -216,15 +217,26 @@ verify_schema(){ } verify_version(){ - # Verify allowed patterns "#.#.#" (SemVer) or "v#.#.#" + + # Override the regex for projects that do not follow https://semver.org + OVERRIDE_SEMVER_REGEX="${OVERRIDE_SEMVER_REGEX:-None}" + if [[ $OVERRIDE_SEMVER_REGEX == "None" ]]; then + # Use the semver regex taken from https://github.com/fsaintjacques/semver-tool + semver_regex="^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" + else + semver_regex="${OVERRIDE_SEMVER_REGEX}" + fi + + # Verify SemVer "#.#.#" (SemVer) or "v#.#.#" echo "INFO: Verifying version $VERSION" - allowed_version_regex="^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" - if [[ $VERSION =~ $allowed_version_regex ]]; then + if [[ $VERSION =~ $semver_regex ]]; then echo "INFO: The version $VERSION is valid" else echo "ERROR: The version $VERSION is not valid" echo "ERROR: Valid versions are \"#.#.#\" (SemVer) or \"v#.#.#\"" - echo "ERROR: See https://semver.org/ for more details on SemVer" + echo "ERROR: Valid version will be matched against \"${semver_regex}\"" + echo "ERROR: Refer to https://semver.org/ for more details on SemVer" + echo "ERROR: Refer SemVer examples from https://github.com/fsaintjacques/semver-tool/#examples" exit 1 fi }