-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRakefile
97 lines (90 loc) · 2.85 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
85
86
87
88
89
90
91
92
93
94
95
96
97
# -*- ruby -*-
#
# Copyright (C) 2024 Sutou Kouhei <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; version 2
# of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA
version = File.read("CMakeLists.txt")[/VERSION "(.*?)"/, 1]
desc "Create source archives"
task :dist do
base_name = "groonga-normalizer-mysql-#{version}"
["tar.gz", "zip"].each do |format|
sh("git",
"archive",
"--format=#{format}",
"--output=#{base_name}.#{format}",
"--prefix=#{base_name}/",
"HEAD")
end
end
namespace :release do
namespace :version do
desc "Update versions for a new release"
task :update do
cd("packages") do
ruby("-S", "rake", "version:update")
end
sh("git",
"add",
"packages/debian/changelog",
"packages/yum/groonga-normalizer-mysql.spec.in")
sh("git", "commit", "-m", "packages: update versions")
sh("git", "push")
end
end
desc "Tag"
task :tag do
latest_news = "doc/text/news.md"
latest_release_note = File.read(latest_news).split(/^## /)[1]
latest_release_note_version = latest_release_note.lines.first[/[\d.]+/]
if latest_release_note_version != version
raise "release note isn't written"
end
changelog = "packages/debian/changelog"
case File.readlines(changelog)[0]
when /\((.+)-1\)/
package_version = $1
unless package_version == version
raise "package version isn't updated: #{package_version}"
end
else
raise "failed to detect deb package version: #{changelog}"
end
sh("git",
"tag",
"v#{version}",
"-a",
"-m",
"groonga-normalizer-mysql #{version}!!!")
sh("git", "push", "origin", "v#{version}")
end
end
namespace :dev do
namespace :version do
desc "Bump version for new development"
task :bump do
new_version = ENV["NEW_VERSION"]
raise "NEW_VERSION environment variable is missing" if new_version.nil?
cmake_lists_txt_content = File.read("CMakeLists.txt")
cmake_lists_txt_content.gsub!(/VERSION ".+?"/) do
"VERSION \"#{new_version}\""
end
File.write("CMakeLists.txt", cmake_lists_txt_content)
sh("git", "add", "CMakeLists.txt")
sh("git", "commit", "-m", "Bump version")
sh("git", "push")
end
end
end