forked from streamlink/streamlink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·298 lines (262 loc) · 6.7 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·298 lines (262 loc) · 6.7 KB
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
292
293
294
295
296
297
298
#!/bin/bash
UPSTREAM_REPO="streamlink"
CLI="streamlink"
usage() {
echo "This will prepare $CLI for release!"
echo ""
echo "Requirements:"
echo " git"
echo " gpg - with a valid GPG key already generated"
echo " hub"
echo " github-release"
echo " GITHUB_TOKEN in your env variable"
echo " "
echo "Not only that, but you must have permission for:"
echo " Tagging releases within Github"
echo ""
}
requirements() {
if [ ! -f /usr/bin/git ] && [ ! -f /usr/local/bin/git ]; then
echo "No git. What's wrong with you?"
return 1
fi
if [ ! -f /usr/bin/gpg ] && [ ! -f /usr/local/bin/gpg ]; then
echo "No gpg. What's wrong with you?"
return 1
fi
if [ ! -f $GOPATH/bin/github-release ]; then
echo "No $GOPATH/bin/github-release. Please run 'go get -v github.com/aktau/github-release'"
return 1
fi
if [ ! -f /usr/bin/hub ]; then
echo "No hub. Please run install hub @ github.com/github/hub"
return 1
fi
if [[ -z "$GITHUB_TOKEN" ]]; then
echo "export GITHUB_TOKEN=yourtoken needed for using github-release"
fi
}
# Clone and then change to user's upstream repo for pushing to master / opening PR's :)
clone() {
git clone ssh://[email protected]/$UPSTREAM_REPO/$CLI.git
if [ $? -eq 0 ]; then
echo OK
else
echo FAIL
exit
fi
cd $CLI
git remote remove origin
git remote add origin [email protected]:$ORIGIN_REPO/$CLI.git
git checkout -b release-$1
cd ..
}
replaceversion() {
cd $CLI
OLD_VERSION=`python setup.py --version`
echo "OLD VERSION:" $OLD_VERSION
echo "1. Replaced .py versioning"
find . -name '*.py' -type f -exec sed -i "s/$OLD_VERSION/$1/g" {} \;
echo "2. Replaced docs versioning"
find docs/ -name '*.md' -type f -exec sed -i "s/$OLD_VERSION/$1/g" {} \;
echo "3. Replaced README.md versioning"
sed -i "s/$OLD_VERSION/$1/g" README.md
cd ..
}
changelog() {
cd $CLI
echo "Getting commit changes. Writing to ../changes.txt"
LOG=$(git shortlog --email --no-merges --pretty=%s ${1}.. | sed 's/^/ /')
echo -e "::\n\n$LOG" > ../changes.txt
echo "Changelog has been written to changes.txt"
echo "!!PLEASE REVIEW BEFORE CONTINUING!!"
echo "Open changes.txt and add the release information"
echo "to the beginning of the file before the git shortlog"
cd ..
}
changelog_rst() {
echo "Generating CHANGELOG.rst"
CHANGES=$(cat changes.txt)
cd $CLI
DATE=$(date +"%Y-%m-%d")
CHANGELOG=$(cat CHANGELOG.rst)
HEADER="$CLI $1 ($DATE)"
UNDERLINE=$(printf %s "$HEADER" | tr -c '-' '[-*]')
echo -e "$HEADER\n$UNDERLINE\n$CHANGES\n\n$CHANGELOG" >CHANGELOG.rst
echo "Changes have been written to CHANGELOG.rst"
cd ..
}
git_commit() {
cd $CLI
BRANCH=`git symbolic-ref --short HEAD`
if [ -z "$BRANCH" ]; then
echo "Unable to get branch name, is this even a git repo?"
return 1
fi
echo "Branch: " $BRANCH
git add .
git commit -m "$1 Release"
git push origin $BRANCH
hub pull-request -b $UPSTREAM_REPO/$CLI:master -h $ORIGIN_REPO/$CLI:$BRANCH
cd ..
echo ""
echo "PR opened against master"
echo ""
}
sign() {
# Tarball it!
cd $CLI
python setup.py sdist
mv dist/$CLI-$1.tar.gz ..
cd ..
# Sign it!
echo -e "SIGN THE TARBALL!\n"
gpg --detach-sign --armor $CLI-$1.tar.gz
if [ $? -eq 0 ]; then
echo SIGN OK
else
echo SIGN FAIL
exit
fi
echo ""
echo "The tar.gz. is now located at $CLI-$1.tar.gz"
echo "and the signed one at $CLI-$1.tar.gz.asc"
echo ""
}
push() {
CHANGES=$(cat changes.txt)
# Release it!
github-release release \
--user $UPSTREAM_REPO \
--repo $CLI \
--tag $1 \
--name "$1" \
--description "$CHANGES"
if [ $? -eq 0 ]; then
echo RELEASE UPLOAD OK
else
echo RELEASE UPLOAD FAIL
exit
fi
github-release upload \
--user $UPSTREAM_REPO \
--repo $CLI \
--tag $1 \
--name "$CLI-$1.tar.gz" \
--file $CLI-$1.tar.gz
if [ $? -eq 0 ]; then
echo TARBALL UPLOAD OK
else
echo TARBALL UPLOAD FAIL
exit
fi
github-release upload \
--user $UPSTREAM_REPO \
--repo $CLI\
--tag $1 \
--name "$CLI-$1.tar.gz.asc" \
--file $CLI-$1.tar.gz.asc
if [ $? -eq 0 ]; then
echo SIGNED TARBALL UPLOAD OK
else
echo SIGNED TARBALL UPLOAD FAIL
exit
fi
echo "DONE"
echo "DOUBLE CHECK IT:"
echo "!!!"
echo "https://github.com/$UPSTREAM_REPO/$CLI/releases/edit/$1"
echo "!!!"
}
upload_pypi_test() {
cd $CLI
python setup.py sdist upload -r pypitest
cd ..
}
upload_pypi() {
cd $CLI
python setup.py sdist upload -r pypi
cd ..
}
clean() {
rm -rf $CLI $CLI-$1 $CLI-$1.tar.gz $CLI-$1.tar.gz.asc $CLI-$1.exe changes.txt
}
main() {
local cmd=$1
usage
echo "What is your Github username? (location of your $CLI fork)"
read ORIGIN_REPO
echo "You entered: $ORIGIN_REPO"
echo ""
echo ""
echo "First, please enter the version of the NEW release: "
read VERSION
echo "You entered: $VERSION"
echo ""
echo ""
echo "Second, please enter the version of the LAST release: "
read PREV_VERSION
echo "You entered: $PREV_VERSION"
echo ""
clear
echo "Now! It's time to go through each step of releasing $CLI!"
echo "If one of these steps fails / does not work, simply re-run ./release.sh"
echo "Re-enter the information at the beginning and continue on the failed step"
echo ""
PS3='Please enter your choice: '
options=(
"Git clone master"
"Replace version number"
"Generate changelog"
"Generate changelog for release"
"Create PR"
"Tarball and sign - requires gpg key"
"Upload the tarball and source code to GitHub release page"
"Test upload to pypi"
"Upload to pypi"
"Clean"
"Quit")
select opt in "${options[@]}"
do
echo ""
case $opt in
"Git clone master")
clone $VERSION
;;
"Replace version number")
replaceversion $VERSION
;;
"Generate changelog")
changelog $PREV_VERSION
;;
"Generate changelog for release")
changelog_rst $VERSION
;;
"Create PR")
git_commit $VERSION
;;
"Tarball and sign - requires gpg key")
sign $VERSION
;;
"Upload the tarball and source code to GitHub release page")
push $VERSION
;;
"Test upload to pypi")
upload_pypi_test
;;
"Upload to pypi")
upload_pypi
;;
"Clean")
clean $VERSION
;;
"Quit")
clear
break
;;
*) echo invalid option;;
esac
echo ""
done
}
main "$@"