renuo-cli 4.14.1 → 4.16.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d640a2a344a4f7297eaa13bef43760785530de9f46deef2a4016665b5ced8e8
4
- data.tar.gz: 1fc8e948cf5c4ef86c6be83f001338cef37a84da78088c7929d162d7e891c6e9
3
+ metadata.gz: b7d2be942a488e9f935ad409f20fa275aea27af14713c6b98b155718208fbbbe
4
+ data.tar.gz: 8b854cf2514442624fe57d6f25e6540575140f14b2ece1ecda41ad2f5ef767cb
5
5
  SHA512:
6
- metadata.gz: 7a11af0c25dd6c23eecda8f9e588ff9a599714c5e9b8b9ef9d41c3488d28a71ab834c1789cddb4aa81a73eefb72f3ce98d028b263c81fe6dd2f108f58ea3c7af
7
- data.tar.gz: 5c323269241ed04e97243bf8009aa527fa508491e5a62169d4c77303496a17c1ced584537ab7cea02666d082b8b720730237ea47d7abb967b4a50a447c093ec7
6
+ metadata.gz: 2b3b6acf9f8c2899d818ab72a1429835fc3f94ad003d8d6974c2bbee8d39819aeec07e5c947dd814f0626d1151fc007dff8d78664b7f84bd63d3d1ef2c6b68cc
7
+ data.tar.gz: 612d0f7b4f197079cbb8e48c0cf7262a9d07f175e03c2318a7cc7a803451bc0c39c812ecebf13cd07b0c666090c0c21b1eedfecba3105ba6758fc616436349de
@@ -35,9 +35,17 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
35
35
  end
36
36
 
37
37
  def git_url_valid?(git_url)
