Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion versions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ outputs:
description: The latest version of the current major
value: ${{ steps.get-versions.outputs.CUR_MAJOR_MAX_TAG }}
next-minor:
description: The next minor version
description: The next minor version that will be split off from trunk
value: ${{ steps.get-versions.outputs.NEXT_MINOR }}
splitted-minor:
description: The latest minor version that is already splitted from trunk, this minor might not be released yet
value: ${{ steps.get-versions.outputs.SPLITTED_MINOR }}
next-patch:
description: The next patch version
value: ${{ steps.get-versions.outputs.NEXT_PATCH }}
Expand Down
23 changes: 15 additions & 8 deletions versions/print_versions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,36 @@ CUR_MAJOR="v${CUR_MAJOR#v}"

get_tags() {
git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/shopware/shopware 2>/dev/null |
cut --delimiter='/' --fields=3 | grep -v -i -E '(dev|beta|alpha)'
cut -d '/' -f 3 | grep -v -i -E '(dev|beta|alpha)'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other format was not compatible with the cut implementation i had installed, so i assume this should have broader compatibility

}

get_tags_without_rc() {
git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/shopware/shopware 2>/dev/null |
cut --delimiter='/' --fields=3 | grep -v -i -E 'rc'
cut -d '/' -f 3 | grep -v -i -E 'rc'
}

get_next_minor_and_patch() {
DAY_OF_WEEK=$(date --utc +%u) # 1=Monday, 7=Sunday
DAY_NEXT_MONDAY=$(date --utc --date="+$((8 - ${DAY_OF_WEEK})) days" +%d)

version=${1}
local max_tag=$(get_tags_without_rc | grep -E "^${version}" | tail -n 1)
if [[ -z $max_tag ]]; then
max_tag=$(get_tags | grep -E "^${version}" | tail -n 1)
fi
IFS='.' read -r -a parts <<<"${max_tag}"
if [ "$DAY_NEXT_MONDAY" -lt 7 ]; then
echo "NEXT_MINOR=${parts[0]}.${parts[1]}.$((${parts[2]} + 2)).0"
else

# check if release branch already exists for 2 minor versions ahead
# if that is the case, that is the next minor release, as the final branch split for the version 1 minor ahead did already happen
NEXT_MINOR_RELEASE="${parts[0]}.${parts[1]}.$((${parts[2]} + 2)).x"
NEXT_MINOR_RELEASE="${NEXT_MINOR_RELEASE:1}" # remove leading 'v'
local branch_exists=$(git ls-remote --heads https://github.com/shopware/shopware ${NEXT_MINOR_RELEASE})

if [[ -z ${branch_exists} ]]; then
echo "NEXT_MINOR=${parts[0]}.${parts[1]}.$((${parts[2]} + 1)).0"
echo "SPLITTED_MINOR=${parts[0]}.${parts[1]}.$((${parts[2]})).0"
else
echo "NEXT_MINOR=${parts[0]}.${parts[1]}.$((${parts[2]} + 2)).0"
echo "SPLITTED_MINOR=${parts[0]}.${parts[1]}.$((${parts[2]} + 1)).0"
fi

echo "NEXT_PATCH=${parts[0]}.${parts[1]}.${parts[2]}.$((${parts[3]} + 1))"

local max_lts_tag=$(get_tags_without_rc | grep -E "^${PREV_MAJOR}" | tail -n 1)
Expand Down