Class: Fastlane::Actions::CreateReleaseAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



104
105
106
107
# File 'lib/fastlane/plugin/semantic_release/actions/create_release.rb', line 104

def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ["xotahal"]
end

.available_optionsObject



44
45
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
# File 'lib/fastlane/plugin/semantic_release/actions/create_release.rb', line 44

def self.available_options
  # Define all options your action supports.

  # Below a few examples
  [
    FastlaneCore::ConfigItem.new(
      key: :description,
      description: "Release note description",
      default_value: "",
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :title,
      description: "Title for release notes",
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :endpoint,
      description: "Gitlab endpoint",
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :project_id,
      description: "Gitlab project id",
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :private_token,
      description: "Gitlab user private token",
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :tag,
      description: "Release tag",
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :branch_name,
      description: "Git branch name",
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :assets,
      description: "Release assets",
      optional: true
    )
  ]
end

.descriptionObject



36
37
38
# File 'lib/fastlane/plugin/semantic_release/actions/create_release.rb', line 36

def self.description
  "Create Gitlab release"
end

.detailsObject



40
41
42
# File 'lib/fastlane/plugin/semantic_release/actions/create_release.rb', line 40

def self.details
  "Create Gitlab release"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


109
110
111
112
# File 'lib/fastlane/plugin/semantic_release/actions/create_release.rb', line 109

def self.is_supported?(platform)
  # you can do things like
  true
end

.outputObject



93
94
95
96
97
# File 'lib/fastlane/plugin/semantic_release/actions/create_release.rb', line 93

def self.output
  # Define the shared values you are going to provide
  # Example
  []
end

.return_valueObject



99
100
101
102
# File 'lib/fastlane/plugin/semantic_release/actions/create_release.rb', line 99

def self.return_value
  # If your method provides a return value, you can describe here what it does
  "Returns generated release notes as a string"
end

.run(params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fastlane/plugin/semantic_release/actions/create_release.rb', line 13

def self.run(params)
  uri = URI("#{params[:endpoint]}/projects/#{params[:project_id]}/releases")
  res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
    req = Net::HTTP::Post.new(uri)
    req['Content-Type'] = 'application/json'
    req['PRIVATE-TOKEN'] = params[:private_token]
    req.body = {
      "assets": params[:assets],
      "description": params[:description],
      "milestones": [],
      "name": params[:title],
      "ref": params[:branch_name],
      "tag_name": params[:tag]
    }.to_json
    res = http.request(req)
    res
  end
end