From 6df88f2e5d16976ad1a8a5deebd95e64568c47e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Thu, 16 Jan 2025 11:00:33 +0000 Subject: [PATCH 1/3] inject VERSION_QUALIFIER into artifacts --- logstash-core-plugin-api/logstash-core-plugin-api.gemspec | 5 +++-- logstash-core/lib/logstash/api/commands/default_metadata.rb | 2 +- logstash-core/logstash-core.gemspec | 6 ++++-- rakelib/artifacts.rake | 6 +----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/logstash-core-plugin-api/logstash-core-plugin-api.gemspec b/logstash-core-plugin-api/logstash-core-plugin-api.gemspec index db1e79c7935..fa58ca3148f 100644 --- a/logstash-core-plugin-api/logstash-core-plugin-api.gemspec +++ b/logstash-core-plugin-api/logstash-core-plugin-api.gemspec @@ -11,8 +11,9 @@ if File.exist?(project_versions_yaml_path) # # we ignore the copy in git and we overwrite an existing file # each time we build the logstash-core gem - original_lines = IO.readlines(project_versions_yaml_path) - original_lines << "" + original_lines = IO.read(project_versions_yaml_path) + original_lines.gsub!(/^logstash: (.+?)\n/, "logstash: \\1-#{ENV['VERSION_QUALIFIER']}\n") if ENV['VERSION_QUALIFIER'] + original_lines << "\n" original_lines << "# This is a copy the project level versions.yml into this gem's root and it is created when the gemspec is evaluated." gem_versions_yaml_path = File.expand_path("./versions-gem-copy.yml", File.dirname(__FILE__)) File.open(gem_versions_yaml_path, 'w') do |new_file| diff --git a/logstash-core/lib/logstash/api/commands/default_metadata.rb b/logstash-core/lib/logstash/api/commands/default_metadata.rb index 7c8f309db80..79181cb518e 100644 --- a/logstash-core/lib/logstash/api/commands/default_metadata.rb +++ b/logstash-core/lib/logstash/api/commands/default_metadata.rb @@ -60,7 +60,7 @@ def host end def version - LOGSTASH_CORE_VERSION + LOGSTASH_VERSION end def http_address diff --git a/logstash-core/logstash-core.gemspec b/logstash-core/logstash-core.gemspec index e783f17cd8d..b274f4c1efa 100644 --- a/logstash-core/logstash-core.gemspec +++ b/logstash-core/logstash-core.gemspec @@ -16,8 +16,10 @@ if File.exist?(project_versions_yaml_path) # # we ignore the copy in git and we overwrite an existing file # each time we build the logstash-core gem - original_lines = IO.readlines(project_versions_yaml_path) - original_lines << "" + original_lines = IO.read(project_versions_yaml_path) + original_lines.gsub!(/^logstash: (.+?)\n/, "logstash: \\1-#{ENV['VERSION_QUALIFIER']}\n") if ENV['VERSION_QUALIFIER'] + + original_lines << "\n" original_lines << "# This is a copy the project level versions.yml into this gem's root and it is created when the gemspec is evaluated." gem_versions_yaml_path = File.expand_path("./versions-gem-copy.yml", File.dirname(__FILE__)) File.open(gem_versions_yaml_path, 'w') do |new_file| diff --git a/rakelib/artifacts.rake b/rakelib/artifacts.rake index c16f070dd45..dca08a51039 100644 --- a/rakelib/artifacts.rake +++ b/rakelib/artifacts.rake @@ -19,11 +19,7 @@ namespace "artifact" do SNAPSHOT_BUILD = ENV["RELEASE"] != "1" VERSION_QUALIFIER = ENV["VERSION_QUALIFIER"] LOCAL_ARTIFACTS = ENV["LOCAL_ARTIFACTS"] || "true" - if VERSION_QUALIFIER - PACKAGE_SUFFIX = SNAPSHOT_BUILD ? "-#{VERSION_QUALIFIER}-SNAPSHOT" : "-#{VERSION_QUALIFIER}" - else - PACKAGE_SUFFIX = SNAPSHOT_BUILD ? "-SNAPSHOT" : "" - end + PACKAGE_SUFFIX = SNAPSHOT_BUILD ? "-SNAPSHOT" : "" ## TODO: Install new service files def package_files From 2117e070bcabe7871411bd91d1467633d30700dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Fri, 17 Jan 2025 09:55:55 +0000 Subject: [PATCH 2/3] refactor injection of qualifier according to comments --- .../logstash-core-plugin-api.gemspec | 8 ++++++-- logstash-core/logstash-core.gemspec | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/logstash-core-plugin-api/logstash-core-plugin-api.gemspec b/logstash-core-plugin-api/logstash-core-plugin-api.gemspec index fa58ca3148f..072d4631744 100644 --- a/logstash-core-plugin-api/logstash-core-plugin-api.gemspec +++ b/logstash-core-plugin-api/logstash-core-plugin-api.gemspec @@ -11,8 +11,12 @@ if File.exist?(project_versions_yaml_path) # # we ignore the copy in git and we overwrite an existing file # each time we build the logstash-core gem - original_lines = IO.read(project_versions_yaml_path) - original_lines.gsub!(/^logstash: (.+?)\n/, "logstash: \\1-#{ENV['VERSION_QUALIFIER']}\n") if ENV['VERSION_QUALIFIER'] + original_lines = IO.readlines(project_versions_yaml_path) + if ENV['VERSION_QUALIFIER'] + logstash_version_line = original_lines.find {|line| line.match(/^logstash:/) } + logstash_version_line.chomp! + logstash_version_line << "-#{ENV['VERSION_QUALIFIER']}\n" + end original_lines << "\n" original_lines << "# This is a copy the project level versions.yml into this gem's root and it is created when the gemspec is evaluated." gem_versions_yaml_path = File.expand_path("./versions-gem-copy.yml", File.dirname(__FILE__)) diff --git a/logstash-core/logstash-core.gemspec b/logstash-core/logstash-core.gemspec index b274f4c1efa..22760525eac 100644 --- a/logstash-core/logstash-core.gemspec +++ b/logstash-core/logstash-core.gemspec @@ -16,9 +16,12 @@ if File.exist?(project_versions_yaml_path) # # we ignore the copy in git and we overwrite an existing file # each time we build the logstash-core gem - original_lines = IO.read(project_versions_yaml_path) - original_lines.gsub!(/^logstash: (.+?)\n/, "logstash: \\1-#{ENV['VERSION_QUALIFIER']}\n") if ENV['VERSION_QUALIFIER'] - + original_lines = IO.readlines(project_versions_yaml_path) + if ENV['VERSION_QUALIFIER'] + logstash_version_line = original_lines.find {|line| line.match(/^logstash:/) } + logstash_version_line.chomp! + logstash_version_line << "-#{ENV['VERSION_QUALIFIER']}\n" + end original_lines << "\n" original_lines << "# This is a copy the project level versions.yml into this gem's root and it is created when the gemspec is evaluated." gem_versions_yaml_path = File.expand_path("./versions-gem-copy.yml", File.dirname(__FILE__)) From 480879ae242e0a1219813b82df226ba15eeb1cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Fri, 17 Jan 2025 09:57:58 +0000 Subject: [PATCH 3/3] refactor injection of qualifier according to comments --- logstash-core-plugin-api/logstash-core-plugin-api.gemspec | 1 + logstash-core/logstash-core.gemspec | 1 + 2 files changed, 2 insertions(+) diff --git a/logstash-core-plugin-api/logstash-core-plugin-api.gemspec b/logstash-core-plugin-api/logstash-core-plugin-api.gemspec index 072d4631744..4a599d84b25 100644 --- a/logstash-core-plugin-api/logstash-core-plugin-api.gemspec +++ b/logstash-core-plugin-api/logstash-core-plugin-api.gemspec @@ -12,6 +12,7 @@ if File.exist?(project_versions_yaml_path) # we ignore the copy in git and we overwrite an existing file # each time we build the logstash-core gem original_lines = IO.readlines(project_versions_yaml_path) + # introduce the version qualifier (e.g. beta1, rc1) into the copied yml so it's displayed by Logstash if ENV['VERSION_QUALIFIER'] logstash_version_line = original_lines.find {|line| line.match(/^logstash:/) } logstash_version_line.chomp! diff --git a/logstash-core/logstash-core.gemspec b/logstash-core/logstash-core.gemspec index 22760525eac..5efed823547 100644 --- a/logstash-core/logstash-core.gemspec +++ b/logstash-core/logstash-core.gemspec @@ -17,6 +17,7 @@ if File.exist?(project_versions_yaml_path) # we ignore the copy in git and we overwrite an existing file # each time we build the logstash-core gem original_lines = IO.readlines(project_versions_yaml_path) + # introduce the version qualifier (e.g. beta1, rc1) into the copied yml so it's displayed by Logstash if ENV['VERSION_QUALIFIER'] logstash_version_line = original_lines.find {|line| line.match(/^logstash:/) } logstash_version_line.chomp!