summaryrefslogtreecommitdiff
path: root/scripts/construct-release-environments-versions.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-19 02:38:12 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-19 02:38:12 +0000
commitb18a04d041aa4ef632ec29895b0cee6fea63f3b9 (patch)
treeda279f1767d67759c35d893ea47e2bce129f8bde /scripts/construct-release-environments-versions.rb
parentd56c47033c32d6d32a864e5c16a3b2fd959b08da (diff)
downloadgitlab-ce-b18a04d041aa4ef632ec29895b0cee6fea63f3b9.tar.gz
Add latest changes from gitlab-org/gitlab@15-10-stable-ee
Diffstat (limited to 'scripts/construct-release-environments-versions.rb')
-rwxr-xr-xscripts/construct-release-environments-versions.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/construct-release-environments-versions.rb b/scripts/construct-release-environments-versions.rb
new file mode 100755
index 00000000000..1af45923731
--- /dev/null
+++ b/scripts/construct-release-environments-versions.rb
@@ -0,0 +1,37 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+require 'json'
+
+class ReleaseEnvironmentsModel
+ COMPONENTS = %w[gitaly registry kas mailroom pages gitlab shell].freeze
+
+ # Will generate a json object that has a key for every component and a value which is the environment combined with
+ # short sha
+ # Example:
+ # {
+ # "gitaly": "15-10-stable-c7c5131c",
+ # "registry": "15-10-stable-c7c5131c",
+ # "kas": "15-10-stable-c7c5131c",
+ # "mailroom": "15-10-stable-c7c5131c",
+ # "pages": "15-10-stable-c7c5131c",
+ # "gitlab": "15-10-stable-c7c5131c",
+ # "shell": "15-10-stable-c7c5131c"
+ # }
+ def generate_json(environment)
+ output_json = {}
+ COMPONENTS.each do |component|
+ output_json[component.to_s] = "#{environment}-#{ENV['CI_COMMIT_SHORT_SHA']}"
+ end
+ JSON.generate(output_json)
+ end
+end
+
+# Outputs in `dotenv` format the ENVIRONMENT and VERSIONS to pass to release environments e.g.
+# ENVIRONMENT=15-10-stable
+# VERSIONS={"gitaly":"15-10-stable-c7c5131c","registry":"15-10-stable-c7c5131c","kas":"15-10-stable-c7c5131c", ...
+if $PROGRAM_NAME == __FILE__
+ environment = ENV['CI_COMMIT_REF_SLUG'].sub("-ee", "")
+ puts "ENVIRONMENT=#{environment}"
+ puts "VERSIONS=#{ReleaseEnvironmentsModel.new.generate_json(environment)}"
+end