@@ -54,6 +54,35 @@ releaseMachineExec() {
5454 echo " Pushed ${REGISTRY} /${ORGANIZATION} /${IMAGE} :${VERSION} "
5555}
5656
57+ commitChangeOrCreatePR ()
58+ {
59+ if [[ ${NOCOMMIT} -eq 1 ]]; then
60+ echo " [INFO] NOCOMMIT = 1; so nothing will be committed. Run this script with no flags for usage + list of flags/options."
61+ else
62+ aVERSION=" $1 "
63+ aBRANCH=" $2 "
64+ PR_BRANCH=" $3 "
65+
66+ COMMIT_MSG=" chore: release: bump to ${aVERSION} in ${aBRANCH} "
67+
68+ # commit change into branch
69+ git add -A || true
70+ git commit -s -m " ${COMMIT_MSG} "
71+ git pull origin " ${aBRANCH} "
72+
73+ PUSH_TRY=" $( git push origin " ${aBRANCH} " ) "
74+ # shellcheck disable=SC2181
75+ if [[ $? -gt 0 ]] || [[ $PUSH_TRY == * " protected branch hook declined" * ]]; then
76+ # create pull request for main branch, as branch is restricted
77+ git branch " ${PR_BRANCH} "
78+ git checkout " ${PR_BRANCH} "
79+ git pull origin " ${PR_BRANCH} "
80+ git push origin " ${PR_BRANCH} "
81+ gh pr create -f -B " ${aBRANCH} " -H " ${PR_BRANCH} "
82+ fi
83+ fi
84+ }
85+
5786# derive branch from version
5887BRANCH=${VERSION% .* } .x
5988
@@ -85,6 +114,7 @@ if [[ ${NOCOMMIT} -eq 0 ]]; then
85114 git commit -s -m " ${COMMIT_MSG} " VERSION
86115 git pull origin " ${BRANCH} "
87116 git push origin " ${BRANCH} "
117+ commitChangeOrCreatePR " ${VERSION} " " ${BRANCH} " " pr-${BRANCH} -to-${NEXTVERSION} "
88118fi
89119
90120if [[ $TRIGGER_RELEASE -eq 1 ]]; then
115145# change VERSION file
116146echo " ${NEXTVERSION} " > VERSION
117147if [[ ${NOCOMMIT} -eq 0 ]]; then
118- BRANCH=${BASEBRANCH}
119- # commit change into branch
120- COMMIT_MSG=" chore: release: bump to ${NEXTVERSION} in ${BRANCH} "
121- git commit -s -m " ${COMMIT_MSG} " VERSION
122- git pull origin " ${BRANCH} "
123-
124- PUSH_TRY=" $( git push origin " ${BRANCH} " ) "
125- # shellcheck disable=SC2181
126- if [[ $? -gt 0 ]] || [[ $PUSH_TRY == * " protected branch hook declined" * ]]; then
127- PR_BRANCH=pr-main-to-${NEXTVERSION}
128- # create pull request for main branch, as branch is restricted
129- git branch " ${PR_BRANCH} "
130- git checkout " ${PR_BRANCH} "
131- git pull origin " ${PR_BRANCH} "
132- git push origin " ${PR_BRANCH} "
133- gh pr create -f -B " ${BRANCH} " -H " ${PR_BRANCH} "
134- fi
148+ commitChangeOrCreatePR " $NEXTVERSION " " $BASEBRANCH " pr-main-to-${NEXTVERSION}
135149fi
0 commit comments