Class: Fastlane::Actions::GitlabDeleteReleaseAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



39
40
41
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_delete_release_action.rb', line 39

def self.authors
  ["Erick Martins"]
end

.available_optionsObject



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

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: :including_tag,
                         description: "If true it will delete the tag as well",
                            optional: false,
                                type: Boolean),
  ]
end

.descriptionObject



35
36
37
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_delete_release_action.rb', line 35

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

.detailsObject



47
48
49
50
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_delete_release_action.rb', line 47

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
87
88
89
90
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_delete_release_action.rb', line 84

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



43
44
45
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_delete_release_action.rb', line 43

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
28
29
30
31
32
33
# File 'lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_delete_release_action.rb', line 7

def self.run(params)
  UI.important "Deleting release from tag \"#{params[:tag]}\"..."

  response = Helper::GitlabTagReleaseHelper::GitlabClient.new(
    endpoint: params[:endpoint],
    private_token: params[:private_token],
    project_id: params[:project_id]
  ).delete_release_with!(tag: params[:tag])

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

  UI.success "Release from tag \"#{params[:tag]}\" deleted succesfuly"
  delete_release_body = response[:body]

  if params[:including_tag]
    other_action.gitlab_delete_tag(
      endpoint: params[:endpoint],
      private_token: params[:private_token],
      project_id: params[:project_id],
      tag: params[:tag]
    )
  end

  delete_release_body
end