@@ -25,6 +25,11 @@ get_current_version_by_makefile() {
2525 grep ' ^VERSION=[0-9[:alpha:].-]*$' Makefile | sed s/VERSION=//g
2626}
2727
28+ get_base_version_by_makefile () {
29+ BASE_VERSION=$( grep ' ^BASE_VERSION=[0-9[:alpha:].-]*$' Makefile | sed s/BASE_VERSION=//g)
30+ echo " ${BASE_VERSION} "
31+ }
32+
2833get_current_version_by_dogu_json () {
2934 jq " .Version" --raw-output dogu.json
3035}
@@ -52,24 +57,47 @@ validate_new_version() {
5257
5358start_git_flow_release () {
5459 local NEW_RELEASE_VERSION=" ${1} "
60+ local BASE_RELEASE_VERSION=" ${2} "
61+ local BASE_DEV_BRANCH_NAME
62+
5563 # Do gitflow
5664 git flow init --defaults --force
5765
5866 local mainBranchExists
5967 mainBranchExists=" $( git show-ref refs/remotes/origin/main || echo " " ) "
60- if [ -n " $mainBranchExists " ]; then
61- echo ' Using "main" branch for production releases'
62- git flow config set master main
63- git checkout main
64- git pull origin main
68+ if [[ -z " $BASE_RELEASE_VERSION " ]]; then
69+ echo " BASE_RELEASE_VERSION variable is empty"
70+ if [ -n " $mainBranchExists " ]; then
71+ echo ' Using "main" branch for production releases'
72+ git flow config set master main
73+ git checkout main
74+ git pull origin main
75+ else
76+ echo ' Using "master" branch for production releases'
77+ git checkout master
78+ git pull origin master
79+ fi
80+ BASE_DEV_BRANCH_NAME=" develop"
6581 else
66- echo ' Using "master" branch for production releases'
67- git checkout master
68- git pull origin master
82+ echo " BASE_RELEASE_VERSION variable is not empty"
83+ if [[ ${NEW_RELEASE_VERSION} != ${BASE_RELEASE_VERSION} * ]]; then
84+ echo " ERROR: Release version (${NEW_RELEASE_VERSION} ) does not start with base version (${BASE_RELEASE_VERSION} )"
85+ exit 1
86+ fi
87+
88+ BASE_MAIN_BRANCH_NAME=" ${BASE_RELEASE_VERSION} /main"
89+ echo " Using ${BASE_MAIN_BRANCH_NAME} branch for production releases"
90+ git flow config set master ${BASE_MAIN_BRANCH_NAME}
91+ git checkout ${BASE_MAIN_BRANCH_NAME}
92+ git pull origin ${BASE_MAIN_BRANCH_NAME}
93+ BASE_DEV_BRANCH_NAME=" ${BASE_RELEASE_VERSION} /develop"
6994 fi
7095
71- git checkout develop
72- git pull origin develop
96+ git flow config set develop ${BASE_DEV_BRANCH_NAME}
97+
98+ git checkout ${BASE_DEV_BRANCH_NAME}
99+ git pull origin ${BASE_DEV_BRANCH_NAME}
100+ git flow config
73101 git flow release start v" ${NEW_RELEASE_VERSION} "
74102}
75103
@@ -81,8 +109,17 @@ start_dry_run_release() {
81109
82110abort_dry_run_release () {
83111 local NEW_RELEASE_VERSION=" ${1} "
112+ local BASE_RELEASE_VERSION=" ${2} "
113+
114+ local BASE_DEV_BRANCH_NAME
115+
116+ if [[ -z " $BASE_RELEASE_VERSION " ]]; then
117+ BASE_DEV_BRANCH_NAME=" develop"
118+ else
119+ BASE_DEV_BRANCH_NAME=" ${BASE_RELEASE_VERSION} /develop"
120+ fi
84121
85- git checkout develop
122+ git checkout ${BASE_DEV_BRANCH_NAME}
86123 git branch -D dryrun/v" ${NEW_RELEASE_VERSION} "
87124}
88125
@@ -302,12 +339,22 @@ show_diff() {
302339finish_release_and_push () {
303340 local CURRENT_VERSION=" ${1} "
304341 local NEW_RELEASE_VERSION=" ${2} "
342+ local BASE_RELEASE_VERSION=" ${3} "
305343
306344 # Push changes and delete release branch
307345 wait_for_ok " Upgrade from version v${CURRENT_VERSION} to version v${NEW_RELEASE_VERSION} finished. Should the changes be pushed?"
308346 git push origin release/v" ${NEW_RELEASE_VERSION} "
309347
310348 echo " Switching back to develop and deleting branch release/v${NEW_RELEASE_VERSION} ..."
311- git checkout develop
349+
350+ local BASE_DEV_BRANCH_NAME
351+
352+ if [[ -z " $BASE_RELEASE_VERSION " ]]; then
353+ BASE_DEV_BRANCH_NAME=" develop"
354+ else
355+ BASE_DEV_BRANCH_NAME=" ${BASE_RELEASE_VERSION} /develop"
356+ fi
357+
358+ git checkout ${BASE_DEV_BRANCH_NAME}
312359 git branch -D release/v" ${NEW_RELEASE_VERSION} "
313360}
0 commit comments