-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRakefile
69 lines (56 loc) · 1.83 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
# frozen_string_literal: true
require "aws_assume_role/version"
require "bundler/gem_tasks"
require "yaml"
task default: :test
begin
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
rescue LoadError # rubocop:disable Lint/HandleExceptions
end
begin
require "rubocop/rake_task"
RuboCop::RakeTask.new(:rubocop)
rescue LoadError # rubocop:disable Lint/HandleExceptions
end
task test: %i[no_pry rubocop spec]
DISTRIBUTIONS = [
"universal-linux",
"universal-freebsd",
"universal-darwin",
"universal-openbsd",
].freeze
CREDENTIALS = {
rubygems_api_key: ENV.fetch("API_KEY", "null"),
}.freeze
task :setup_credentials do
FileUtils.mkdir_p(File.expand_path("~/.gem"))
File.write(File.expand_path("~/.gem/credentials"), CREDENTIALS.to_yaml)
end
task publish: %i[build build_generic] do
Dir.glob("#{File.dirname(__FILE__)}/pkg/*.gem") do |g|
sh "gem push #{g}"
end
end
namespace :build_arch do
DISTRIBUTIONS.each do |arch|
desc "build binary gem for #{arch}"
task arch do
sh "cd #{File.dirname(__FILE__)} && PLATFORM=#{arch} gem build aws_assume_role.gemspec"
FileUtils.mkdir_p(File.join(File.dirname(__FILE__), "pkg"))
sh "cd #{File.dirname(__FILE__)} && mv *.gem pkg/"
end
end
end
task build: DISTRIBUTIONS.map { |d| "build_arch:#{d}" }
task :build_generic do
sh "cd #{File.dirname(__FILE__)} && GENERIC_GEM=true gem build aws_assume_role.gemspec"
FileUtils.mkdir_p(File.join(File.dirname(__FILE__), "pkg"))
sh "cd #{File.dirname(__FILE__)} && mv *.gem pkg/"
end
task :no_pry do
files = Dir.glob("**/**").reject { |x| x.match(/^spec|Gemfile|coverage|\.gemspec$|Rakefile|vendor/) || File.directory?(x) }
files.each do |file|
raise "Use of pry found in #{file}." if File.read(file) =~ /"pry"/
end
end