build-labels 0.0.27 → 0.0.29

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: 208d38d03e2e082828c05f3db32d515798d09ff4cb65c93aa993a5a96d6f1187
4
- data.tar.gz: cd1ff4fc1c4a9dcd137f0cacbbfee9b66c71cc8b04e2cbe87049c99053276f09
3
+ metadata.gz: 33e6468499e7dba74de3940e9efcf8b0163e4998562cb14c410b283045e9212d
4
+ data.tar.gz: f537053e05673a46332cf877e9c3c70caa18e01c20881b0ae04310b02d9c5d72
5
5
  SHA512:
6
- metadata.gz: ffdf54b18d77baf4c6ecc16760f0e08b35823aa085f69994bcf2fbb474103f4b16bdd31fdd6a49d6c83eb376d60c7679388b82bf8df2e865c2fd4f9c12f960c1
7
- data.tar.gz: 6cc8f640a773e079ec01ca1ef89ab8118f51359e7c70b38e76bbbffd49bd257ab37830db957a22e630306a7915423d01621f65f25e0faeef192a12070c813f2d
6
+ metadata.gz: 7517f405c98548ef7ec5c77d3732c4d9c100af0cae0ce10580bf21ecd930166f4298ccb24f51fe8fa49b483e17e20ff922e00a9190f411a2a572e5e0049ad0f4
7
+ data.tar.gz: 04cbc3277100c7e45396c654220485290cf8959a60d61efab9804fe13d657fa7c8ea0c340c9870cd3f8ee7da5bcfd6b3202941912fcdad78c8f7da94522b05e3
@@ -1,47 +1,48 @@
1
1
  require_relative 'command_line'
2
2
 
3
3
  BuildLabels::CommandLine::COMMANDS[:set_version] = Class.new do
4
- def commit_message_commands(version)
5
- return version unless (match = ENV['CI_COMMIT_MESSAGE']&.match(/#push:(\w+)/i))
6
4
 
7
- puts 'Debug: Push command detected in commit message'
8
- version = '0.0' if version.to_s.empty?
9
- tag = match[1] ? "-#{match[1]}" : ''
10
- "#{version}.#{ENV['CI_PIPELINE_IID']}#{tag}"
11
- end
12
-
13
- def run(builder, params, compose)
5
+ def run(_builder, params, compose)
14
6
  raise 'Compose file not defined' unless compose
15
7
 
16
8
  compose_dir = params[:compose] ? File.dirname(params[:compose]) : '.'
17
9
 
18
- compose['services'].each do |name, svc|
10
+ compose['services'].each do |_name, svc|
19
11
  next unless svc['build']
20
- versionfile = svc['build'].is_a?(String) ? './' : svc['build']['context']
21
- versionfile = File.join versionfile, '.version'
22
- versionfile = File.expand_path versionfile, compose_dir
23
-
24
- current_version = File.exist?( versionfile) ? File.read(versionfile).strip : nil
25
- current_version = commit_message_commands(current_version)
26
-
27
- image = svc['image'].gsub( /:.*/, '')
28
- tag = svc['image'][/:(.*)/, 1]
12
+ unless svc['build']['tags']
13
+ svc['build']['tags'] = [svc['image']]
14
+ end
29
15
 
30
- full_tag = [current_version, tag].compact.join '-'
31
- full_tag = full_tag.empty? ? '' : ":#{full_tag}"
16
+ version_file = svc['build'].is_a?(String) ? './' : svc['build']['context']
17
+ version_file = File.join version_file, '.version'
18
+ version_file = File.expand_path version_file, compose_dir
32
19
 
33
- svc['image'] = "#{image}#{full_tag}"
20
+ current_version = File.exist?( version_file) ? File.read(version_file).strip : nil
34
21
 
35
- next unless svc['build']['tags']
36
22
  svc['build']['tags'] = svc['build']['tags'].map do |t|
37
23
  image, tag = t.split(':')
38
24
  full_tag = [current_version, tag].compact.join('-')
39
- "#{image}#{full_tag.empty? ? '' : ":#{full_tag}"}"
25
+
26
+ [image, full_tag].compact.join ':'
40
27
  end
28
+
29
+ if ENV['CI_COMMIT_MESSAGE'].to_s =~ /#push/mi
30
+ full_version = "#{current_version.to_s.empty? ? '0.0' : current_version}.#{ENV['CI_PIPELINE_IID']}"
31
+
32
+ push_tag = ENV['CI_COMMIT_MESSAGE']&[/#push:(\w+)/mi, 1]
33
+
34
+ svc['build']['tags'] += svc['build']['tags'].map do |t|
35
+ image, tag = t.split(':')
36
+ full_tag = [full_version, push_tag || tag].compact.join('-')
37
+
38
+ [image, full_tag].compact.join ':'
39
+ end
40
+ end
41
+
41
42
  end
42
43
  end
43
44
 
44
45
  def help
45
46
  'Add version tag from [docker_context]/.version file to image'
46
47
  end
47
- end.new
48
+ end.new
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module BuildLabels
2
2
  class Builder
3
- VERSION = '0.0.27'
3
+ VERSION = '0.0.29'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build-labels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom B
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-30 00:00:00.000000000 Z
11
+ date: 2025-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake