| 1 |
require "json" |
| 2 |
require "pathname" |
| 3 |
|
| 4 |
groonga_repository = ENV["GROONGA_REPOSITORY"] |
| 5 |
if groonga_repository.nil? |
| 6 |
raise "Specify GROONGA_REPOSITORY environment variable" |
| 7 |
end |
| 8 |
require "#{groonga_repository}/packages/packages-groonga-org-package-task" |
| 9 |
|
| 10 |
class GroongaNormalizerMySQLPackageTask < PackagesGroongaOrgPackageTask |
| 11 |
def initialize |
| 12 |
super("groonga-normalizer-mysql", detect_version, detect_release_time) |
| 13 |
end |
| 14 |
|
| 15 |
private |
| 16 |
def top_directory |
| 17 |
packages_directory.parent |
| 18 |
end |
| 19 |
|
| 20 |
def packages_directory |
| 21 |
Pathname(__dir__) |
| 22 |
end |
| 23 |
|
| 24 |
def detect_version |
| 25 |
ENV["VERSION"] || |
| 26 |
(top_directory + "CMakeLists.txt").read[/VERSION "(.*?)"/, 1] |
| 27 |
end |
| 28 |
|
| 29 |
def detect_required_groonga_version |
| 30 |
(top_directory + "required_groonga_version").read.chomp |
| 31 |
end |
| 32 |
|
| 33 |
def original_archive_path |
| 34 |
top_directory + @archive_name |
| 35 |
end |
| 36 |
|
| 37 |
def define_archive_task |
| 38 |
file "../#{@archive_name}" do |
| 39 |
source_archive_url = built_package_url(:source, @archive_name) |
| 40 |
download(source_archive_url, "..") |
| 41 |
end |
| 42 |
|
| 43 |
file @archive_name => "../#{@archive_name}" do |
| 44 |
ln_s("../#{@archive_name}", @archive_name) |
| 45 |
end |
| 46 |
end |
| 47 |
|
| 48 |
def apt_targets_default |
| 49 |
[ |
| 50 |
"debian-bookworm", |
| 51 |
"debian-bookworm-arm64", |
| 52 |
"debian-trixie", |
| 53 |
"debian-trixie-arm64", |
| 54 |
"ubuntu-jammy", |
| 55 |
"ubuntu-jammy-arm64", |
| 56 |
"ubuntu-noble", |
| 57 |
"ubuntu-noble-arm64", |
| 58 |
] |
| 59 |
end |
| 60 |
|
| 61 |
def yum_targets_default |
| 62 |
[ |
| 63 |
"almalinux-8", |
| 64 |
"almalinux-8-aarch64", |
| 65 |
"almalinux-9", |
| 66 |
"almalinux-9-aarch64", |
| 67 |
"amazon-linux-2023", |
| 68 |
"amazon-linux-2023-aarch64", |
| 69 |
] |
| 70 |
end |
| 71 |
|
| 72 |
def yum_expand_variable(key) |
| 73 |
case key |
| 74 |
when "REQUIRED_GROONGA_VERSION" |
| 75 |
detect_required_groonga_version |
| 76 |
else |
| 77 |
super |
| 78 |
end |
| 79 |
end |
| 80 |
|
| 81 |
def source_targets_default |
| 82 |
[ |
| 83 |
"#{@archive_base_name}.tar.gz", |
| 84 |
"#{@archive_base_name}.zip", |
| 85 |
] |
| 86 |
end |
| 87 |
|
| 88 |
def use_built_package? |
| 89 |
true |
| 90 |
end |
| 91 |
|
| 92 |
def github_repository |
| 93 |
"groonga/groonga-normalizer-mysql" |
| 94 |
end |
| 95 |
|
| 96 |
def github_actions_workflow_file_name(target_namespace, target) |
| 97 |
case target_namespace |
| 98 |
when :apt, :yum |
| 99 |
"package.yml" |
| 100 |
else |
| 101 |
super |
| 102 |
end |
| 103 |
end |
| 104 |
|
| 105 |
def github_actions_artifact_name(target_namespace, target) |
| 106 |
case target_namespace |
| 107 |
when :apt |
| 108 |
if target.end_with?("-i386") or target.end_with?("-arm64") |
| 109 |
"packages-#{target}" |
| 110 |
else |
| 111 |
"packages-#{target}-amd64" |
| 112 |
end |
| 113 |
when :yum |
| 114 |
"packages-#{target}" |
| 115 |
when :source |
| 116 |
target |
| 117 |
else |
| 118 |
raise NotImplementedError |
| 119 |
end |
| 120 |
end |
| 121 |
|
| 122 |
def built_package_url(target_namespace, target) |
| 123 |
url = "https://github.com/groonga/groonga-normalizer-mysql/releases/download/v#{@version}/" |
| 124 |
case target_namespace |
| 125 |
when :apt |
| 126 |
if target.end_with?("-i386") or target.end_with?("-arm64") |
| 127 |
url << "#{target}.tar.gz" |
| 128 |
else |
| 129 |
url << "#{target}-amd64.tar.gz" |
| 130 |
end |
| 131 |
when :yum |
| 132 |
url << "#{target}.tar.gz" |
| 133 |
else |
| 134 |
url << "#{target}" |
| 135 |
end |
| 136 |
url |
| 137 |
end |
| 138 |
|
| 139 |
def built_package_n_split_components |
| 140 |
3 |
| 141 |
end |
| 142 |
|
| 143 |
def tag_name |
| 144 |
"v#{@version}" |
| 145 |
end |
| 146 |
end |
| 147 |
|
| 148 |
task = GroongaNormalizerMySQLPackageTask.new |
| 149 |
task.define |