actual version bump support
This commit is contained in:
5 files changed
+351
-109
No files matched your search
@@ -2,13 +2,10 @@
|
||||
# Compute Semantic Version (SemVer 2.0.0) for Asteria Qt.
|
||||
#
|
||||
# Rules:
|
||||
# - Base version (MAJOR.MINOR.BASE_PATCH) is read from the root VERSION file.
|
||||
# - Current version (MAJOR.MINOR.PATCH) is read from the root VERSION file.
|
||||
# - On master (default branch):
|
||||
# - If HEAD already has a release tag vMAJOR.MINOR.P, reuse MAJOR.MINOR.P.
|
||||
# - Otherwise, PATCH = max(BASE_PATCH, highest existing vMAJOR.MINOR.* tag + 1).
|
||||
# - Outputs: MAJOR.MINOR.PATCH
|
||||
# - On feature branches:
|
||||
# - PATCH = max(BASE_PATCH, highest existing vMAJOR.MINOR.* tag + 1).
|
||||
# - Branch name is sanitized to lowercase [a-z0-9-] for SemVer pre-release.
|
||||
# - Outputs: MAJOR.MINOR.PATCH-<sanitized-branch>.<short-sha>
|
||||
#
|
||||
@@ -35,7 +32,7 @@ while [[ $# -gt 0 ]]; do
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
sed -n '2,18p' "$0" | sed 's/^# \{0,1\}//'
|
||||
sed -n '2,15p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
@@ -58,7 +55,7 @@ fi
|
||||
|
||||
MAJOR="${BASH_REMATCH[1]}"
|
||||
MINOR="${BASH_REMATCH[2]}"
|
||||
BASE_PATCH="${BASH_REMATCH[3]}"
|
||||
PATCH="${BASH_REMATCH[3]}"
|
||||
|
||||
# Determine current branch and short SHA
|
||||
BRANCH="${OVERRIDE_BRANCH:-${CI_COMMIT_BRANCH:-${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_REF_NAME:-}}}}"
|
||||
@@ -82,58 +79,7 @@ if [ -z "$SHORT_SHA" ]; then
|
||||
fi
|
||||
|
||||
DEFAULT_BRANCH="${CI_DEFAULT_BRANCH:-master}"
|
||||
IS_MASTER=false
|
||||
if [ "$BRANCH" = "$DEFAULT_BRANCH" ] || [ "$BRANCH" = "master" ]; then
|
||||
IS_MASTER=true
|
||||
fi
|
||||
|
||||
# Extract max patch from tags matching v?MAJOR.MINOR.PATCH (no pre-release suffix)
|
||||
max_patch_in_tags() {
|
||||
local max_p=-1
|
||||
local tag p
|
||||
while IFS= read -r tag; do
|
||||
[ -z "$tag" ] && continue
|
||||
if [[ "$tag" =~ ^v?${MAJOR}\.${MINOR}\.([0-9]+)$ ]]; then
|
||||
p="${BASH_REMATCH[1]}"
|
||||
if [ "$p" -gt "$max_p" ]; then
|
||||
max_p="$p"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$max_p"
|
||||
}
|
||||
|
||||
PATCH="$BASE_PATCH"
|
||||
|
||||
if [ "$HAS_GIT" = true ]; then
|
||||
# If on master (or detached HEAD) and HEAD is already tagged with a matching release tag, keep it
|
||||
if [ "$IS_MASTER" = true ] || [ "$BRANCH" = "HEAD" ] || [ -z "$BRANCH" ]; then
|
||||
HEAD_MAX_PATCH="$(git -C "$PROJECT_DIR" tag --points-at HEAD 2>/dev/null | max_patch_in_tags)"
|
||||
if [ "$HEAD_MAX_PATCH" -ge 0 ]; then
|
||||
if [ "$HEAD_MAX_PATCH" -ge "$BASE_PATCH" ]; then
|
||||
PATCH="$HEAD_MAX_PATCH"
|
||||
fi
|
||||
echo "${MAJOR}.${MINOR}.${PATCH}"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
REPO_MAX_PATCH="$(git -C "$PROJECT_DIR" tag -l "v${MAJOR}.${MINOR}.*" "${MAJOR}.${MINOR}.*" 2>/dev/null | max_patch_in_tags)"
|
||||
if [ "$REPO_MAX_PATCH" -ge 0 ]; then
|
||||
NEXT_PATCH=$((REPO_MAX_PATCH + 1))
|
||||
if [ "$NEXT_PATCH" -gt "$PATCH" ]; then
|
||||
PATCH="$NEXT_PATCH"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$IS_MASTER" = true ]; then
|
||||
echo "${MAJOR}.${MINOR}.${PATCH}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Non-git fallback if branch couldn't be determined
|
||||
if [ -z "$BRANCH" ]; then
|
||||
if [ "$BRANCH" = "$DEFAULT_BRANCH" ] || [ "$BRANCH" = "master" ] || [ -z "$BRANCH" ]; then
|
||||
echo "${MAJOR}.${MINOR}.${PATCH}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user