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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
require "json"
require "pathname"
groonga_repository = ENV["GROONGA_REPOSITORY"]
if groonga_repository.nil?
raise "Specify GROONGA_REPOSITORY environment variable"
end
require "#{groonga_repository}/packages/packages-groonga-org-package-task"
class GroongaNormalizerMySQLPackageTask < PackagesGroongaOrgPackageTask
def initialize
super("groonga-normalizer-mysql", detect_version, detect_release_time)
end
private
def top_directory
packages_directory.parent
end
def packages_directory
Pathname(__dir__)
end
def detect_version
ENV["VERSION"] ||
(top_directory + "CMakeLists.txt").read[/VERSION "(.*?)"/, 1]
end
def detect_required_groonga_version
(top_directory + "required_groonga_version").read.chomp
end
def original_archive_path
top_directory + @archive_name
end
def define_archive_task
file "../#{@archive_name}" do
source_archive_url = built_package_url(:source, @archive_name)
download(source_archive_url, "..")
end
file @archive_name => "../#{@archive_name}" do
ln_s("../#{@archive_name}", @archive_name)
end
end
def apt_targets_default
[
"debian-bookworm",
"debian-bookworm-arm64",
"ubuntu-jammy",
"ubuntu-jammy-arm64",
"ubuntu-noble",
"ubuntu-noble-arm64",
]
end
def yum_targets_default
[
"almalinux-8",
"almalinux-8-aarch64",
"almalinux-9",
"almalinux-9-aarch64",
"amazon-linux-2023",
"amazon-linux-2023-aarch64",
]
end
def yum_expand_variable(key)
case key
when "REQUIRED_GROONGA_VERSION"
detect_required_groonga_version
else
super
end
end
def source_targets_default
[
"#{@archive_base_name}.tar.gz",
"#{@archive_base_name}.zip",
]
end
def use_built_package?
true
end
def github_repository
"groonga/groonga-normalizer-mysql"
end
def github_actions_workflow_file_name(target_namespace, target)
case target_namespace
when :apt, :yum
"package.yml"
else
super
end
end
def github_actions_artifact_name(target_namespace, target)
case target_namespace
when :apt
if target.end_with?("-i386") or target.end_with?("-arm64")
"packages-#{target}"
else
"packages-#{target}-amd64"
end
when :yum
"packages-#{target}"
when :source
target
else
raise NotImplementedError
end
end
def built_package_url(target_namespace, target)
url = "https://github.com/groonga/groonga-normalizer-mysql/releases/download/v#{@version}/"
case target_namespace
when :apt
if target.end_with?("-i386") or target.end_with?("-arm64")
url << "#{target}.tar.gz"
else
url << "#{target}-amd64.tar.gz"
end
when :yum
url << "#{target}.tar.gz"
else
url << "#{target}"
end
url
end
def built_package_n_split_components
3
end
def tag_name
"v#{@version}"
end
end
task = GroongaNormalizerMySQLPackageTask.new
task.define
|