-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
60 lines (47 loc) · 1.83 KB
/
Copy pathRakefile
File metadata and controls
60 lines (47 loc) · 1.83 KB
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
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rake/testtask"
require "rubocop/rake_task"
require "shellwords"
require_relative "lib/riteway/version"
require_relative "scripts/release_preflight"
RSpec::Core::RakeTask.new(:rspec)
Rake::TestTask.new(:minitest) do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.warning = false
end
RuboCop::RakeTask.new(:lint)
task test: [:rspec, :minitest]
task default: [:lint, :test]
# Publishing must be done by a human — never by an AI agent.
# Override bundler's rake release: preflight checks, build, tag, push tag.
# Actual gem push happens in GitHub Actions when the tag is detected.
Rake::Task[:release].clear
task :release do
tag = "v#{Riteway::VERSION}"
begin
ReleasePreflight.run!(tag: tag)
rescue ReleasePreflight::Error => e
abort e.message
end
# Shared check: tag matches version.rb (same script used in CI)
sh "ruby scripts/verify_release_tag.rb #{Shellwords.escape(tag)}"
# Build locally as a dry run — catches gemspec/syntax errors before pushing the tag.
# CI will rebuild from source; this copy is not used for publishing.
Rake::Task[:build].invoke
sh "git tag -a #{Shellwords.escape(tag)} -m #{Shellwords.escape("Release #{tag}")}"
begin
sh "git push origin #{Shellwords.escape(tag)}"
rescue RuntimeError
# Tag push failed — remove the local tag so the next attempt starts clean.
system("git", "tag", "-d", tag)
abort "Failed to push tag #{tag}. Local tag deleted. Try: bundle exec rake release"
end
# Push succeeded — discard the local build artifact. The canonical gem is
# built and published by GitHub Actions.
FileUtils.rm_rf("pkg")
puts
puts "#{tag} pushed. GitHub Actions will run tests and publish to RubyGems."
puts "Monitor: https://github.com/mycargus/riteway-ruby/actions"
end