-
Notifications
You must be signed in to change notification settings - Fork 583
/
Rakefile
84 lines (67 loc) · 2.31 KB
/
Rakefile
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
84
# frozen_string_literal: true
require "fileutils"
require "rubygems"
require "mail_catcher/version"
# XXX: Would prefer to use Rake::SprocketsTask but can't populate
# non-digest assets, and we don't want sprockets at runtime so
# can't use manifest directly. Perhaps index.html should be
# precompiled with digest assets paths?
desc "Compile assets"
task "assets" do
compiled_path = File.expand_path("../public/assets", __FILE__)
FileUtils.mkdir_p(compiled_path)
require "mail_catcher/web/assets"
sprockets = MailCatcher::Web::Assets
sprockets.css_compressor = :sass
sprockets.js_compressor = :uglifier
sprockets.each_logical_path(/(\Amailcatcher\.(js|css)|\.(xsl|png)\Z)/) do |logical_path|
if asset = sprockets.find_asset(logical_path)
target = File.join(compiled_path, logical_path)
asset.write_to target
end
end
end
desc "Package as Gem"
task "package" => ["assets"] do
require "rubygems/package"
require "rubygems/specification"
spec_file = File.expand_path("../mailcatcher.gemspec", __FILE__)
spec = Gem::Specification.load(spec_file)
Gem::Package.build spec
end
desc "Release Gem to RubyGems"
task "release" => ["package"] do
%x[gem push mailcatcher-#{MailCatcher::VERSION}.gem]
end
desc "Build and push Docker images (optional: VERSION=#{MailCatcher::VERSION})"
task "docker" do
version = ENV.fetch("VERSION", MailCatcher::VERSION)
Dir.chdir(__dir__) do
system "docker", "buildx", "build",
# Push straight to Docker Hub (only way to do multi-arch??)
"--push",
# Build for both intel and arm (apple, graviton, etc)
"--platform", "linux/amd64",
"--platform", "linux/arm64",
# Version respected within Dockerfile
"--build-arg", "VERSION=#{version}",
# Push latest and version
"-t", "sj26/mailcatcher:latest",
"-t", "sj26/mailcatcher:v#{version}",
# Use current dir as context
"."
end
end
require "rdoc/task"
RDoc::Task.new(:rdoc => "doc",:clobber_rdoc => "doc:clean", :rerdoc => "doc:force") do |rdoc|
rdoc.title = "MailCatcher #{MailCatcher::VERSION}"
rdoc.rdoc_dir = "doc"
rdoc.main = "README.md"
rdoc.rdoc_files.include "lib/**/*.rb"
end
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:test) do |rspec|
rspec.rspec_opts = "--format doc"
end
task :test => :assets
task :default => :test