ci_toolkit 1.5.8 → 1.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ci_toolkit/bitrise_env.rb +2 -1
- data/lib/ci_toolkit/gitlab_release.rb +73 -0
- data/lib/ci_toolkit.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a951dd9097d65107fc3fa9dd13829ec438b4ce93fe45e2fba29a6397bf19cd6
|
4
|
+
data.tar.gz: 711207dc90fdc9ecd97c558bef5f094822a1d35c169aaf0e8dc933e1181cc74b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ef6a46e827451086ddc6c30e06ad09a12a4f9a6784f77dd8aec6f0f964e273fe1f95fed6fe2ea3afcd9b7f4b0266be1888dc68391d3bdb547cf11b83bc4de5c
|
7
|
+
data.tar.gz: 27c680c4eb29d14aa04d1c3d4813e94f23059d39b4e10abb33d5bcbb441ea50f51b714f384c124315b3b3fbf1ad80c2df5fa90cf35194c1138f7f94b374e629c
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "open3"
|
4
|
+
|
5
|
+
module CiToolkit
|
6
|
+
# Can be used to create gitlab project releases and upload asset to project uploads
|
7
|
+
class GitlabRelease
|
8
|
+
def initialize(
|
9
|
+
env = CiToolkit::BitriseEnv.new,
|
10
|
+
client = Gitlab.client(endpoint: ENV["GITLAB_API_URL"] || "",
|
11
|
+
private_token: ENV["GITLAB_USER_PRIVATE_TOKEN"] || "")
|
12
|
+
)
|
13
|
+
@repo_slug = env.repository_slug
|
14
|
+
@client = client
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_release(
|
18
|
+
project_id:,
|
19
|
+
name:,
|
20
|
+
description:,
|
21
|
+
tag_name:,
|
22
|
+
file_name:
|
23
|
+
)
|
24
|
+
release_details = {
|
25
|
+
name: name,
|
26
|
+
tag_name: tag_name,
|
27
|
+
description: description,
|
28
|
+
assets: { links: [get_assets_details(project_id, tag_name, file_name)] }
|
29
|
+
}
|
30
|
+
|
31
|
+
@client.create_project_release(@repo_slug, release_details)
|
32
|
+
end
|
33
|
+
|
34
|
+
# rubocop:disable Metrics/MethodLength
|
35
|
+
def upload_file(project_id:, tag_name:, full_path_to_file:)
|
36
|
+
result = ""
|
37
|
+
exit_status = nil
|
38
|
+
curl_command = get_curl_command(project_id, tag_name, full_path_to_file)
|
39
|
+
Open3.popen2e(*curl_command) do |_stdin, io, thread|
|
40
|
+
io.sync = true
|
41
|
+
io.each do |line|
|
42
|
+
result = line.strip
|
43
|
+
end
|
44
|
+
exit_status = thread.value
|
45
|
+
end
|
46
|
+
unless exit_status.exitstatus.zero?
|
47
|
+
raise StandardError, "Exit status of command '#{curl_command}' was #{exit_status.exitstatus} instead of 0."
|
48
|
+
end
|
49
|
+
|
50
|
+
result
|
51
|
+
end
|
52
|
+
# rubocop:enable Metrics/MethodLength
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def get_curl_command(project_id, tag_name, full_path_to_file)
|
57
|
+
upload_url = generic_package_download_url(project_id, tag_name, File.basename(full_path_to_file))
|
58
|
+
"curl --header 'PRIVATE-TOKEN: #{@client.private_token}' --upload-file '#{full_path_to_file}' '#{upload_url}'"
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_assets_details(project_id, tag_name, file_name)
|
62
|
+
package_download_url = generic_package_download_url(project_id, tag_name, file_name)
|
63
|
+
{
|
64
|
+
name: file_name,
|
65
|
+
url: package_download_url
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def generic_package_download_url(project_id, tag_name, file_name)
|
70
|
+
"#{@client.endpoint}/projects/#{project_id}/packages/generic/#{@repo_slug}/#{tag_name}/#{file_name}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/ci_toolkit.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gero Keller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/ci_toolkit/github_bot.rb
|
229
229
|
- lib/ci_toolkit/github_pr.rb
|
230
230
|
- lib/ci_toolkit/gitlab_pr.rb
|
231
|
+
- lib/ci_toolkit/gitlab_release.rb
|
231
232
|
- lib/ci_toolkit/jira.rb
|
232
233
|
- lib/ci_toolkit/pr_messenger.rb
|
233
234
|
- lib/ci_toolkit/pr_messenger_text.rb
|