blob: 00a592bdb0889d958552340bf75f6fe7bd73ba5b (
plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/usr/bin/env ruby
require 'erb'
require_relative 'run.rb'
def main(version)
unless version.match?(/\d+\.\d+\.\d+/)
abort "Version string #{version.inspect} does not look like a semver (e.g. \"1.0.2\"). Aborting."
end
env = %w[/usr/bin/env BUNDLE_FLAGS=--no-deployment]
run!(env + %w[make verify smoke-test])
puts 'Testing for changed files'
run!(%w[git diff --quiet --exit-code])
puts 'Testing for staged changes'
run!(%w[git diff --quiet --cached --exit-code])
tag_name = "v#{version}"
write_version_files(version)
run!(%W[_support/generate_changelog #{version}])
run!(%w[git add changelogs CHANGELOG.md])
version_msg = "Version #{version}"
run!(%W[git commit -m #{version_msg}])
run!(%w[gem build gitaly.gemspec])
run!(%W[git tag -a -m #{version_msg} #{tag_name}])
# We use 'capture!' to prevent 'git show' from invoking 'less'.
show_output = capture!(%W[git show --pretty #{tag_name}])
puts show_output
puts "If this is not a security release you can now publish this tag to gitlab.com:\n\n\t_support/publish #{tag_name}\n\n"
end
def write_version_files(version)
version_file = 'VERSION'
open(version_file, 'w') { |f| f.puts version }
run!(%W[git add #{version_file}])
ruby_proto_version_file = 'ruby/proto/gitaly/version.rb'
open(ruby_proto_version_file, 'w') do |f|
f.puts <<~PROTO_VERSION
# This file was auto-generated by #{$0}
module Gitaly
VERSION = '#{version}'
end
PROTO_VERSION
end
# Generating code is tricky. Let's actually load the gem, and inspect
# the version constant.
check = capture!(%W[ruby -Iruby/proto -rgitaly -e #{'print Gitaly::VERSION'}])
unless check == version
puts "fatal: ruby proto version check failed. \n\n"
puts capture!(%w[git diff])
abort
end
run!(%W[git add #{ruby_proto_version_file}])
end
def error(msg)
warn "#{$0}: #{msg}"
end
unless ARGV.count == 1
warn "Usage: #{$0} VERSION"
warn "Specify version as x.y.z"
abort
end
directory_current_file = File.expand_path('..', __FILE__)
git_root_current_file = capture!(%w[git rev-parse --show-toplevel], directory_current_file).chomp
unless git_root_current_file == Dir.pwd
error "#{$0}: this script must be run from the root of the Gitaly repository"
abort
end
main(ARGV.first)
|