Skip to content

Commit a7a382f

Browse files
committed
add release checklist
1 parent 6537143 commit a7a382f

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

Runfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ require "byebug"
33
require "colsole"
44
require_relative 'lib/bashly'
55
require_relative 'helpers/example'
6+
require_relative 'helpers/checklist'
67
include Colsole
78

89
title "Bashly Developer Toolbelt"
@@ -70,4 +71,5 @@ action :examples do
7071
end
7172
end
7273

74+
require_relative 'helpers/release'
7375
require './debug.rb' if File.exist? 'debug.rb'

helpers/checklist.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# A helper class used in Runfile for running through a release checklist
2+
class Checklist
3+
attr_accessor :failed, :limit
4+
5+
def initialize(limit: 3)
6+
@limit = limit
7+
@failed = 0
8+
end
9+
10+
def url_exist?(url)
11+
`curl -s -o /dev/null -w "%{http_code}" #{url}`.strip.to_i == 200
12+
end
13+
14+
def run(text)
15+
say "!txtblu![....]!txtrst! #{text} "
16+
if failed >= limit
17+
say ''
18+
return
19+
end
20+
21+
ok = yield
22+
if ok
23+
resay "!txtgrn![PASS]!txtrst! #{text}"
24+
else
25+
resay "!txtred![FAIL]!txtrst! #{text}"
26+
@failed += 1
27+
end
28+
end
29+
end

helpers/release.rb

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
help 'Run release checklist'
2+
usage 'release VERSION'
3+
action :release do |args|
4+
version = args['VERSION']
5+
6+
checklist = Checklist.new
7+
8+
checklist.run "on master branch and nothing to commit" do
9+
`git status`.match /On branch master.*nothing to commit/m
10+
end
11+
12+
checklist.run "code version is #{version}" do
13+
File.read('lib/bashly/version.rb').include? version
14+
end
15+
16+
checklist.run "dockerfile version is #{version}" do
17+
File.read('Dockerfile').include? version
18+
end
19+
20+
checklist.run "tag v#{version} exists" do
21+
!`git tag -l v#{version}`.empty?
22+
end
23+
24+
checklist.run "changelog has a section for #{version}" do
25+
File.read('CHANGELOG.md').include? "v#{version}"
26+
end
27+
28+
checklist.run "github has tag v#{version}" do
29+
checklist.url_exist? "https://github.com/DannyBen/bashly/tree/v#{version}"
30+
end
31+
32+
checklist.run "built gem is version #{version}" do
33+
`bundle exec bashly --version`.strip == version
34+
end
35+
36+
checklist.run "published gem is version #{version}" do
37+
checklist.url_exist? "https://rubygems.org/gems/bashly/versions/#{version}"
38+
end
39+
40+
checklist.run "local docker image exists with tag #{version}" do
41+
`docker images`.match /bashly\s*#{version}/
42+
end
43+
44+
checklist.run "remote docker image exists with tag #{version}" do
45+
digest = `docker inspect --format='{{.RepoDigests}}' dannyben/bashly:#{version}`[/@sha256:(.*)\]/,1]
46+
if digest
47+
checklist.url_exist? "https://hub.docker.com/layers/dannyben/bashly/#{version}/images/sha256-#{digest}"
48+
else
49+
false
50+
end
51+
end
52+
53+
checklist.run "github release is available for #{version}" do
54+
checklist.url_exist? "https://github.com/DannyBen/bashly/releases/tag/v#{version}"
55+
end
56+
57+
checklist.run "version in local retype is #{version}" do
58+
YAML.load_file('/vagrant/sites/bashly/retype.yml')['branding']['label'] == "v#{version}"
59+
end
60+
61+
checklist.run "version in remote retype is #{version}" do
62+
`curl -Ss https://raw.githubusercontent.com/DannyBen/bashly-book/master/retype.yml`.include? "label: v#{version}"
63+
end
64+
65+
color = checklist.failed == 0 ? '!bldgrn!' : '!bldred!'
66+
say " #{color}Done with #{checklist.failed} failed tasks"
67+
end

0 commit comments

Comments
 (0)