@@ -69,12 +69,31 @@ function update_content_file
6969 grep " counter=" ${file} | sed " s/counter=//"
7070}
7171
72+ function wait_for_pr_approval
73+ {
74+ echo
75+ echo " *** Approve the PR in github ***"
76+ echo " After that press 'c' to continue"
77+ while : ; do
78+ read -n 1 key
79+ if [[ " $key " == " c" ]]; then
80+ echo -e " \nContinuing..."
81+ break
82+ fi
83+ done
84+ }
85+
86+ function increment_version {
87+ local current_tag=" $1 "
88+ echo " $current_tag " | sed -E ' s/([0-9]+)$/echo $((\1+1))/e'
89+ }
90+
7291main ()
7392{
7493 check_arguments " $@ "
7594
76- echo ; echo " *** Create a branch, update source and make a pull-request"
77- git checkout -b ${BRANCH_NAME} -demo
95+ echo ; echo " *** Create a branch, update source and make a squash pull-request"
96+ git checkout -b ${BRANCH_NAME} -demo-1
7897 FE_VER=$( update_content_file src/frontend.txt)
7998 git add src
8099 git commit -m " ${BRANCH_NAME} Updated SW frontend=${FE_VER} "
@@ -84,61 +103,32 @@ main()
84103 git push; wait_for_github_actions
85104 gh pr create --fill
86105
106+ wait_for_pr_approval
107+ gh pr merge --auto --squash --delete-branch --subject " ${BRANCH_NAME} Updated SW frontend=${FE_VER} "
108+ wait_for_github_actions
109+
110+ echo ; echo " *** Create a branch, update source and make a merge pull-request"
111+ git checkout -b ${BRANCH_NAME} -demo-2
112+ FE_VER=$( update_content_file src/frontend.txt)
113+ git add src
114+ git commit -m " ${BRANCH_NAME} Updated SW frontend=${FE_VER} "
115+ FE_VER=$( update_content_file src/frontend.txt)
116+ git add src
117+ git commit -m " ${BRANCH_NAME} Updated SW frontend=${FE_VER} "
118+ git push; wait_for_github_actions
119+ gh pr create --fill
87120
121+ wait_for_pr_approval
122+ gh pr merge --auto --merge --delete-branch; wait_for_github_actions
88123
124+ echo ; echo " *** Create new version tag and push ***"
125+ CURRENT_TAG=$( git describe --tags --abbrev=0)
126+ NEXT_TAG=$( increment_version ${CURRENT_TAG} )
127+ git tag -a ${NEXT_TAG} -m " Version ${NEXT_TAG} "
128+ git push origin ${NEXT_TAG}
129+ wait_for_github_actions
89130
90- # echo; echo "*** Waiting for pull request to do required checks before merge"; wait_for_github_actions
91- # gh pr merge --auto --squash --delete-branch; wait_for_github_actions
92- # echo; echo "*** Wait for build on main to finish"; wait_for_github_actions
93- # make report_all_envs > /dev/null; wait_for_github_actions
94- # echo; echo "*** SW is now running in dev. Do a deployment from dev to staging"
95- # make deploy_to_staging; wait_for_github_actions
96- # make report_all_envs > /dev/null; wait_for_github_actions
97- # echo; echo "*** Make a release candidate for SW now running in staging with Jira issue ${JIRA_KEY_1}"
98- # make generate_jira_release; wait_for_github_actions
99- #
100- # echo; echo "*** We assume the product owner found a bug and wanted a new version of the backend"
101- #
102- # echo; echo "*** Create a branch, update backend app and make a pull-request **"
103- # git checkout -b ${JIRA_KEY_2}-demo-2
104- # BE_VER=$(update_content_file apps/backend/backend-content.txt)
105- # git add apps/
106- # git commit -m "${JIRA_KEY_2} Updated SW backend=${BE_VER}"
107- # git push; wait_for_github_actions
108- # gh pr create --fill
109- # echo; echo "*** Waiting for pull request to do required checks before merge"; wait_for_github_actions
110- # gh pr merge --auto --squash --delete-branch; wait_for_github_actions
111- # echo; echo "*** Wait for build on main to finish"; wait_for_github_actions
112- # make report_all_envs > /dev/null; wait_for_github_actions
113- # echo; echo "*** Updated SW is now running in dev. Do a deployment from dev to staging"
114- # make deploy_to_staging; wait_for_github_actions
115- # make report_all_envs > /dev/null; wait_for_github_actions
116- # echo; echo "*** Update the release candidate for SW now running in staging."
117- # echo "*** This will add the second JIRA-KEY ($JIRA_KEY_2) to the Jira release"
118- # make generate_jira_release; wait_for_github_actions
119- # echo; echo "*** Check if current release candidate has been approved and can be released. This shall fail!"
120- # make check_release_to_prod; wait_for_github_actions
121- #
122- # echo; echo "*** Go to url:"
123- # echo "https://kosli-team.atlassian.net/projects/OPS?selectedItem=com.atlassian.jira.jira-projects-plugin%3Arelease-page"
124- # echo
125- # echo "Press the version you see in the list. It should only be one that is UNRELEASED"
126- # echo "On the right hand side press the + next to Approvers"
127- # echo "Add your self as an approver"
128- # echo "Change the approval from PENDING to APPROVED"
129- # echo "After that press 'c' to continue"
130- # while :; do
131- # read -n 1 key
132- # if [[ "$key" == "c" ]]; then
133- # echo -e "\nContinuing..."
134- # break
135- # fi
136- # done
137- # echo; echo "*** Check if release has been approved"
138- # make check_release_to_prod; wait_for_github_actions
139- # make report_all_envs > /dev/null; wait_for_github_actions
140- # make update_tags
141- # echo; echo "*** You can now check kosli UX to see that correct SW is running and that attestations have been done"
131+ echo ; echo " *** Release has now been created and reported to kosli ***"
142132}
143133
144134main " $@ "
0 commit comments