File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,5 @@ vendor/bundle
99doc /
1010
1111config /* .yaml
12+
13+ /archive- *
Original file line number Diff line number Diff line change 44
55### 追加
66
7+ * アーカイブ作成スクリプトを追加した。
8+
79### 変更
810
911## [ 0.1.0] - 2020-05-24
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3+ require 'pathname'
4+
35require 'rake/testtask'
46require 'yard'
57
@@ -27,4 +29,42 @@ YARD::Rake::YardocTask.new do |t|
2729 ]
2830end
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 ( /\A v(\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+
3070task default : :test
You can’t perform that action at this time.
0 commit comments