This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Eduardo
authored
Jul 31, 2018
1 parent
0a1b69b
commit ac9b2cb
Showing
4 changed files
with
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ terraform-provider-bless | |
.vscode | ||
terraform.tfstate* | ||
dist | ||
*-packr.go |
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,108 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'rubygems' | ||
require 'git' | ||
require 'logger' | ||
require 'semantic' | ||
|
||
|
||
g = Git.open('.') | ||
g.fetch('origin', {tags: true}) | ||
|
||
if g.status.changed.length > 0 | ||
puts "Please release only from a clean working directory (no uncommitted changes)." | ||
exit(1) | ||
end | ||
|
||
head_sha = g.object("HEAD").sha | ||
master_sha = g.object("origin/master").sha | ||
|
||
if head_sha != master_sha | ||
puts "Please only release versions from master, that way the tagged git sha is on master." | ||
puts "SHAs on branches could go away if a PR is squash-merged." | ||
exit(1) | ||
end | ||
|
||
tag_index = g.tags.inject(Hash.new) do |ind, t| | ||
ind[t.objectish] = t.name | ||
ind | ||
end | ||
|
||
tag, sha = nil, nil | ||
|
||
g.log(1000).each do |c| | ||
if (tag = tag_index[c.sha]) | ||
sha = c.sha | ||
break | ||
end | ||
end | ||
|
||
puts "Found tag #{tag}" | ||
puts "sha for that tag: #{sha}" | ||
|
||
v = open('VERSION').read.strip | ||
semver = Semantic::Version.new(v) | ||
|
||
puts "VERSION file says #{v}" | ||
|
||
if tag.sub('v', '') != v | ||
puts "tag does not match version file" | ||
exit(1) | ||
end | ||
|
||
breaking = false | ||
feature = false | ||
puts "included commits…" | ||
g.log.between("v#{v}", 'HEAD').each do |commit| | ||
puts "* #{commit.message}" | ||
|
||
if commit.message.include?("[breaking]") | ||
breaking = true | ||
end | ||
if commit.message.include?("[feature]") | ||
feature = true | ||
end | ||
end | ||
|
||
if breaking | ||
puts "this appears to be a breaking change" | ||
else | ||
puts "this appears not to be a breaking change" | ||
end | ||
|
||
release_type = if semver.major < 1 | ||
if breaking | ||
"minor" | ||
else | ||
"patch" | ||
end | ||
else | ||
if breaking | ||
"major" | ||
elsif feature | ||
"minor" | ||
else | ||
"patch" | ||
end | ||
end | ||
|
||
puts "release type is #{release_type}" | ||
|
||
new_version = semver.increment!(release_type.to_sym) | ||
|
||
puts "shall we do a #{release_type} release? new version will be #{new_version} (y/n)" | ||
a = gets.chomp | ||
if a != 'y' | ||
puts "canceled" | ||
exit(1) | ||
end | ||
|
||
f = open('VERSION', 'w') | ||
f.write(new_version.to_s) | ||
f.close() | ||
|
||
g.add('VERSION') | ||
g.commit("release version #{new_version.to_s}") | ||
g.add_tag("v#{new_version.to_s}") | ||
|
||
`make release` |