-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
70 lines (54 loc) · 1.58 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
# frozen_string_literal: true
require 'pathname'
require 'rake/testtask'
require 'yard'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.libs << 'vendor/bcdice/src'
t.test_files = FileList['test/**/*_test.rb']
end
YARD::Rake::YardocTask.new do |t|
t.files = [
'lib/**/*.rb',
'exe/**/*.rb',
'-',
'README.md',
'master_commands.md',
]
t.options = [
'--protected',
'--private',
'--markup-provider=redcarpet',
'--markup=markdown',
]
end
desc 'タグ t のアーカイブを作成する'
task :archive, [:t] do |_t, args|
tag = args[:t]
raise ArgumentError, 'タグを指定してください' unless tag
m = tag.match(/\Av(\d+\.\d+\.\d+.*)/)
raise ArgumentError, "無効なタグの書式です: #{tag}" unless m
ver = m[1]
prefix = "bcdice-irc-#{ver}"
tmp_dir = "archive-#{ver}"
# @type [Pathname]
tmp_dir_prefix_path = Pathname.new(tmp_dir) / prefix
tmp_dir_prefix_path.mkpath
# BCDice IRCのファイルをコピーする
sh "git archive --format=tar #{tag} | (cd #{tmp_dir_prefix_path} && tar -xf -)"
sh "git checkout #{tag}"
sh 'git submodule update'
cd('vendor/bcdice') do
# BCDiceのファイルをコピーする
sh "git archive --format=tar --prefix=vendor/bcdice/ HEAD | (cd ../../#{tmp_dir_prefix_path} && tar -xf -)"
end
cd(tmp_dir) do
prefix_with_bcdice = "#{prefix}-with-bcdice"
# アーカイブを作成する
sh "tar -zcf #{prefix_with_bcdice}.tar.gz #{prefix}"
sh "zip -r #{prefix_with_bcdice}.zip #{prefix}"
rm_r prefix
end
end
task default: :test