This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
releasing.sh
executable file
·132 lines (110 loc) · 4.27 KB
/
releasing.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
# Requires: Perl, git-review, tox, and osa-toolkit from https://github.com/evrardjp/osa_toolkit installed
# This doesn't work on fish shell anymore.
set -o errexit
set -o nounset
WORKDIR="${WORKDIR:-/tmp/releases}"
REPOS_GIT_URL="https://github.com/openstack"
OSA_FOLDER=${WORKDIR}/openstack-ansible
RELEASES_FOLDER=${WORKDIR}/releases
RELEASINGLOG=${WORKDIR}/releasing.log
RELEASECOMMITMSG=${WORKDIR}/commitmsg_releases.txt
OACOMMITMSG=${WORKDIR}/commitmsg_OA.txt
function cleanupenv {
unset BRANCH
unset CURRENT_RELEASE
unset RELEASE_CHANGEID
unset release_changeid
unset NEXT_RELEASE
unset next_release
}
function cleanup {
rm -rf ${RELEASES_FOLDER}
rm -rf ${OSA_FOLDER}
}
function clone {
mkdir -p ${WORKDIR}
cd $WORKDIR
git clone ${REPOS_GIT_URL}/releases.git
git clone ${REPOS_GIT_URL}/openstack-ansible.git
}
function new_release {
local BRANCHNAME=$1
cd $RELEASES_FOLDER
tox -e venv -- new-release $BRANCHNAME openstack-ansible bugfix | tee -a ${RELEASINGLOG}
}
function ask_ready_to_review {
local folder=$1
local commitmsgfile=$2
echo "Please checkout a new branch, edit the files, git add, and git commit -F ${commitmsgfile} in $folder."
read -rp $'Are you ready to send review? (Y/n) : ' -ei $'Y' key;
if [[ "$key" == "Y" ]]
then
cd $folder
git review -f -t release_osa | tee -a ${RELEASINGLOG}
cd -
else
echo "Not Ready, not sending review. Please send review manually."
exit 1
fi
}
function parse_release_log {
export CURRENT_RELEASE=$(perl -n -e'/going from.*to (.*)$/ && print "$1\n"' ${RELEASINGLOG} | tail -n 1)
echo "Release OpenStack-Ansible ${BRANCH}/${CURRENT_RELEASE}" > ${RELEASECOMMITMSG}
}
function parse_gitreview_log {
export RELEASE_CHANGEID=$(perl -n -e '/remote.*(https.*review.openstack.org\/\d+)/ && print "$1\n"' ${RELEASINGLOG} | tail -n 1)
echo "Found git review url: $RELEASE_CHANGEID"
}
function write_commit_msg {
cat > ${OACOMMITMSG} << EOCOMMIT
Bump version to ${next_release:-'next release'}
Depends-On: ${RELEASE_CHANGEID}
EOCOMMIT
}
function rollback_time {
cd $1
git checkout -- . || true
git reset HEAD^ --hard || true
git pull
}
function release_branch {
cleanupenv
export BRANCH=$1
#################
# Releases repo #
#################
rollback_time ${WORKDIR}/releases # In case something was wrongly done on master, come back in time.
git checkout -b release_osa # Create a new branch for doing the release
new_release $BRANCH # Uses's releases' tox tool to produce a release.
parse_release_log # Get current's code version by parsing "next release" element from releases repo
ask_ready_to_review ${WORKDIR}/releases ${RELEASECOMMITMSG} # Wait for user editions and confirmations before git review -f
parse_gitreview_log # Get review change id for the depends on.
# If you already did the releases folder part, just comment out the
# above section, and export the release change details for the
# depends on, like this:
# export RELEASE_CHANGEID="https://review.openstack.org/#/c/584787/"
rollback_time ${WORKDIR}/releases # In case something was wrongly done on master, come back in time.
##########################
# OpenStack-Ansible repo #
##########################
# Cleanup the repo. Making sure it looks like a fresh git cloned repo.
cd $OSA_FOLDER
git remote rm gerrit || true
git checkout origin/master
git branch -D stable/$BRANCH || true
git checkout -b stable/$BRANCH -t origin/stable/$BRANCH || true # Ensure the work of OSA toolkit is done on the right branch.
git pull # Ensure said branch is up to date.
osa releases bump_release_number | tee -a ${RELEASINGLOG}
export next_release=$(tail -n 1 ${RELEASINGLOG} | cut -d ' ' -f 4)
git checkout -b release_osa
write_commit_msg # Prepare an example commit message.
ask_ready_to_review ${WORKDIR}/openstack-ansible ${OACOMMITMSG} # Wait for user editions and confirmations before git review -f
rollback_time ${WORKDIR}/openstack-ansible # In case something was wrongly done on master, come back in time
}
cleanup
clone
release_branch rocky
release_branch queens
release_branch pike
#release_branch ocata