-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.rake
34 lines (30 loc) · 931 Bytes
/
git.rake
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
# frozen_string_literal: true
task 'git:require-clean-workspace' do
# Ensure the git repo is free of unstaged or untracked files prior
# to building / testing / pushing a release.
unless `git diff --shortstat 2> /dev/null | tail -n1` == ''
warn('workspace must be clean to release')
exit(1)
end
end
task 'git:tag' do
sh("git commit -m \"Bumped version to v#{$VERSION}\"")
sh("git tag -a -m \"$(rake git:tag_message)\" v#{$VERSION}")
end
task 'git:tag_message' do
issues = `git log $(git describe --tags --abbrev=0)...HEAD -E \
--grep '#[0-9]+' 2>/dev/null`
issues = issues.scan(%r{((?:\S+/\S+)?#\d+)}).flatten
msg = +"Tag release v#{$VERSION}"
msg << "\n\n"
unless issues.empty?
msg << "References: #{issues.uniq.sort.join(', ')}"
msg << "\n\n"
end
msg << `rake changelog:latest`
puts msg
end
task 'git:push' do
sh('git push origin')
sh('git push origin --tags')
end