ci_toolkit 1.5.9 → 1.5.10
Sign up to get free protection for your applications and to get access to all the features.
- 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: 7114e8220c601e7b2674b81cea0f57fb8224082a42aab12e5873f8ccd20e3572
|
4
|
+
data.tar.gz: 3d4fc7c284e0a5d5b3e365bd3220ae30966e83d0580f7ac918edccd75488aaf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c583d06d707bc0376b7e664c48cd94ef800e1169e0d73affc6db979c206e4b8413d3fe205814df0686430ceb14f49799eb28c40eb885d6e7971c4c36a6d1553
|
7
|
+
data.tar.gz: 012b5c539c88d76dc7f37a700400dc7c8eef947dd4d8c30a155a1d0147d1c14828b2e81bf9666dc81e8e380d35c4ce4e4decd6b966161751842821cac38eb44b
|
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: "https://git.smartlife.vodafo.ne/api/v4",
|
11
|
+
private_token: "glpat-DmuAdnz889reaWDwLsb9")
|
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.10
|
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
|