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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0eebcc016a93756c6eb7c87242c7f8acb84c5b5368a4263431779e6546a36ba
4
- data.tar.gz: ad3d0ee8e23a388ef198980dd703eb751fb7dbdc6076edcf3f26d8106786c5ca
3
+ metadata.gz: 7114e8220c601e7b2674b81cea0f57fb8224082a42aab12e5873f8ccd20e3572
4
+ data.tar.gz: 3d4fc7c284e0a5d5b3e365bd3220ae30966e83d0580f7ac918edccd75488aaf4
5
5
  SHA512:
6
- metadata.gz: 29708a410ca02b109df6e15c3fccd72972c68189c52823b0d446bb09df2f810c7ef3cb073fa50b260430eb90faa490b0f7907289c0b8f999a13886c9d9a5060e
7
- data.tar.gz: 2fddf0508c6cd943f3ac7d879c22971c3a9990c92aab46718a56d207714e70baf7ddc267aeea7b6086c40458b2ea13a3d2c514d18251974b994775d08153250e
6
+ metadata.gz: 3c583d06d707bc0376b7e664c48cd94ef800e1169e0d73affc6db979c206e4b8413d3fe205814df0686430ceb14f49799eb28c40eb885d6e7971c4c36a6d1553
7
+ data.tar.gz: 012b5c539c88d76dc7f37a700400dc7c8eef947dd4d8c30a155a1d0147d1c14828b2e81bf9666dc81e8e380d35c4ce4e4decd6b966161751842821cac38eb44b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci_toolkit (1.5.9)
4
+ ci_toolkit (1.5.10)
5
5
  faraday
6
6
  faraday_middleware
7
7
  gitlab
@@ -9,7 +9,8 @@ module CiToolkit
9
9
  :app_url,
10
10
  :git_branch,
11
11
  :app_slug,
12
- :git_commit
12
+ :git_commit,
13
+ :repository_slug
13
14
 
14
15
  def initialize(options = {
15
16
  build_number: ENV["BITRISE_BUILD_NUMBER"],
@@ -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
@@ -8,6 +8,7 @@ require "ci_toolkit/dvcs_pr"
8
8
  require "ci_toolkit/github_bot"
9
9
  require "ci_toolkit/github_pr"
10
10
  require "ci_toolkit/gitlab_pr"
11
+ require "ci_toolkit/gitlab_release"
11
12
  require "ci_toolkit/dvcs_pr_factory"
12
13
  require "ci_toolkit/git"
13
14
  require "ci_toolkit/jira"
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.9
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-06-28 00:00:00.000000000 Z
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