Skip to content

Commit

Permalink
scripts: imp code
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Feb 13, 2024
1 parent a5bed23 commit f096505
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions scripts/make/version.sh
Expand Up @@ -68,6 +68,15 @@ get_last_minor_zero() {
| head -n 1
}

# get_last_release returns the most recent release tag, regardless whether it's
# patch, minor, or major one.
get_last_release() {
git tag\
| grep -e 'v[0-9]\+\.[0-9]\+\.[0-9]\+$'\
| sort -k 1.2,1nr -k 2,2nr -k 3,3nr -t '.'\
| head -n 1
}

channel="${CHANNEL:?please set CHANNEL}"
readonly channel

Expand Down Expand Up @@ -132,29 +141,29 @@ in
# This pseudo-channel is used to set a proper versions into release
# candidate builds.

# last_beta is the most recent beta version git tag. Assume the release
# candidate branch is always based on the following version's beta branch
# and thus the latest beta tag will be described.
last_beta="$( git describe --abbrev=0 )"
readonly last_beta
# last_release is the name of the previous release version's tag.
last_release="$( get_last_release )"

# current_branch is the name of the branch currently checked out. It's
# assumed to be a release candidate branch and have a name like:
#
# rc-v1.23.456
#
# current_branch is the name of the branch currently checked out.
current_branch="$( git rev-parse --abbrev-ref HEAD )"
readonly current_branch

# num_commits_since_beta is the number of commits within the branch.
num_commits_since_beta="$( git rev-list --count "$last_beta".."$current_branch" )"
readonly num_commits_since_beta
# The branch should be named like:
#
# rc-v12.34.56
#
if ! echo "$current_branch" | grep -E -e '^rc-v[0-9]+\.[0-9]+\.[0-9]+$' -q
then
echo "invalid release candidate branch name '$current_branch'" 1>&2

exit 1
fi

# release_version is the final version of this release candidate.
release_version="$( echo "$current_branch" | cut -d '-' -f 2 )"
readonly release_version

version="${release_version}-rc.${num_commits_since_beta}"
version="${release_version}-rc.$( git rev-list --count "$last_release"..HEAD )"
;;
(*)
echo "invalid channel '$channel', supported values are\
Expand Down

0 comments on commit f096505

Please sign in to comment.