Skip to content

Commit 7394b14

Browse files
committed
アーカイブ作成スクリプトを追加する
1 parent 7d8a0d5 commit 7394b14

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ vendor/bundle
99
doc/
1010

1111
config/*.yaml
12+
13+
/archive-*

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### 追加
66

7+
* アーカイブ作成スクリプトを追加した。
8+
79
### 変更
810

911
## [0.1.0] - 2020-05-24

Rakefile

+40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
require 'pathname'
4+
35
require 'rake/testtask'
46
require 'yard'
57

@@ -27,4 +29,42 @@ YARD::Rake::YardocTask.new do |t|
2729
]
2830
end
2931

32+
desc 'タグ t のアーカイブを作成する'
33+
task :archive, [:t] do |_t, args|
34+
tag = args[:t]
35+
raise ArgumentError, 'タグを指定してください' unless tag
36+
37+
m = tag.match(/\Av(\d+\.\d+\.\d+.*)/)
38+
raise ArgumentError, "無効なタグの書式です: #{tag}" unless m
39+
40+
ver = m[1]
41+
prefix = "bcdice-irc-#{ver}"
42+
tmp_dir = "archive-#{ver}"
43+
44+
# @type [Pathname]
45+
tmp_dir_prefix_path = Pathname.new(tmp_dir) / prefix
46+
tmp_dir_prefix_path.mkpath
47+
48+
# BCDice IRCのファイルをコピーする
49+
sh "git archive --format=tar #{tag} | (cd #{tmp_dir_prefix_path} && tar -xf -)"
50+
51+
sh "git checkout #{tag}"
52+
sh 'git submodule update'
53+
54+
cd('vendor/bcdice') do
55+
# BCDiceのファイルをコピーする
56+
sh "git archive --format=tar --prefix=vendor/bcdice/ HEAD | (cd ../../#{tmp_dir_prefix_path} && tar -xf -)"
57+
end
58+
59+
cd(tmp_dir) do
60+
prefix_with_bcdice = "#{prefix}-with-bcdice"
61+
62+
# アーカイブを作成する
63+
sh "tar -zcf #{prefix_with_bcdice}.tar.gz #{prefix}"
64+
sh "zip -r #{prefix_with_bcdice}.zip #{prefix}"
65+
66+
rm_r prefix
67+
end
68+
end
69+
3070
task default: :test

0 commit comments

Comments
 (0)