-
Notifications
You must be signed in to change notification settings - Fork 12
/
release.sh
executable file
·89 lines (74 loc) · 1.8 KB
/
release.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
#!/bin/sh
set -e
if [ "$#" -ne 1 ]; then
echo >&2 "USAGE: $0 new_version"
exit 2
fi
RELEASE_BRANCH=release
DEV_BRANCH=master
NEW_VERSION=$1
T() {
printf >&2 -- '-> %s\n' "$*"
"$@"
}
T_redir_to_file() {
local f=$1
shift
printf >&2 -- '-> %s > %s\n' "$*" "$f"
"$@" > "$f"
}
T_append_to_file() {
local f=$1
shift
printf >&2 -- '-> %s >> %s\n' "$*" "$f"
"$@" >> "$f"
}
ask() {
local ans
echo ""
echo -n " $* (“yes” to proceed) >>> "
read -r ans || exit 3
if [ "$ans" != yes ]; then
exit 3
fi
}
if ! T git checkout $RELEASE_BRANCH; then
T git branch $RELEASE_BRANCH
T git checkout $RELEASE_BRANCH
fi
last_msg=$(git log -1 --pretty=%B)
release_msg="Release $NEW_VERSION"
if [ "$last_msg" = "$release_msg" ]; then
echo ""
echo "Last commit message is “$last_msg”."
echo "Apparently, you have run this script before, so exiting now."
exit 1
fi
T git merge $DEV_BRANCH
T_redir_to_file VERSION echo $NEW_VERSION
T_append_to_file RELEASE_NOTES echo
T sed \
-e "1i\luastatus $NEW_VERSION ($(LC_ALL=C date +'%B %d, %Y'))\n===\n(Please describe the changes here.)\n" \
-e :a -e '/^\n*$/{$d;N;};/\n$/ba' \
-i RELEASE_NOTES
T ${EDITOR:-edit} RELEASE_NOTES
ask 'Commit?'
T git add VERSION RELEASE_NOTES
T git commit -m "$release_msg"
cat <<EOF
===
Done! Now:
* Make manual changes, if needed.
* Run the following commands:
* git tag --force v$NEW_VERSION
* git push --set-upstream origin $RELEASE_BRANCH
* git push --tags
* git checkout $DEV_BRANCH
* Release it on GitHub:
* The “<number> release(s)” link on the GitHub page of the project
* The “Tags” tab
* “Add release notes”
* Fill in everything needed, click “Publish release”
* Tell everybody about it!!
===
EOF