fastlane-plugin-gitlab_tag_release 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3576e025c0f6e57ae410916984b74594266793aadd6af3eed8d32c5dd55f650f
4
+ data.tar.gz: 1efc715003efa68b15401981f0a4d20b5e353bd37a58661395afd85518d355ab
5
+ SHA512:
6
+ metadata.gz: 39f115425c6ad5139e3570ab905cdeba108b25e442efe674badfd64b24daac7ff012ebca23234663e5cca8dbd997d68ad62e9e3836dedb7e99c3fd1935c602c3
7
+ data.tar.gz: 6bc6c05aac440283eb00847bd1052156f249fba7af6dfc11355e975da9a310e973c378d93d38d6d56021ec5a302adcc2ef2969a1e2157aabb6cf4687fae959aa
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Erick Martins <ericknmp@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # gitlab_tag_release plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-gitlab_tag_release)
4
+ [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/erick-martins/fastlane-plugin-gitlab_tag_release/blob/master/LICENSE)
5
+ [![Gem Version](https://badge.fury.io/rb/fastlane-plugin-gitlab_tag_release.svg)](https://badge.fury.io/rb/fastlane-plugin-gitlab_tag_release)
6
+
7
+ ## Getting Started
8
+
9
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-gitlab_tag_release`, add it to your project by running:
10
+
11
+ ```bash
12
+ fastlane add_plugin gitlab_tag_release
13
+ ```
14
+
15
+ ## About gitlab_tag_release
16
+
17
+ Manages gitlab releases
18
+
19
+ ## Example
20
+
21
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
22
+ ```ruby
23
+ lane :test do
24
+ commit = last_git_commit
25
+ assets_links = [{ :name => "hoge", :url => "https://google.com", :filepath => "/binaries/linux-amd64", :link_type => "other" }]
26
+
27
+ # Lists all releases
28
+ gitlab_list_releases(
29
+ endpoint: ENV["GITLAB_ENDPOINT"], # [Optional] String: The API endpoint URL (default: ENV['GITLAB_ENDPOINT'])
30
+ private_token: ENV["GITLAB_PRIVATE_TOKEN"], # [Optional] String: User's private token or OAuth2 access token (default: ENV['GITLAB_PRIVATE_TOKEN'])
31
+ project_id: ENV["GITLAB_PROJECT_ID"], # [Optional] String: The id of this project, given from GitLab. (default: ENV['GITLAB_PROJECT_ID'])
32
+ )
33
+
34
+ # Gets a specific release
35
+ gitlab_get_releases(
36
+ endpoint: ENV["GITLAB_ENDPOINT"], # [Optional] String: The API endpoint URL (default: ENV['GITLAB_ENDPOINT'])
37
+ private_token: ENV["GITLAB_PRIVATE_TOKEN"], # [Optional] String: User's private token or OAuth2 access token (default: ENV['GITLAB_PRIVATE_TOKEN'])
38
+ project_id: ENV["GITLAB_PROJECT_ID"], # [Optional] String: The id of this project, given from GitLab. (default: ENV['GITLAB_PROJECT_ID'])
39
+ tag: "v2.69.0" # [Required] String: The name of the tag. (ex: 1.0)
40
+ )
41
+
42
+ # Creates a release
43
+ # Read more about these parameters here: https://docs.gitlab.com/ee/api/releases/#create-a-release
44
+ gitlab_create_release(
45
+ endpoint: ENV["GITLAB_ENDPOINT"], # [Optional] String: The API endpoint URL (default: ENV['GITLAB_ENDPOINT'])
46
+ private_token: ENV["GITLAB_PRIVATE_TOKEN"], # [Optional] String: User's private token or OAuth2 access token (default: ENV['GITLAB_PRIVATE_TOKEN'])
47
+ project_id: ENV["GITLAB_PROJECT_ID"], # [Optional] String: The id of this project, given from GitLab. (default: ENV['GITLAB_PROJECT_ID'])
48
+ tag: "v2.69.0", # [Required] String: The name of the tag. (ex: 1.0)
49
+ ref: commit[:commit_hash], # [Optional] String: 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
50
+ name: "New release", # [Optional] String: The release name
51
+ description: "Super nice release", # [Optional] String: The description of the release. You can use Markdown
52
+ milestones: ["v1.0", "v1.0-rc"], # [Optional] String: The title of each milestone the release is associated with. GitLab Premium customers can specify group milestones
53
+ assets_links: assets_links # [Optional] String: An array of assets links. Format { "name": String, "url": String, "filepath": String, "link_type": String }
54
+ )
55
+
56
+ # Collects evidence of a release
57
+ gitlab_collect_release_evidence(
58
+ endpoint: ENV["GITLAB_ENDPOINT"], # [Optional] String: The API endpoint URL (default: ENV['GITLAB_ENDPOINT'])
59
+ private_token: ENV["GITLAB_PRIVATE_TOKEN"], # [Optional] String: User's private token or OAuth2 access token (default: ENV['GITLAB_PRIVATE_TOKEN'])
60
+ project_id: ENV["GITLAB_PROJECT_ID"], # [Optional] String: The id of this project, given from GitLab. (default: ENV['GITLAB_PROJECT_ID'])
61
+ tag: "v2.69.0"
62
+ )
63
+
64
+ # Updates a release
65
+ gitlab_update_release(
66
+ endpoint: ENV["GITLAB_ENDPOINT"], # [Optional] String: The API endpoint URL (default: ENV['GITLAB_ENDPOINT'])
67
+ private_token: ENV["GITLAB_PRIVATE_TOKEN"], # [Optional] String: User's private token or OAuth2 access token (default: ENV['GITLAB_PRIVATE_TOKEN'])
68
+ project_id: ENV["GITLAB_PROJECT_ID"], # [Optional] String: The id of this project, given from GitLab. (default: ENV['GITLAB_PROJECT_ID'])
69
+ tag: "v2.69.0", # [Required] String: The name of the tag. (ex: 1.0)
70
+ name: "New release updated",
71
+ description: "Super nice release updated",
72
+ milestones: ["v1.0", "v1.0-rc"],
73
+ )
74
+
75
+ # Deletes a release
76
+ gitlab_delete_release(
77
+ endpoint: ENV["GITLAB_ENDPOINT"], # [Optional] String: The API endpoint URL (default: ENV['GITLAB_ENDPOINT'])
78
+ private_token: ENV["GITLAB_PRIVATE_TOKEN"], # [Optional] String: User's private token or OAuth2 access token (default: ENV['GITLAB_PRIVATE_TOKEN'])
79
+ project_id: ENV["GITLAB_PROJECT_ID"], # [Optional] String: The id of this project, given from GitLab. (default: ENV['GITLAB_PROJECT_ID'])
80
+ tag: "v2.69.1", # [Required] String: The name of the tag. (ex: 1.0)
81
+ including_tag: true # [Optional] Boolean: If true it will delete the tag as well (Default: false)
82
+ )
83
+
84
+ # Deletes a tag
85
+ gitlab_delete_tag(
86
+ endpoint: ENV["GITLAB_ENDPOINT"], # [Optional] String: The API endpoint URL (default: ENV['GITLAB_ENDPOINT'])
87
+ private_token: ENV["GITLAB_PRIVATE_TOKEN"], # [Optional] String: User's private token or OAuth2 access token (default: ENV['GITLAB_PRIVATE_TOKEN'])
88
+ project_id: ENV["GITLAB_PROJECT_ID"], # [Optional] String: The id of this project, given from GitLab. (default: ENV['GITLAB_PROJECT_ID'])
89
+ tag: "v2.69.1" # [Required] String: The name of the tag. (ex: 1.0)
90
+ )
91
+ end
92
+ ```
93
+
94
+ ## Run tests for this plugin
95
+
96
+ To run both the tests, and code style validation, run
97
+
98
+ ```bash
99
+ rake
100
+ ```
101
+
102
+ To automatically fix many of the styling issues, use
103
+ ```bash
104
+ rubocop -a
105
+ ```
106
+
107
+ ## Issues and Feedback
108
+
109
+ For any other issues and feedback about this plugin, please submit it to this repository.
110
+
111
+ ## Troubleshooting
112
+
113
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
114
+
115
+ ## Using _fastlane_ Plugins
116
+
117
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
118
+
119
+ ## About _fastlane_
120
+
121
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,71 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/gitlab_tag_release_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GitlabCollectReleaseEvidenceAction < Action
7
+ def self.run(params)
8
+ response = Helper::GitlabTagReleaseHelper::GitlabClient.new(
9
+ endpoint: params[:endpoint],
10
+ private_token: params[:private_token],
11
+ project_id: params[:project_id]
12
+ )
13
+ .collect_release_evidence(tag: params[:tag])
14
+
15
+ response[:body] < 300
16
+ end
17
+
18
+ def self.description
19
+ "Simple plugin to manage gitlab releases"
20
+ end
21
+
22
+ def self.authors
23
+ ["Erick Martins"]
24
+ end
25
+
26
+ def self.return_value
27
+ # If your method provides a return value, you can describe here what it does
28
+ end
29
+
30
+ def self.details
31
+ # Optional:
32
+ "Simple plugin to manage gitlab releases"
33
+ end
34
+
35
+ def self.available_options
36
+ [
37
+ FastlaneCore::ConfigItem.new(key: :endpoint,
38
+ description: "The API endpoint URL, default: ENV['GITLAB_ENDPOINT']",
39
+ env_name: "GITLAB_ENDPOINT",
40
+ optional: true,
41
+ type: String),
42
+
43
+ FastlaneCore::ConfigItem.new(key: :private_token,
44
+ description: "User's private token or OAuth2 access token",
45
+ env_name: "GITLAB_PRIVATE_TOKEN",
46
+ optional: true,
47
+ type: String),
48
+
49
+ FastlaneCore::ConfigItem.new(key: :project_id,
50
+ description: "The id of this project, given from GitLab. Default ENV[\"GITLAB_PROJECT_ID\"]",
51
+ env_name: "GITLAB_PROJECT_ID",
52
+ optional: true,
53
+ type: String),
54
+
55
+ FastlaneCore::ConfigItem.new(key: :tag,
56
+ description: "The name of the tag. (ex: 1.0)",
57
+ optional: false,
58
+ type: String),
59
+ ]
60
+ end
61
+
62
+ def self.is_supported?(platform)
63
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
64
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
65
+ #
66
+ # [:ios, :mac, :android].include?(platform)
67
+ true
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,112 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/gitlab_tag_release_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GitlabCreateReleaseAction < Action
7
+ def self.run(params)
8
+ response = Helper::GitlabTagReleaseHelper::GitlabClient.new(
9
+ endpoint: params[:endpoint],
10
+ private_token: params[:private_token],
11
+ project_id: params[:project_id]
12
+ ).create_release(
13
+ tag: params[:tag],
14
+ name: params[:name],
15
+ description: params[:description],
16
+ ref: params[:ref],
17
+ milestones: params[:milestones],
18
+ assets_links: params[:assets_links],
19
+ released_at: params[:released_at],
20
+ )
21
+
22
+ if response[:status] >= 300
23
+ UI.user_error!(response[:body][:message])
24
+ end
25
+
26
+ response[:body]
27
+ end
28
+
29
+ def self.description
30
+ "Simple plugin to manage gitlab releases"
31
+ end
32
+
33
+ def self.authors
34
+ ["Erick Martins"]
35
+ end
36
+
37
+ def self.return_value
38
+ # If your method provides a return value, you can describe here what it does
39
+ end
40
+
41
+ def self.details
42
+ # Optional:
43
+ "Simple plugin to manage gitlab releases"
44
+ end
45
+
46
+ def self.available_options
47
+ [
48
+ FastlaneCore::ConfigItem.new(key: :endpoint,
49
+ description: "The API endpoint URL, default: ENV['GITLAB_ENDPOINT']",
50
+ env_name: "GITLAB_ENDPOINT",
51
+ optional: true,
52
+ type: String),
53
+
54
+ FastlaneCore::ConfigItem.new(key: :private_token,
55
+ description: "User's private token or OAuth2 access token",
56
+ env_name: "GITLAB_PRIVATE_TOKEN",
57
+ optional: true,
58
+ type: String),
59
+
60
+ FastlaneCore::ConfigItem.new(key: :project_id,
61
+ description: "The id of this project, given from GitLab. Default ENV[\"GITLAB_PROJECT_ID\"]",
62
+ env_name: "GITLAB_PROJECT_ID",
63
+ optional: true,
64
+ type: String),
65
+
66
+ FastlaneCore::ConfigItem.new(key: :tag,
67
+ description: "The name of the tag. (ex: 1.0)",
68
+ optional: false,
69
+ type: String),
70
+
71
+ FastlaneCore::ConfigItem.new(key: :name,
72
+ description: "The release name",
73
+ optional: true,
74
+ type: String),
75
+
76
+ FastlaneCore::ConfigItem.new(key: :description,
77
+ description: "The description of the release. You can use Markdown",
78
+ optional: true,
79
+ type: String),
80
+
81
+ FastlaneCore::ConfigItem.new(key: :ref,
82
+ 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",
83
+ optional: false,
84
+ type: String),
85
+
86
+ FastlaneCore::ConfigItem.new(key: :milestones,
87
+ description: "The title of each milestone the release is associated with. GitLab Premium customers can specify group milestones",
88
+ optional: true,
89
+ type: Array),
90
+
91
+ FastlaneCore::ConfigItem.new(key: :assets_links,
92
+ description: "An array of assets links. Format { \"name\": String, \"url\": String, \"filepath\": String, \"link_type\": String }",
93
+ optional: true,
94
+ type: Array),
95
+
96
+ FastlaneCore::ConfigItem.new(key: :released_at,
97
+ description: "The date when the release is/was ready. Defaults to the current time. Expected in ISO 8601 format (2019-03-15T08:00:00Z)",
98
+ optional: true,
99
+ type: String),
100
+ ]
101
+ end
102
+
103
+ def self.is_supported?(platform)
104
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
105
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
106
+ #
107
+ # [:ios, :mac, :android].include?(platform)
108
+ true
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,93 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/gitlab_tag_release_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GitlabDeleteReleaseAction < Action
7
+ def self.run(params)
8
+ UI.important "Deleting release from tag \"#{params[:tag]}\"..."
9
+
10
+ response = Helper::GitlabTagReleaseHelper::GitlabClient.new(
11
+ endpoint: params[:endpoint],
12
+ private_token: params[:private_token],
13
+ project_id: params[:project_id]
14
+ ).delete_release_with!(tag: params[:tag])
15
+
16
+ if response[:status] >= 300
17
+ UI.user_error!(response[:body][:message])
18
+ end
19
+
20
+ UI.success "Release from tag \"#{params[:tag]}\" deleted succesfuly"
21
+ delete_release_body = response[:body]
22
+
23
+ if params[:including_tag]
24
+ other_action.gitlab_delete_tag(
25
+ endpoint: params[:endpoint],
26
+ private_token: params[:private_token],
27
+ project_id: params[:project_id],
28
+ tag: params[:tag]
29
+ )
30
+ end
31
+
32
+ delete_release_body
33
+ end
34
+
35
+ def self.description
36
+ "Simple plugin to manage gitlab releases"
37
+ end
38
+
39
+ def self.authors
40
+ ["Erick Martins"]
41
+ end
42
+
43
+ def self.return_value
44
+ # If your method provides a return value, you can describe here what it does
45
+ end
46
+
47
+ def self.details
48
+ # Optional:
49
+ "Simple plugin to manage gitlab releases"
50
+ end
51
+
52
+ def self.available_options
53
+ [
54
+ FastlaneCore::ConfigItem.new(key: :endpoint,
55
+ description: "The API endpoint URL, default: ENV['GITLAB_ENDPOINT']",
56
+ env_name: "GITLAB_ENDPOINT",
57
+ optional: true,
58
+ type: String),
59
+
60
+ FastlaneCore::ConfigItem.new(key: :private_token,
61
+ description: "User's private token or OAuth2 access token",
62
+ env_name: "GITLAB_PRIVATE_TOKEN",
63
+ optional: true,
64
+ type: String),
65
+
66
+ FastlaneCore::ConfigItem.new(key: :project_id,
67
+ description: "The id of this project, given from GitLab. Default ENV[\"GITLAB_PROJECT_ID\"]",
68
+ env_name: "GITLAB_PROJECT_ID",
69
+ optional: true,
70
+ type: String),
71
+
72
+ FastlaneCore::ConfigItem.new(key: :tag,
73
+ description: "The name of the tag. (ex: 1.0)",
74
+ optional: false,
75
+ type: String),
76
+
77
+ FastlaneCore::ConfigItem.new(key: :including_tag,
78
+ description: "If true it will delete the tag as well",
79
+ optional: false,
80
+ type: Boolean),
81
+ ]
82
+ end
83
+
84
+ def self.is_supported?(platform)
85
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
86
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
87
+ #
88
+ # [:ios, :mac, :android].include?(platform)
89
+ true
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,78 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/gitlab_tag_release_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GitlabDeleteTagAction < Action
7
+ def self.run(params)
8
+ UI.important "Deleting tag \"#{params[:tag]}\"..."
9
+
10
+ response = Helper::GitlabTagReleaseHelper::GitlabClient.new(
11
+ endpoint: params[:endpoint],
12
+ private_token: params[:private_token],
13
+ project_id: params[:project_id]
14
+ ).delete!(tag: params[:tag])
15
+
16
+ if response[:status] >= 300
17
+ UI.user_error!(response[:body][:message])
18
+ end
19
+
20
+ UI.success "Tag \"#{params[:tag]}\" deleted succesfuly"
21
+
22
+ response[:body]
23
+ end
24
+
25
+ def self.description
26
+ "Simple plugin to manage gitlab releases"
27
+ end
28
+
29
+ def self.authors
30
+ ["Erick Martins"]
31
+ end
32
+
33
+ def self.return_value
34
+ # If your method provides a return value, you can describe here what it does
35
+ end
36
+
37
+ def self.details
38
+ # Optional:
39
+ "Simple plugin to manage gitlab releases"
40
+ end
41
+
42
+ def self.available_options
43
+ [
44
+ FastlaneCore::ConfigItem.new(key: :endpoint,
45
+ description: "The API endpoint URL, default: ENV['GITLAB_ENDPOINT']",
46
+ env_name: "GITLAB_ENDPOINT",
47
+ optional: true,
48
+ type: String),
49
+
50
+ FastlaneCore::ConfigItem.new(key: :private_token,
51
+ description: "User's private token or OAuth2 access token",
52
+ env_name: "GITLAB_PRIVATE_TOKEN",
53
+ optional: true,
54
+ type: String),
55
+
56
+ FastlaneCore::ConfigItem.new(key: :project_id,
57
+ description: "The id of this project, given from GitLab. Default ENV[\"GITLAB_PROJECT_ID\"]",
58
+ env_name: "GITLAB_PROJECT_ID",
59
+ optional: true,
60
+ type: String),
61
+
62
+ FastlaneCore::ConfigItem.new(key: :tag,
63
+ description: "The name of the tag. (ex: 1.0)",
64
+ optional: false,
65
+ type: String),
66
+ ]
67
+ end
68
+
69
+ def self.is_supported?(platform)
70
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
71
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
72
+ #
73
+ # [:ios, :mac, :android].include?(platform)
74
+ true
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,68 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/gitlab_tag_release_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GitlabGetReleaseAction < Action
7
+ def self.run(params)
8
+ Helper::GitlabTagReleaseHelper::GitlabClient.new(
9
+ endpoint: params[:endpoint],
10
+ private_token: params[:private_token],
11
+ project_id: params[:project_id]
12
+ ).get_release_by(tag: params[:tag])
13
+ end
14
+
15
+ def self.description
16
+ "Simple plugin to manage gitlab releases"
17
+ end
18
+
19
+ def self.authors
20
+ ["Erick Martins"]
21
+ end
22
+
23
+ def self.return_value
24
+ # If your method provides a return value, you can describe here what it does
25
+ end
26
+
27
+ def self.details
28
+ # Optional:
29
+ "Simple plugin to manage gitlab releases"
30
+ end
31
+
32
+ def self.available_options
33
+ [
34
+ FastlaneCore::ConfigItem.new(key: :endpoint,
35
+ description: "The API endpoint URL, default: ENV['GITLAB_ENDPOINT']",
36
+ env_name: "GITLAB_ENDPOINT",
37
+ optional: true,
38
+ type: String),
39
+
40
+ FastlaneCore::ConfigItem.new(key: :private_token,
41
+ description: "User's private token or OAuth2 access token",
42
+ env_name: "GITLAB_PRIVATE_TOKEN",
43
+ optional: true,
44
+ type: String),
45
+
46
+ FastlaneCore::ConfigItem.new(key: :project_id,
47
+ description: "The id of this project, given from GitLab. Default ENV[\"GITLAB_PROJECT_ID\"]",
48
+ env_name: "GITLAB_PROJECT_ID",
49
+ optional: true,
50
+ type: String),
51
+
52
+ FastlaneCore::ConfigItem.new(key: :tag,
53
+ description: "The name of the tag. (ex: 1.0)",
54
+ optional: false,
55
+ type: String),
56
+ ]
57
+ end
58
+
59
+ def self.is_supported?(platform)
60
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
61
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
62
+ #
63
+ # [:ios, :mac, :android].include?(platform)
64
+ true
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,63 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/gitlab_tag_release_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GitlabListReleasesAction < Action
7
+ def self.run(params)
8
+ Helper::GitlabTagReleaseHelper::GitlabClient.new(
9
+ endpoint: params[:endpoint],
10
+ private_token: params[:private_token],
11
+ project_id: params[:project_id]
12
+ ).list_releases!
13
+ end
14
+
15
+ def self.description
16
+ "Simple plugin to manage gitlab releases"
17
+ end
18
+
19
+ def self.authors
20
+ ["Erick Martins"]
21
+ end
22
+
23
+ def self.return_value
24
+ # If your method provides a return value, you can describe here what it does
25
+ end
26
+
27
+ def self.details
28
+ # Optional:
29
+ "Simple plugin to manage gitlab releases"
30
+ end
31
+
32
+ def self.available_options
33
+ [
34
+ FastlaneCore::ConfigItem.new(key: :endpoint,
35
+ description: "The API endpoint URL, default: ENV['GITLAB_ENDPOINT']",
36
+ env_name: "GITLAB_ENDPOINT",
37
+ optional: true,
38
+ type: String),
39
+
40
+ FastlaneCore::ConfigItem.new(key: :private_token,
41
+ description: "User's private token or OAuth2 access token. Default ENV[\"GITLAB_PRIVATE_TOKEN\"]",
42
+ env_name: "GITLAB_PRIVATE_TOKEN",
43
+ optional: true,
44
+ type: String),
45
+
46
+ FastlaneCore::ConfigItem.new(key: :project_id,
47
+ description: "The id of this project, given from GitLab. Default ENV[\"GITLAB_PROJECT_ID\"]",
48
+ env_name: "GITLAB_PROJECT_ID",
49
+ optional: true,
50
+ type: String)
51
+ ]
52
+ end
53
+
54
+ def self.is_supported?(platform)
55
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
56
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
57
+ #
58
+ # [:ios, :mac, :android].include?(platform)
59
+ true
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,100 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/gitlab_tag_release_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GitlabUpdateReleaseAction < Action
7
+ def self.run(params)
8
+ response = Helper::GitlabTagReleaseHelper::GitlabClient.new(
9
+ endpoint: params[:endpoint],
10
+ private_token: params[:private_token],
11
+ project_id: params[:project_id]
12
+ ).update_release(
13
+ tag: params[:tag],
14
+ name: params[:name],
15
+ description: params[:description],
16
+ milestones: params[:milestones],
17
+ released_at: params[:released_at],
18
+ )
19
+
20
+ if response[:status] >= 300
21
+ UI.user_error!(response[:body][:message])
22
+ end
23
+
24
+ response[:body]
25
+ end
26
+
27
+ def self.description
28
+ "Simple plugin to manage gitlab releases"
29
+ end
30
+
31
+ def self.authors
32
+ ["Erick Martins"]
33
+ end
34
+
35
+ def self.return_value
36
+ # If your method provides a return value, you can describe here what it does
37
+ end
38
+
39
+ def self.details
40
+ # Optional:
41
+ "Simple plugin to manage gitlab releases"
42
+ end
43
+
44
+ def self.available_options
45
+ [
46
+ FastlaneCore::ConfigItem.new(key: :endpoint,
47
+ description: "The API endpoint URL, default: ENV['GITLAB_ENDPOINT']",
48
+ env_name: "GITLAB_ENDPOINT",
49
+ optional: true,
50
+ type: String),
51
+
52
+ FastlaneCore::ConfigItem.new(key: :private_token,
53
+ description: "User's private token or OAuth2 access token",
54
+ env_name: "GITLAB_PRIVATE_TOKEN",
55
+ optional: true,
56
+ type: String),
57
+
58
+ FastlaneCore::ConfigItem.new(key: :project_id,
59
+ description: "The id of this project, given from GitLab. Default ENV[\"GITLAB_PROJECT_ID\"]",
60
+ env_name: "GITLAB_PROJECT_ID",
61
+ optional: true,
62
+ type: String),
63
+
64
+ FastlaneCore::ConfigItem.new(key: :tag,
65
+ description: "The name of the tag. (ex: 1.0)",
66
+ optional: false,
67
+ type: String),
68
+
69
+ FastlaneCore::ConfigItem.new(key: :name,
70
+ description: "The release name",
71
+ optional: true,
72
+ type: String),
73
+
74
+ FastlaneCore::ConfigItem.new(key: :description,
75
+ description: "The description of the release. You can use Markdown",
76
+ optional: true,
77
+ type: String),
78
+
79
+ FastlaneCore::ConfigItem.new(key: :milestones,
80
+ description: "The title of each milestone the release is associated with. GitLab Premium customers can specify group milestones",
81
+ optional: true,
82
+ type: Array),
83
+
84
+ FastlaneCore::ConfigItem.new(key: :released_at,
85
+ description: "The date when the release is/was ready. Defaults to the current time. Expected in ISO 8601 format (2019-03-15T08:00:00Z)",
86
+ optional: true,
87
+ type: String),
88
+ ]
89
+ end
90
+
91
+ def self.is_supported?(platform)
92
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
93
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
94
+ #
95
+ # [:ios, :mac, :android].include?(platform)
96
+ true
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,142 @@
1
+ require 'fastlane_core/ui/ui'
2
+ require 'faraday'
3
+ require 'uri'
4
+
5
+ module Fastlane
6
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
7
+
8
+ module Helper
9
+ class GitlabTagReleaseHelper
10
+ # class methods that you define here become available in your action
11
+ # as `Helper::GitlabTagReleaseHelper.your_method`
12
+ #
13
+ def self.show_message
14
+ UI.message("Hello from the gitlab_tag_release plugin helper!")
15
+ end
16
+
17
+ class GitlabService
18
+ def initialize(options = {})
19
+ @private_token = options[:private_token]
20
+ @project_id = options[:project_id]
21
+
22
+ @endpoint = URI.join(options[:endpoint], "projects/#{options[:project_id]}/").to_s
23
+ end
24
+
25
+ def get(path:, paramenters: {}, headers: {})
26
+ url = get_url(path)
27
+ response = Faraday.get(url, paramenters, merge_headers(headers: headers))
28
+
29
+ JSON.parse(response.body, symbolize_names: true)
30
+ end
31
+
32
+ def post(path:, body: {}, headers: {})
33
+ url = get_url(path)
34
+ parse_response Faraday.post(url, body.to_json, merge_headers(headers: headers))
35
+ end
36
+
37
+ def put(path:, body: {}, headers: {})
38
+ url = get_url(path)
39
+ parse_response Faraday.put(url, body.to_json, merge_headers(headers: headers))
40
+ end
41
+
42
+ def delete!(path:, paramenters: {}, headers: {})
43
+ url = get_url(path)
44
+ response = Faraday.delete(url, paramenters, merge_headers(headers: headers))
45
+ parse_response response
46
+ end
47
+
48
+ private
49
+
50
+ def parse_response(response)
51
+ body = {}
52
+ if response.body.is_a?(String)
53
+ begin
54
+ body = JSON.parse(response.body.strip, symbolize_names: true)
55
+ rescue => ex
56
+ UI.important "Could not convert json response into hash"
57
+ UI.error ex.message
58
+ body = response.body
59
+ end
60
+ else
61
+ body = response.body
62
+ end
63
+
64
+ {
65
+ :status => response.status,
66
+ :body => body
67
+ }
68
+ end
69
+
70
+ def get_url(path)
71
+ URI.join(@endpoint, path).to_s
72
+ end
73
+
74
+ def merge_headers(headers: {})
75
+ full_headers = {
76
+ "PRIVATE-TOKEN" => @private_token,
77
+ "Content-Type" => "application/json"
78
+ }
79
+ full_headers.merge headers
80
+
81
+ full_headers
82
+ end
83
+ end
84
+
85
+
86
+ class GitlabClient
87
+ def initialize(options = {})
88
+ @service = Helper::GitlabTagReleaseHelper::GitlabService.new(options)
89
+ end
90
+
91
+ def list_releases!
92
+ @service.get(path: 'releases/')
93
+ end
94
+
95
+ def get_release_by(tag:)
96
+ @service.get(path: "releases/#{tag}")
97
+ end
98
+
99
+ def create_release(tag:, ref:, name: "", description: "", milestones: nil, assets_links: nil, released_at: nil)
100
+ @service.post(
101
+ path: 'releases/',
102
+ body: {
103
+ :tag_name => tag,
104
+ :ref => ref,
105
+ :name => name,
106
+ :description => description,
107
+ :milestones => milestones,
108
+ :assets => {
109
+ :links => assets_links
110
+ },
111
+ :released_at => released_at
112
+ }.compact
113
+ )
114
+ end
115
+
116
+ def update_release(tag:, name: "", description: "", milestones: nil, released_at: nil)
117
+ @service.put(
118
+ path: "releases/#{tag}/",
119
+ body: {
120
+ :name => name,
121
+ :description => description,
122
+ :milestones => milestones,
123
+ :released_at => released_at
124
+ }.compact
125
+ )
126
+ end
127
+
128
+ def collect_release_evidence(tag:)
129
+ @service.post(path: "releases/#{tag}/evidence")
130
+ end
131
+
132
+ def delete_release_with!(tag:)
133
+ @service.delete!(path: "releases/#{tag}")
134
+ end
135
+
136
+ def delete!(tag:)
137
+ @service.delete!(path: "repository/tags/#{tag}")
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module GitlabTagRelease
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/gitlab_tag_release/version'
2
+
3
+ module Fastlane
4
+ module GitlabTagRelease
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::GitlabTagRelease.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-gitlab_tag_release
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Erick Martins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fastlane
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.99.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.99.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec_junit_formatter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.12.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.12.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-require_tools
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
154
+ email: ericknmp@gmail.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/gitlab_tag_release.rb
162
+ - lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_collect_release_evidence_action.rb
163
+ - lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_create_release_action.rb
164
+ - lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_delete_release_action.rb
165
+ - lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_delete_tag_action.rb
166
+ - lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_get_release_action.rb
167
+ - lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_list_releases_action.rb
168
+ - lib/fastlane/plugin/gitlab_tag_release/actions/gitlab_update_release_action.rb
169
+ - lib/fastlane/plugin/gitlab_tag_release/helper/gitlab_tag_release_helper.rb
170
+ - lib/fastlane/plugin/gitlab_tag_release/version.rb
171
+ homepage: https://github.com/erick-martins/fastlane-plugin-gitlab_tag_release
172
+ licenses:
173
+ - MIT
174
+ metadata: {}
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '2.5'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubygems_version: 3.2.4
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: Simple plugin to manage gitlab releases
194
+ test_files: []