-
Notifications
You must be signed in to change notification settings - Fork 31
/
generate_release.sh
executable file
·43 lines (35 loc) · 1.36 KB
/
generate_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
#!/bin/sh
#Script to automate some of the work involved in generating a new release
#Run it as `./generate_release 0.0.0`
#Regex to check argument, this isn't very good, but is good enough
if [ -z "$1" ]; then
echo "No argument supplied";
exit 1;
fi
if [ $(echo "$@" | sed -E "s/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/true/" ) != "true" ]; then
echo "Argument must be in the form d.d.d";
exit 1;
fi
#Bump version
sed -e "s/\(Version: \).*$/\1$@/" plugin/simplenote.vim > plugin/simplenote.vim.tmp && mv plugin/simplenote.vim.tmp plugin/simplenote.vim;
#Update Changelog with commits since last tag
last_tag=`git show-ref --tags | tail -n 1 | awk '{print $1}'`
git log $last_tag..HEAD --pretty=oneline --abbrev-commit | cut -d " " -f 2- > commit.log;
sed s/^/\-" "/ commit.log > commit.log.tmp;
echo "
## $@ `date '+(%m/%d/%Y)'`
`cat commit.log.tmp`" > commit.log
sed '/Changelog/ r commit.log' < CHANGELOG.md > CHANGELOG.md.tmp && mv CHANGELOG.md.tmp CHANGELOG.md
rm commit.log commit.log.tmp;
#Add commits
git add plugin/simplenote.vim;
git add CHANGELOG.md;
git commit -m "Bump version to v$@";
#Tag release
git tag v$@
#Generate vimball
sh ./mk_vimball.sh
#Echo what needs to be done next
echo "Changelog and version updated, commited and tagged."
echo "Review the Changelog and make necessary changes with git commit --amend."
echo "Remember to re-tag the commit if you amend it."