Class: Fastlane::Actions::GitlabCreateReleaseAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



33
34
35
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb', line 33

def self.authors
  ["Erick Martins"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb', line 46

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :endpoint,
                         description: "The API endpoint URL, default: ENV['GITLAB_ENDPOINT']",
                            env_name: "GITLAB_ENDPOINT",
                            optional: true,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :private_token,
                         description: "User's private token or OAuth2 access token",
                            env_name: "GITLAB_PRIVATE_TOKEN",
                            optional: true,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :project_id,
                         description: "The id of this project, given from GitLab. Default ENV[\"GITLAB_PROJECT_ID\"]",
                            env_name: "GITLAB_PROJECT_ID",
                            optional: true,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :tag,
                         description: "The name of the tag. (ex: 1.0)",
                            optional: false,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :name,
                         description: "The release name",
                            optional: true,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :description,
                         description: "The description of the release. You can use Markdown",
                            optional: true,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :ref,
                         description: "If a tag specified in tag_name doesn’t exist, the release is created from ref and tagged with tag_name. It can be a commit SHA, another tag name, or a branch name",
                            optional: false,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :milestones,
                         description: "The title of each milestone the release is associated with. GitLab Premium customers can specify group milestones",
                            optional: true,
                                type: Array),

    FastlaneCore::ConfigItem.new(key: :assets_links,
                         description: "An array of assets links. Format { \"name\": String, \"url\": String, \"filepath\": String, \"link_type\": String }",
                            optional: true,
                                type: Array),

    FastlaneCore::ConfigItem.new(key: :released_at,
                         description: "The date when the release is/was ready. Defaults to the current time. Expected in ISO 8601 format (2019-03-15T08:00:00Z)",
                            optional: true,
                                type: String),
  ]
end

.descriptionObject



29
30
31
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb', line 29

def self.description
  "Simple plugin to manage gitlab releases"
end

.detailsObject



41
42
43
44
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb', line 41

def self.details
  # Optional:
  "Simple plugin to manage gitlab releases"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
106
107
108
109
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb', line 103

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



37
38
39
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb', line 37

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb', line 7

def self.run(params)
  response = Helper::GitlabTagReleaseHelper::GitlabClient.new(
    endpoint: params[:endpoint],
    private_token: params[:private_token],
    project_id: params[:project_id]
  ).create_release(
    tag: params[:tag],
    name: params[:name],
    description: params[:description],
    ref: params[:ref],
    milestones: params[:milestones],
    assets_links: params[:assets_links],
    released_at: params[:released_at],
  )

  if response[:status] >= 300
    UI.user_error!(response[:body][:message])
  end 

  response[:body]
end