38
+ http_git_url?(git_url) || ssh_git_url?(git_url)
39
+ end
40
+
41
+ def http_git_url?(git_url)
38
42
  http_git_url_regex = %r{^https?://[\w.-]+/[\w.-]+/[\w.-]+(?:\.git)?/?$}
43
+ git_url.match?(http_git_url_regex)
44
+ end
45
+
46
+ def ssh_git_url?(git_url)
39
47
  ssh_git_url_regex = %r{^(git@[\w.-]+[:|/][\w.-]+/[\w.-]+\.git)$}
40
- git_url.match?(http_git_url_regex) || git_url.match?(ssh_git_url_regex)
48
+ git_url.match?(ssh_git_url_regex)
41
49
  end
42
50
 
43
51
  private
@@ -70,6 +78,11 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
70
78
 
71
79
  say ">> Git URL must be provided and valid. Please try again.".colorize(:red)
72
80
  end
81
+
82
+ return unless http_git_url?(@git_url)
83
+
84
+ say ">> Your provided URL uses https. If the repository is private, an ssh url is required.".colorize(:yellow)
85
+ say ">> (e.g: git@github.com:my-org/my-app.git instead of https://github.com/my-org/my-app.git)".colorize(:yellow)
73
86
  end
74
87
 
75
88
  def set_postgres_version
@@ -91,7 +91,7 @@ class Renuo::Cli::Commands::FetchSecrets # rubocop:disable Metrics/ClassLength
91
91
  warn "Field `#{name}` not found in item #{item_id}. Check the field name in your #{CONFIG_FILE} file."
92
92
  else
93
93
  value = env_json["value"]
94
- update_or_add_variable(".env", name, /^#{name}=/, "#{name}=#{value}")
94
+ update_or_add_variable(".env", name, /^#{name}=.*$/, "#{name}=#{value}")
95
95
  update_or_add_variable("config/application.yml", name, /^#{name}:.*$/, "#{name}: \"#{value}\"")
96
96
  end
97
97
  end
@@ -6,13 +6,17 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
6
6
  UPDATE_TYPES = %w[major minor patch custom].freeze
7
7
  TMP_FOLDER_NAME = "_RENUO_RELEASE_TEMP_#{rand(100_000_000)}".freeze
8
8
  MOVE_TO_TMP_FOLDER = "mkdir -p #{TMP_FOLDER_NAME} && cd #{TMP_FOLDER_NAME}".freeze
9
+ SUPPORTED_HOSTS = %w[github.com gitlab.com].freeze
9
10
 
10
11
  command "release" do |c|
11
12
  c.syntax = "renuo release"
12
- c.summary = "Release a projects state of develop (on github) to main in one command."
13
+ c.summary = "Release a project's state of develop to main in one command."
13
14
  c.description = "Creates a new release version of a project on main as either a Major, Minor, " \
14
- "Patch or Custom release based on the current state of develop on Github"
15
- c.example "renuo release my-project minor", "release a minor release of my-project"
15
+ "Patch or Custom release based on the current state of develop. " \
16
+ "Supports GitHub and GitLab repositories."
17
+ c.example "renuo release my-project minor", "release a minor release of renuo/my-project on GitHub"
18
+ c.example "renuo release renuo/my-project minor", "release a minor release of renuo/my-project on GitHub"
19
+ c.example "renuo release https://gitlab.com/renuo/project patch", "release a patch of a GitLab project"
16
20
  c.example "renuo release my-project custom 2.5.0", "release my-project as release 2.5.0"
17
21
  c.action { |args| new.run(args) }
18
22
  end
@@ -39,6 +43,23 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
39
43
 
40
44
  def validate_project_name
41
45
  abort(">> No project name given.") unless @project_name
46
+
47
+ @host, @repo_path = repo_identifier(@project_name)
48
+ end
49
+
50
+ def repo_identifier(input)
51
+ return ["github.com", "renuo/#{input}"] unless input.include?("/")
52
+ return ["github.com", input] unless input.start_with?("http://", "https://", "git@")
53
+
54
+ # Convert git@host:path to https://host/path
55
+ uri = input.sub(/^git@([^:]+):/, 'https://\1/').sub(/\.git$/, "")
56
+ parsed = URI.parse(uri)
57
+ host = parsed.host
58
+ repo_path = parsed.path.sub(%r{^/}, "")
59
+
60
+ return [host, repo_path] if SUPPORTED_HOSTS.include?(host)
61
+
62
+ abort(">> Unsupported host '#{host}'. Supported hosts: #{SUPPORTED_HOSTS.join(", ")}")
42
63
  end
43
64
 
44
65
  def validate_update_type
@@ -74,11 +95,20 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
74
95
 
75
96
  def open_comparison_page
76
97
  puts "Opening browser to double-check what is going to be deployed…"
77
- open_path "https://github.com/#{@project_name}/compare/#{main_branch}...develop"
98
+ open_path comparison_url
99
+ end
100
+
101
+ def comparison_url
102
+ case @host
103
+ when "gitlab.com"
104
+ "https://#{@host}/#{@repo_path}/-/compare/#{main_branch}...develop"
105
+ else
106
+ "https://#{@host}/#{@repo_path}/compare/#{main_branch}...develop"
107
+ end
78
108
  end
79
109
 
80
110
  def checkout_project
81
- abort(">> Project not found on Github.") unless system("#{MOVE_TO_TMP_FOLDER} && gh repo clone #{@project_name}")
111
+ abort(">> Project not found.") unless system("#{MOVE_TO_TMP_FOLDER} && git clone git@#{@host}:#{@repo_path}.git")
82
112
 
83
113
  system(cmd_in_folder("git checkout #{main_branch} && git pull origin #{main_branch} &&" \
84
114
  "git checkout #{develop_branch} && git pull origin #{develop_branch}"))
@@ -173,7 +203,7 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
173
203
  end
174
204
 
175
205
  def ask_for_final_confirmation
176
- unless agree(">> Are you sure you wish to deploy '#{@project_name}' " \
206
+ unless agree(">> Are you sure you wish to deploy '#{@repo_path}' " \
177
207
  "as a #{@update_type} release (#{current_version} => #{@version})?")
178
208
  abort(">> Cancelling Release.")
179
209
  end
@@ -195,7 +225,7 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
195
225
  end
196
226
 
197
227
  def folder_name
198
- @project_name.split("/").last
228
+ @repo_path.split("/").last
199
229
  end
200
230
 
201
231
  def cleanup
@@ -203,7 +233,7 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
203
233
  end
204
234
 
205
235
  def main_branch
206
- remote_repo = "git@github.com:#{@project_name}.git"
236
+ remote_repo = "git@#{@host}:#{@repo_path}.git"
207
237
  @main_branch ||= `git ls-remote --heads #{remote_repo} main`.empty? ? "master" : "main"
208
238
  end
209
239
 
@@ -17,7 +17,7 @@ class Renuo::Cli::Services::Heroku
17
17
  end
18
18
 
19
19
  def fetch_app_names(team = nil)
20
- fetch_app_names_cmd = %(heroku apps --json #{team ? "--team=#{team}" : ""} | jq -r '.[] | "\\(.name)"')
20
+ fetch_app_names_cmd = %(heroku apps --json #{"--team=#{team}" if team} | jq -r '.[] | "\\(.name)"')
21
21
  stdout, stderr, status = Open3.capture3 fetch_app_names_cmd
22
22
  raise "Error fetching Heroku app list: #{stderr}" unless status.success?
23
23
 
@@ -16,11 +16,8 @@ do
16
16
  ;;
17
17
 
18
18
  assets)
19
- cache restore "packs-$SEMAPHORE_GIT_BRANCH,packs-develop"
20
- cache restore "packstest-$SEMAPHORE_GIT_BRANCH,packstest-develop"
21
19
  cache restore "assets-$SEMAPHORE_GIT_BRANCH,assets-develop"
22
20
  cache restore "sprocketscache-$SEMAPHORE_GIT_BRANCH,sprocketscache-develop"
23
- cache restore "webpackercache-$SEMAPHORE_GIT_BRANCH,webpackercache-develop"
24
21
  ;;
25
22
 
26
23
  *)
@@ -16,11 +16,8 @@ do
16
16
  ;;
17
17
 
18
18
  assets)
19
- cache store packs-$SEMAPHORE_GIT_BRANCH public/packs
20
- cache store packstest-$SEMAPHORE_GIT_BRANCH public/packs-test
21
19
  cache store assets-$SEMAPHORE_GIT_BRANCH public/assets
22
20
  cache store sprocketscache-$SEMAPHORE_GIT_BRANCH tmp/cache/assets/sprockets
23
- cache store webpackercache-$SEMAPHORE_GIT_BRANCH tmp/cache/webpacker
24
21
  ;;
25
22
 
26
23
  *)
@@ -2,7 +2,7 @@ version: v1.0
2
2
  name: <%= environment %>-deploy
3
3
  agent:
4
4
  machine:
5
- type: e2-standard-2
5
+ type: f1-standard-4
6
6
  os_image: ubuntu2204
7
7
 
8
8
  blocks:
@@ -12,6 +12,7 @@ blocks:
12
12
  task:
13
13
  secrets:
14
14
  - name: <%= project_name %>
15
+ - name: nctl
15
16
  env_vars:
16
17
  - name: DEPLOIO_PROJECT
17
18
  value: renuo-<%= project_name %>
@@ -24,7 +25,7 @@ blocks:
24
25
  - echo 'deb [trusted=yes] https://repo.nine.ch/deb/ /' | sudo tee /etc/apt/sources.list.d/repo.nine.ch.list
25
26
  - sudo apt-get -qq update
26
27
  - sudo apt-get -qq install -y nctl
27
- - nctl auth login --api-token=$API_TOKEN --organization=renuo
28
+ - nctl auth login --api-client-id=$NCTL_API_CLIENT_ID --api-client-secret=$NCTL_API_CLIENT_SECRET --organization=$NCTL_ORGANIZATION
28
29
  - nctl update app $DEPLOIO_APP_NAME -p $DEPLOIO_PROJECT --build-env="RUBY_VERSION=$(cat .ruby-version)" --git-revision=$(git rev-parse HEAD) --skip-repo-access-check
29
30
  - gem i renuo-cli
30
31
  - renuo check-deploio-status
@@ -3,7 +3,7 @@ name: <%= project_name %>
3
3
 
4
4
  agent:
5
5
  machine:
6
- type: e2-standard-2
6
+ type: f1-standard-4
7
7
  os_image: ubuntu2204
8
8
 
9
9
  auto_cancel:
@@ -3,7 +3,7 @@
3
3
  # :nocov:
4
4
  module Renuo
5
5
  class Cli
6
- VERSION = "4.14.1"
6
+ VERSION = "4.16.0"
7
7
  NAME = "renuo-cli"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renuo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.14.1
4
+ version: 4.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renuo AG
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.7.0
138
+ rubygems_version: 3.7.2
139
139
  specification_version: 4
140
140
  summary: The Renuo CLI automates some common workflows.
141
141
  test_files: []