forked from getnikola/nikola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease
executable file
·156 lines (128 loc) · 4.83 KB
/
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
#!/usr/bin/env zsh
# The Release Script
# Based on Python Project Template by Chris Warrick
# Copyright © 2013-2022, Chris Warrick.
# All rights reserved.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the
# Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice
# shall be included in all copies or substantial portions of
# the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
function status {
echo $@
}
function warning {
echo 'WARNING: '$@
}
function error {
echo 'ERROR: '$@
}
function cleanup {
rm -rf Nikola.egg-info build || true
rm -rf **/__pycache__ || true
}
status '*** Nikola Release Scripts'
dates=$(date '+%s')
# Make sure we're up-to-date
git checkout master
git pull origin master
echo -n "Version (in format X.Y.Z): "
read version
echo $version | grep '^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$' > /dev/null
if [[ $? != 0 ]]; then
echo $version | grep '^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\-[0-9A-Za-z-]\{1,\}$' > /dev/null
if [[ $? != 0 ]]; then
warning 'version number is not compliant with versioning scheme (Semantic Versioning 2.0)'
echo -n 'Continue? [y/N] '
read vercont
if [[ $vercont == 'y' || $vercont == 'Y' ]]; then
echo 'Continuing.'
else
exit 2
fi
else
status 'NOTICE: pre-release version number in use.'
echo -n 'Continue? [Y/n] '
read vercont
if [[ $vercont == 'n' || $vercont == 'N' ]]; then
exit 2
else
echo 'Continuing.'
fi
fi
fi
cleanup
status 'Replacing versions in files...'
sed "s/version=.*/version='$version',/g" setup.py -i
sed "s/version = .*/version = '$version'/g" docs/sphinx/conf.py -i
sed "s/release = .*/release = '$version'/g" docs/sphinx/conf.py -i
sed "s/:Version: .*/:Version: $version/g" docs/*.rst -i
sed "s/:Version: .*/:Version: Nikola $version/g" docs/man/nikola.rst -i
sed "s/__version__ = .*/__version__ = '$version'/g" nikola/__init__.py -i
sed "s/version: .*/version: $version/g" snapcraft.yaml -i
setopt errexit # Exit on errors
# Slightly convoluted underline automation
underline=$(python -c "import sys; sys.stdout.write((len('v$version')) * '=')")
perl -0777 -i -pe "s/master\n======/v$version\n$underline/" CHANGES.txt
# Man pages
rst2man.py docs/man/nikola.rst > docs/man/nikola.1
gzip -f docs/man/nikola.1
status 'Updating path handler documentation...'
scripts/document_path_handlers.py > docs/path_handlers.rst
status 'Updating Jinja2 templates...'
scripts/jinjify.py
status 'Updating npm assets...'
scripts/update-npm-assets.sh
status 'Updating symlinked list...'
scripts/generate_symlinked_list.sh
status 'Updating website (conf.py and docs)...'
python -m nikola default_config > ../nikola-site/listings/conf.py
cp AUTHORS.txt CHANGES.txt ../nikola-site/stories
cp docs/*.* ../nikola-site/stories
sed 's/Nikola v[0-9\.A_Za-z-]\{1,\}/Nikola'" v$version/g" ../nikola-site/stories/conf.rst -i
status 'Generating locales...'
scripts/import_po.py
status 'List of locales:'
scripts/langstatus.py
unsetopt errexit
status 'If any locales are shown as "NOT found" and they have full translations, please add them in nikola.py. Check this in another terminal (or not) and press Enter to continue.'
read localefix
status 'Importing...'
python -c "import nikola"
if [[ $? == 1 ]]; then
error "Import failed. Fix your code or don't come back."
exit 1
fi
status 'This is the last chance to quit. Hit ^C now if you want to.'
read bailout
cleanup
./setup.py sdist bdist_wheel || exit $?
twine upload -s dist/Nikola-$version.tar.gz dist/Nikola-$version*.whl || exit $?
cleanup
git add -A --ignore-errors . || exit $?
git commit -S -am "Version $version" || exit $?
git tag -sm "Version $version" v$version || exit $?
git push --follow-tags origin master || exit $?
status "Done!"
echo "Next steps (see Release Checklist):"
echo " * Write announcements, create blog posts"
echo " * Create a GitHub release"
echo " * Update GitHub Issues milestones"
echo " * Update Nikola’s website"
echo " * Send out announcement e-mails"