forked from django-cms/django-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-release
executable file
·291 lines (229 loc) · 9.51 KB
/
make-release
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/bin/bash
#
# This script is only meant to be used by release managers.
# It assumes the following:
# 1. you have a github fork on the ready where you can push&pull
# 2. you can push new refs to djangoCMS origin
# 3. you have a transifex account with access to djangoCMS project
#
# License: MIT
set -e
base_branch=develop
upstream_source=git@github.com:django-cms/django-cms.git
upstream_pattern='github\.com.django-cms/django-cms\.git$'
SCRIPTS=$(dirname "$(realpath "$0")")
#shellcheck disable=SC1090
source "${SCRIPTS}/functions"
# Preparations:
# checking we have all necessary tools
check_command_exists python git awk sed pip npm xargs grep "${EDITOR}"
load_nvm
# -- argument checks
FULL_VERSION=$1
if [ -z "$1" ]; then
error "Missing version argument:"
echo "Usage: "
echo ""
echo "$0 <VERSION>[suffix] [branch]"
echo ""
echo "example:"
echo "$0 3.9.0 rc1"
exit 1
fi
if [ -n "$2" ]; then
base_branch="$2"
if ! git branch -a | grep -q "${base_branch}\$"; then
error "Can not find specified base branch ${base_branch}"
exit 1
fi
fi
check_version_string "${FULL_VERSION}"
VERSION=$(get_main_version "${FULL_VERSION}")
VERSUFFIX=$(get_version_suffix "${FULL_VERSION}")
BRANCH_SUFFIX=$(echo "${FULL_VERSION}" | awk -F '.' -e '{print $1 "." $2 ".x"}')
BRANCH="release/${BRANCH_SUFFIX}"
TAG="${FULL_VERSION}"
COMMIT_PREFIX="[${FULL_VERSION} release process] "
# Sanity checks:
if [ ! -d .git ] || [ ! -d "cms" ]; then
error "Must be a django-cms source repo, can not find .git or 'cms'... aborting"
exit 1
fi
# check that git is configured for commit
if ! git config user.name >/dev/null || ! git config user.email >/dev/null; then
error "Git must be configured for commit, please run the following commands first:"
echo ""
echo 'git config --local user.email "you@example.com"'
echo 'git config --local user.name "Your Name"'
echo ""
echo "or use --global to configure your git for all repo by default"
exit 1
fi
origin=$(git remote -v | grep push | grep origin | awk '{print $2}')
if [ -z "${origin}" ]; then
error "no 'origin' remote configured, please configure the origin to your fork"
exit 1
fi
if echo "${origin}" | grep -q "${upstream_pattern}"; then
error "please configure the origin to your fork, not official django CMS origin ${origin}"
exit 1
fi
check_virtual_env
# bump the version
current_branch=$(git branch --show-current)
if [ "${current_branch}" != "${base_branch}" ]; then
echo -e "${RED}**WARNING**: ${NORMAL}Branch mismatch:"
echo -e "You appear to be on branch ${RED}${current_branch}${NORMAL} but will create the release from ${YELLOW}${base_branch}${NORMAL}"
echo "do you want to checkout ${base_branch}?"
echo -e "${BLUE}Enter${NORMAL} to checkout ${base_branch} now, Ctrl-C to abort"
read -r
git checkout "${base_branch}"
fi
OLDVER=$(python -c "import cms; print(cms.__version__)" )
if [ -z "$(git tag -l "${OLDVER}")" ]; then
error "Can not find tag for version ${OLDVER} aborting ..."
exit 1
fi
# check if the tag does not already exist
if git tag | grep -q "\<${TAG}\>"; then
error "It appears tag ${TAG} already exists! aborting"
exit 1
fi
##
## Let's roll it
##
status "****************************************************************************************"
status "*** django CMS OFFICIAL RELEASE PROCESS ***"
status "****************************************************************************************"
echo ""
echo -e "${RED}WARNING!${NORMAL} This script will ${RED}REVERT ALL LOCAL MODIFICATIONS!${NORMAL}"
echo ""
echo -e "Preparing to create a release ${GREEN}${VERSION}${VERSUFFIX}${NORMAL} from content of ${YELLOW}${base_branch}${NORMAL} (currently version ${YELLOW}${OLDVER}${NORMAL})"
echo "using fork: ${origin}"
echo ""
status "(Ctrl-C to abort, ${BLUE}Enter${YELLOW} to continue)"
read -r
# checkinrg upstream really point to djangoCMS
status "- Setting up upstream to ${upstream_source}"
upstream=$(git remote -v | grep fetch | grep upstream | awk '{print $2}')
if [ "${upstream_source}" != "${upstream}" ]; then
if [ -n "${upstream}" ]; then
git remote remove upstream
fi
git remote add upstream ${upstream_source}
fi
status "- Cleaning the environment:"
# first go to ${base_branch} (default is develop) and ensure we got the latest and greatest
git clean -dfx
git restore --staged .
git checkout .
git pull upstream "${base_branch}"
# installing needed nodejs module
status "- syncing fork"
# updating the local repository, and pushing this to fork
git pull upstream "${base_branch}"
git push -u origin "${base_branch}"
status "- preparing branch ${BRANCH}"
# checking if the branch exists?
if ! git branch -a | grep -q "remotes/upstream/${BRANCH}\$"; then
git checkout -b "${BRANCH}"
git push upstream "${BRANCH}"
else
echo "You appear to already have a ${BRANCH} created, using it"
git checkout "${BRANCH}"
git pull upstream "${BRANCH}"
fi
# cleaning on the branch
git clean -f
git checkout .
# ensuring we have the proper env installed in pip
"${SCRIPTS}/prepare-buildenv"
cd cms
# 2.2: make messages and push them
status "- Creating transifex messages!"
"$SCRIPTS/transifex-send-strings"
git diff-index --quiet HEAD locale || git commit locale -m "${COMMIT_PREFIX}Building locales"
echo ""
status "****************************************************************************************"
status "*** Preparing for actual release!! ***"
status "****************************************************************************************"
echo ""
echo -e " This is your ${RED}LAST CHANCE TO CANCEL${NORMAL}"
echo -e "(Ctrl-C to cancel, ${BLUE}Enter${NORMAL} to continue)"
read -r
# 2.3 Check sphinx configuration (check the doc for version or things should not be there)
# Trigger a travis build on the current develop state
status "- Bumping version to ${FULL_VERSION}"
# bump the version
sed -i __init__.py -e "s/__version__ = '.*'/__version__ = '$FULL_VERSION'/"
git commit __init__.py -m "${COMMIT_PREFIX}Bumped version to ${FULL_VERSION}"
status "- Fetching strings from transifex"
"${SCRIPTS}/transifex-pull-strings"
# Before compiling:
# ignore changesets that only involeves "^POT-Creation-Date:" "^PO-Revision-Date:"
git diff-index --quiet HEAD locale || git commit locale -m "${COMMIT_PREFIX}compilemessages"
cd ..
status "- generating assets/static"
gulp icons
gulp sass
gulp bundle
# remove old versions
git rm -rf "cms/static/cms/css/${OLDVER}" "cms/static/cms/fonts/${OLDVER}" "cms/static/cms/js/dist/${OLDVER}"
git add "cms/static/cms/css/${FULL_VERSION}" "cms/static/cms/fonts/${FULL_VERSION}" "cms/static/cms/js/dist/${FULL_VERSION}"
git commit cms/static -m "${COMMIT_PREFIX}compiling new static files"
status "- preparing documentation"
"${SCRIPTS}/make-changelog" "${FULL_VERSION}"
upgrade_doc="docs/upgrade/${VERSION}.rst"
if [ ! -f "docs/upgrade/${VERSION}.rst" ]; then
echo "Creating upgrade instructions"
# looking for last upgrade by version number:
needle=$OLDVER
while [ -n "${needle}" ] && [ ! -f "docs/upgrade/${needle}.rst" ]; do
last=$(echo "${needle}" | awk -F '.' '{print $NF}')
echo "looking for docs/upgrade/${needle}.rst as base template"
if [ "${last}" -gt 0 ]; then
last=$(( last - 1 ))
#shellcheck disable=SC2001
needle=$(echo "${needle}" | sed -e "s/\.[0-9]\+\$/.${last}/")
else
#shellcheck disable=SC2001
needle=$(echo "${needle}" | sed -e 's/\.[0-9]\+$//')
fi
done
while [ ! -f "docs/upgrade/${needle}.rst" ]; do
error "Can not find docs/upgrade/${needle}.rst"
status "Can not find base version to create upgrade instructions (from $OLDVER)"
echo -e "Please ${BLUE}enter base version${NORMAL} to use (ex: 3.8) (Ctrl-C to abort)"
ls docs/upgrades/
read -r needle
done
cp "docs/upgrade/${needle}.rst" "${upgrade_doc}"
git add "docs/upgrade/${VERSION}.rst"
sed -i "${upgrade_doc}" \
-e "s/^.. _upgrade-to-.*:$/.. _upgrade-to-${VERSION}:/" \
-e "s/^${needle}.* release notes$/${VERSION} release notes/i" \
-e "s/^What's new in ${needle}.*$/What's new in ${VERSION}/i" \
-e "s/^How to upgrade to ${needle}.*$/How to upgrade to ${VERSION}/i" \
-e "s/^We assume you are upgrading from django CMS.*\.$/We assume you are upgrading from django CMS ${needle}./"
fi
if ! grep -q " *${VERSION}$" docs/upgrade/index.rst; then
status "Adding ${VERSION} to doc index"
# note: the new line in the following command is not a mistake, it is needed for sed to process the command
sed -i docs/upgrade/index.rst -e "/:maxdepth: 1/{N;a\ \ \ \ ${VERSION}
}"
fi
review CHANGELOG.rst
review "${upgrade_doc}"
review docs/upgrade/index.rst
review docs/conf.py
# commit documentations
git diff-index --quiet HEAD docs CHANGELOG.rst || git commit -m "${COMMIT_PREFIX}updating latest docs" "${upgrade_doc}" CHANGELOG.rst docs/upgrade/index.rst docs/conf.py
# update the blog post using the What's new section
status "Uploading to fork"
git push -u origin "${BRANCH}"
success "Release process complete on the fork"
echo -e "To complete the process:"
echo -e "1. ${BLUE}Please create a Pull Request${NORMAL} from your fork to ${YELLOW}${BRANCH}${NORMAL}"
echo -e "2. When the PR is merged in target branch, execute: ${BLUE}git tag ${TAG}; git push upstream ${TAG}"
echo -e "3. Create a PR from ${BRANCH} to ${base_branch} then to develop when golden release is accepted"
success "Enjoy!"