retag 0.1.6 → 0.1.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: ab9f253e8ff9f3a7bfd637ddaa844cff811d3c75f79fde036bdacd8eb1f58f91
4
- data.tar.gz: d36f32cb6b21896c28901f18420ef1ccf4207e4cf2683c42407bebd52662f761
3
+ metadata.gz: 4cde121c1134315e7af8b6f3b99287852eff68bfaedd8cd45149672b10c2f39a
4
+ data.tar.gz: 2347a0a62ff16b0d850bbd408b62584ed5831c8407259ae039b3b4ba4e7ece4b
5
5
  SHA512:
6
- metadata.gz: 484c2c98bf6d72545501c1b4b43e139579ee37af5b8f0e1c7e5bf1c28998a8ba4c039fb4a2e7042edbdbf56304420d28b186104863599834c1a6db3ab8c78249
7
- data.tar.gz: 390312a1b807c7790a80e4bb5e9f68c6644455b267dcbdd965d260af58106030b9b11cbc1477f21ac78f6a230660e09aef1d32313e94a5301f37b32bef60cd5d
6
+ metadata.gz: e380ab0f64df32dee97b74f97c4d3960e2505b5b1cf055fb9fd6870dab52a8cce245968f5c6854993e5036e0de01e7bdf4a4a7497f576512c07ed075a2718da9
7
+ data.tar.gz: 459d326b5e1d396e1fc721fe8b4c98cf4c8398318cd3392bfb9de1e0864e9ca4ce64b34b77f85d7ec3def20f0a56395d24e59b8e319dcca70c29e7c0d40b5595
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retag (0.1.6)
4
+ retag (0.1.10)
5
5
  activesupport (~> 6.0)
6
6
  colorize
7
7
  gitlab
data/bin/retag CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'yaml'
4
+ require 'erb'
4
5
  require 'thor'
5
6
  require 'colorize'
6
7
  require 'retag'
@@ -40,8 +41,31 @@ class RepoCommand < Thor
40
41
  # Success: there is no such tag
41
42
  end if opts['force']
42
43
 
44
+ $logger.info ">>> Repo #{project}"
45
+ $logger.info " From ".ljust(5) + "[#{options['ref'].colorize(:yellow)}]".ljust(35)
46
+ $logger.info " To ".ljust(5) + "[#{tag.colorize(:yellow)}]".ljust(35)
47
+
43
48
  puts Gitlab.client.create_tag(project, tag, options['ref'], options['message']).inspect
44
49
  end
50
+
51
+ desc "release <project> <tag>", "Create tag in Gitlab project"
52
+ long_desc <<-LONGDESC
53
+ LONGDESC
54
+
55
+ option :ref, default: ENV.fetch("#{ENV_PREFIX}_RELEASE_REF", 'master'),
56
+ required: true,
57
+ type: :string,
58
+ desc: "Gtilab refspec from which create tag"
59
+
60
+ option :description, default: nil,
61
+ type: :string,
62
+ desc: "description Markdown"
63
+ def release(project, tag)
64
+ $logger.info ">>> Repo #{project}"
65
+ $logger.info " From ".ljust(5) + "[#{options['ref'].colorize(:yellow)}]".ljust(35)
66
+ $logger.info " To ".ljust(5) + "[#{tag.colorize(:yellow)}]".ljust(35)
67
+ Gitlab.client.create_project_release(project, name: tag, tag_name: tag, description: options['description']&.strip, ref: options['ref'])
68
+ end
45
69
  end
46
70
 
47
71
  class DockerCommand < Thor
@@ -73,7 +97,11 @@ class DockerCommand < Thor
73
97
  tag = opts['suffix'].present? ? "#{tag}-#{opts['suffix']}" : tag
74
98
 
75
99
  image = ::Retag::Image.new(img, tag)
76
- image.retag!(opts['tag'])
100
+
101
+ $logger.info ">>> Image #{image.image}"
102
+ $logger.info " From ".ljust(5) + "[#{image.tag.colorize(:yellow)}]: ".ljust(35) + image.full
103
+ newimg = image.retag!(opts['tag'])
104
+ $logger.info " To ".ljust(5) + "[#{newimg.tag.colorize(:yellow)}]: ".ljust(35) + newimg.full
77
105
  end
