-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d70fc92
commit 5cb8e97
Showing
7 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module JMESPath | ||
VERSION = '0.2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
task 'changelog:version' do | ||
# replaces "Next Release (TBD)" in the CHANGELOG with a version and date | ||
changelog = File.open('CHANGELOG.md', 'r', encoding: 'UTF-8') { |f| f.read } | ||
changelog = changelog.lines | ||
changelog[0] = "#{$VERSION} (#{Time.now.strftime('%Y-%m-%d')})\n" | ||
changelog = changelog.join | ||
File.open('CHANGELOG.md', 'w', encoding: 'UTF-8') { |f| f.write(changelog) } | ||
sh("git add CHANGELOG.md") | ||
end | ||
|
||
task 'changelog:next_release' do | ||
# inserts a "Next Release (TDB)" section at the top of the CHANGELOG | ||
lines = [] | ||
lines << "Next Release (TBD)\n" | ||
lines << "------------------\n" | ||
lines << "\n" | ||
changelog = File.open('CHANGELOG.md', 'r', encoding: 'UTF-8') { |f| f.read } | ||
changelog = lines.join + changelog | ||
File.open('CHANGELOG.md', 'w', encoding: 'UTF-8') { |f| f.write(changelog) } | ||
sh("git add CHANGELOG.md") | ||
sh("git commit -m 'Added next release section to the changelog.'") | ||
end | ||
|
||
task 'changelog:latest' do | ||
# Returns the contents of the most recent CHANGELOG section | ||
changelog = File.open('CHANGELOG.md', 'r', encoding: 'UTF-8') { |f| f.read } | ||
lines = [] | ||
changelog.lines[3..-1].each do |line| | ||
if line.match(/^\d+\.\d+\.\d+/) | ||
break | ||
else | ||
lines << line | ||
end | ||
end | ||
puts lines[0..-2].join | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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 | ||
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(/((?:\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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
task 'github:require-access-token' do | ||
unless $GITHUB_ACCESS_TOKEN | ||
warn("you must export JMESPATH_GITHUB_ACCESS_TOKEN") | ||
exit | ||
end | ||
end | ||
|
||
task 'github:release' do | ||
require 'octokit' | ||
|
||
gh = Octokit::Client.new(access_token: $GITHUB_ACCESS_TOKEN) | ||
|
||
repo = 'trevorrowe/jmespath.rb' | ||
tag_ref_sha = `git show-ref v#{version}`.split(' ').first | ||
tag = gh.tag(repo, tag_ref_sha) | ||
|
||
release = gh.create_release(repo, "v#{version}", { | ||
name: 'Release v' + version + ' - ' + tag.tagger.date.strftime('%Y-%m-%d'), | ||
body: tag.message.lines[2..-1].join, | ||
prerelease: version.match('rc') ? true : false, | ||
}) | ||
|
||
gh.upload_asset(release.url, 'docs.zip', | ||
:content_type => 'application/octet-stream') | ||
|
||
gh.upload_asset(release.url, "jmespath-#{$VERSION}.gem", | ||
:content_type => 'application/octet-stream') | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
task 'release:require-version' do | ||
unless ENV['VERSION'] | ||
warn("usage: VERSION=x.y.z rake release") | ||
exit | ||
end | ||
end | ||
|
||
task 'release:bump-version' do | ||
sh("echo '#{$VERSION}' > VERSION") | ||
path = 'lib/jmespath/version.rb' | ||
file = File.read(path) | ||
file = file.gsub(/VERSION = '.+?'/, "VERSION = '#{$VERSION}'") | ||
File.open(path, 'w') { |f| f.write(file) } | ||
sh("git add #{path}") | ||
sh("git add VERSION") | ||
end | ||
|
||
task 'release:stage' => [ | ||
'release:require-version', | ||
'github:require-access-token', | ||
'git:require-clean-workspace', | ||
'test:unit', | ||
'changelog:version', | ||
'release:bump-version', | ||
'git:tag', | ||
'gem:build', | ||
'docs:zip', | ||
] | ||
|
||
task 'release:publish' => [ | ||
'git:push', | ||
'gems:push', | ||
'github:release', | ||
] | ||
|
||
task 'release:cleanup' => [ | ||
'changelog:next_release', | ||
] | ||
|
||
desc "Public release" | ||
task :release => ['release:stage', 'release:publish', 'release:cleanup'] |