debian-mirror-gitlab/lib/gitlab/ci/build/releaser.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.1 KiB
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Build
class Releaser
BASE_COMMAND = 'release-cli create'
2020-07-28 23:09:34 +05:30
SINGLE_FLAGS = %i[name description tag_name ref released_at].freeze
ARRAY_FLAGS = %i[milestones].freeze
2020-06-23 00:09:42 +05:30
attr_reader :config
def initialize(config:)
@config = config
end
def script
command = BASE_COMMAND.dup
2020-07-28 23:09:34 +05:30
single_flags.each { |k, v| command.concat(" --#{k.to_s.dasherize} \"#{v}\"") }
array_commands.each { |k, v| v.each { |elem| command.concat(" --#{k.to_s.singularize.dasherize} \"#{elem}\"") } }
2021-06-08 01:23:25 +05:30
asset_links.each { |link| command.concat(" --assets-link #{stringified_json(link)}") }
2020-06-23 00:09:42 +05:30
2021-06-08 01:23:25 +05:30
[command.freeze]
2020-07-28 23:09:34 +05:30
end
private
def single_flags
config.slice(*SINGLE_FLAGS)
end
def array_commands
config.slice(*ARRAY_FLAGS)
2020-06-23 00:09:42 +05:30
end
2021-06-08 01:23:25 +05:30
def asset_links
config.dig(:assets, :links) || []
end
def stringified_json(object)
"#{object.to_json.to_json}"
end
2020-06-23 00:09:42 +05:30
end
end
end
end