78
106
 
79
107
  end
@@ -92,18 +120,23 @@ class ReleaseCommand < Thor
92
120
  required: false,
93
121
  desc: "Env: #{ENV_PREFIX}_RELEASE_NAME. Name of the current release"
94
122
 
123
+ option :manifest, default: './manifest.md',
124
+ required: false,
125
+ type: :string,
126
+ desc: "Output file for Markdown manifest of the release"
127
+
95
128
  def release(*_args)
96
129
  opts = options.to_h.dup
97
130
  $logger.level = :debug if opts['verbose']
98
131
 
99
- config = YAML.load_file(File.expand_path(opts['config']))
132
+ config = YAML.load(ERB.new(File.read(File.expand_path(opts['config']))).result)
100
133
  config['release'] = opts['name'] || config['release']
101
134
 
102
135
  release = config['release'].to_s
103
- suffix = config['suffix']
104
- branch = config['branch']
136
+ suffix = config['default-suffix']
137
+ branch = config['default-branch']
105
138
 
106
- services = config['services'].map do|(name, cfg)|
139
+ services = config['services'].map do|(name, cfg)|
107
140
  Retag::Service.new(name, cfg, release, suffix: cfg.fetch('suffix', suffix), branch: cfg.fetch('branch', branch)) unless name.start_with?('.')
108
141
  end.compact
109
142
 
@@ -111,6 +144,8 @@ class ReleaseCommand < Thor
111
144
 
112
145
  $logger.info "*** Starting '#{tag_message.colorize(mode: :bold)}'...".colorize(:cyan)
113
146
 
147
+ markdown = "## Services\n\n"
148
+
114
149
  services.each do |srv|
115
150
  $logger.tagged(srv.name.colorize(:yellow), "#{srv.revision.colorize(mode: :bold)}@#{srv.branch}") do
116
151
  $logger.info "#{'==>'.colorize(mode: :bold, color: :white)} Releasing service #{srv.name.colorize(mode: :bold)} from #{srv.repo.repo} at #{srv.branch.colorize(mode: :bold)}:".colorize(:green)
@@ -122,22 +157,28 @@ class ReleaseCommand < Thor
122
157
  $logger.info "From ".ljust(5) + "[#{img.tag.colorize(:yellow)}]: ".ljust(35) + img.full
123
158
  newimg = img.retag!(release)
124
159
  $logger.info "To ".ljust(5) + "[#{newimg.tag.colorize(:yellow)}]: ".ljust(35) + newimg.full
160
+
161
+ markdown += "* **Name**: `#{srv.name}`<br>**Version**: #{img.tag}<br>**Image**: #{newimg.full}\n"
125
162
  end
126
163
 
127
164
  $logger.info ">>> Repo #{srv.repo.repo}"
128
165
 
129
166
  $logger.shift do
130
167
  $logger.info "From ".ljust(5) + "[#{srv.revision.colorize(:yellow)}]: ".ljust(35) + "#{srv.repo.repo}~#{srv.revision}@#{srv.branch}"
131
- newimg = img.retag!(release)
168
+ srv.repo.tag!(release, message: tag_message)
132
169
  $logger.info "To ".ljust(5) + "[#{release.colorize(:yellow)}]: ".ljust(35) + "#{srv.repo.repo}~#{srv.revision}@#{release}"
133
170
  end
134
-
135
- srv.repo.tag!(release, message: tag_message)
171
+
136
172
  end
137
173
  end
138
174
  end
139
175
  end
140
176
 
177
+ File.write(opts['manifest'], markdown.strip)
178
+
179
+
180
+
181
+
141
182
  $logger.info "*** Completed '#{tag_message.colorize(mode: :bold)}'".colorize(:cyan)
142
183
 
143
184
  end
data/lib/retag/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Retag
4
4
 
5
- VERSION = '0.1.6'
5
+ VERSION = '0.1.10'
6
6
 
7
7
  end
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-21 00:00:00.000000000 Z
11
+ date: 2022-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler