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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/bruh/cli.rb', line 26
def release
interactive = !options[:non_interactive]
project_root = Dir.pwd
cabal_file = find_cabal_file(project_root)
if cabal_file.nil?
puts 'Error: No .cabal file found in current directory or subdirectories'
exit 1
end
cabal = Cabal.new(cabal_file)
current_version = cabal.version
puts "Current version: #{current_version}"
if options[:version] && !options[:version].empty?
new_version = options[:version]
elsif interactive
suggested_version = increment_version(current_version)
new_version = prompt('Enter new version', suggested_version)
else
new_version = increment_version(current_version)
end
puts "Preparing release for version #{new_version}"
cabal.update_version(new_version)
puts "Updated .cabal file to version #{new_version}"
if File.exist?('CHANGELOG.md')
Changelog.update(new_version, project_root, interactive)
puts 'Updated CHANGELOG.md with new version entry'
end
puts 'Running tests to verify everything works...'
unless system('bundle exec rake test')
puts 'Tests failed. Aborting release process.'
exit 1 unless yes_no_prompt('Continue anyway?', default_no: false) && interactive
end
if interactive && yes_no_prompt('Commit version bump and changelog?', default_no: true)
system("git add #{cabal_file} CHANGELOG.md")
system("git commit -m \"Bump version to #{new_version}\"")
system('git push origin main') if yes_no_prompt('Push changes to origin?', default_no: true)
if yes_no_prompt("Create tag v#{new_version}?", default_no: true)
if system("git rev-parse v#{new_version} >/dev/null 2>&1")
if yes_no_prompt('Tag already exists. Update it?', default_no: true)
system("git tag -fa v#{new_version} -m \"Release version #{new_version}\"")
end
else
system("git tag -a v#{new_version} -m \"Release version #{new_version}\"")
end
system("git push origin v#{new_version}") if yes_no_prompt('Push tag to origin?', default_no: true)
end
end
unless options[:skip_hackage]
puts 'Preparing for Hackage release...'
hackage = Hackage.new(interactive)
if interactive
uploaded = hackage.publish(new_version)
else
config = Config.load
uploaded = hackage.publish_non_interactive(new_version, config[:hackage_username], config[:hackage_password])
end
if uploaded
puts 'Successfully published to Hackage!'
sha256 = hackage.calculate_package_sha256(new_version)
if sha256
puts 'Updating Homebrew formula...'
formula = Homebrew.new(interactive)
formula.update(new_version, sha256)
unless options[:skip_bottles]
puts 'Building Homebrew bottle...'
bottle = Bottle.new(interactive)
bottle_info = bottle.build(new_version)
if bottle_info && !options[:skip_github]
puts 'Uploading bottle to GitHub...'
bottle.upload_to_github(new_version, bottle_info)
puts 'Updating formula with bottle information...'
formula.update_bottle_info(bottle_info)
end
end
end
end
end
puts 'Release process complete!'
end
|