bake-gem 0.8.0 → 0.10.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: 48eb04c9e92c22e34e9504d4cd5e29b47f7c01d5649815872f8163ff0352b14d
4
- data.tar.gz: 486fa34ab83b02141d1b526ea19cfbb078cb0dd126d5c361f3d617dce9c72939
3
+ metadata.gz: 436620eb899794e3709390307a7d665798d1808b2cdded1a151c005db9c3f55d
4
+ data.tar.gz: c438bf0f5436b9eb5935661d8d9b4b4241050f7d5dfd4f0da086a4fe9ff48e04
5
5
  SHA512:
6
- metadata.gz: 9edd13ef496b1b47c49040d87f3010f4ca2a3e3a46458ce3eedb5d6d185fed45a2eacdee97c2f4c700ba31f73e8cdeea358ebd5c5a3b7a201c9c5aac9cfe89eb
7
- data.tar.gz: 57d47443d4e6c56f245342106e7c024a2b6caa5c432acf5f2bd702a7de712d56cb3e83c9848c59a39b0009e5e44550fa7db7120291d69e53a784e3fd4a31bae8
6
+ metadata.gz: 3bb4833a86116ebdcfb5949f5d8960473ded2595ad0fbd3d533988a79fb8158535c43ffeeb1755e5ac657a2f884f863f99c3d4dca562a2efc2f2c8b53abe8735
7
+ data.tar.gz: 5821fefb80eac7a536e54c0f4df700ff0d800938bd72e4ad4c364f1262878247a68922ae70474bfc57a44821efad2ae7cf394ae19abef5fe12d0a9038887f2dd
checksums.yaml.gz.sig CHANGED
Binary file
@@ -32,12 +32,12 @@ def increment(bump, message: "Bump version.")
32
32
  gemspec = helper.gemspec
33
33
 
34
34
  helper.update_version(bump) do |version|
35
- version_string = version.join('.')
36
-
37
- Console.logger.info(self) {"Updated version to #{version_string}"}
35
+ Console.logger.info(self) {"Updated version: #{version}"}
38
36
 
39
37
  # Ensure that any subsequent tasks use the correct version!
40
- gemspec.version = ::Gem::Version.new(version_string)
38
+ gemspec.version = version.join
39
+
40
+ after_increment(version)
41
41
  end
42
42
  end
43
43
 
@@ -54,9 +54,15 @@ def commit(bump, message: "Bump version.")
54
54
  version_path = increment(bump, message: message)
55
55
 
56
56
  if version_path
57
- system("git", "add", version_path, chdir: context.root)
57
+ system("git", "add", "--all", chdir: context.root)
58
58
  system("git", "commit", "-m", message, chdir: context.root)
59
59
  else
60
60
  raise "Could not find version number!"
61
61
  end
62
62
  end
63
+
64
+ protected
65
+
66
+ def after_increment(version)
67
+ context['after_gem_release_version_increment']&.call(version)
68
+ end
data/bake/gem.rb CHANGED
@@ -42,6 +42,8 @@ def install(local: false)
42
42
  @helper.install_gem(*arguments, path: path)
43
43
  end
44
44
 
45
+ # Release the gem by building it, pushing it to the server, and tagging the release.
46
+ # @parameter tag [Boolean] Whether to tag the release.
45
47
  def release(tag: true)
46
48
  @helper.guard_clean
47
49
 
@@ -11,6 +11,64 @@ require_relative 'shell'
11
11
 
12
12
  module Bake
13
13
  module Gem
14
+ class Version
15
+ LINE_PATTERN = /VERSION = ['"](?<version>(?<parts>\d+\.\d+\.\d+)(-(?<suffix>.*?))?)['"]/
16
+
17
+ # If the line contains a version constant, update it using the provided block.
18
+ def self.update_version(line)
19
+ if match = line.match(LINE_PATTERN)
20
+ parts = match[:parts].split(/\./).map(&:to_i)
21
+ suffix = match[:suffix]
22
+
23
+ version = self.new(parts, suffix)
24
+
25
+ yield version
26
+
27
+ line.sub!(match[:version], version.join)
28
+ end
29
+ end
30
+
31
+ def initialize(parts, suffix)
32
+ @parts = parts
33
+ @suffix = suffix
34
+ end
35
+
36
+ def release?
37
+ @suffix.nil?
38
+ end
39
+
40
+ # Join all parts together to form a version string.
41
+ def join
42
+ if @suffix
43
+ return "#{@parts.join('.')}-#{@suffix}"
44
+ else
45
+ return @parts.join('.')
46
+ end
47
+ end
48
+
49
+ # The version string with a "v" prefix.
50
+ def to_s
51
+ "v#{join}"
52
+ end
53
+
54
+ def increment(bump)
55
+ bump.each_with_index do |increment, index|
56
+ if index > @parts.size
57
+ @suffix = bump[index..-1].join('.')
58
+ break
59
+ end
60
+
61
+ if increment == 1
62
+ @parts[index] += 1
63
+ elsif increment == 0
64
+ @parts[index] = 0
65
+ end
66
+ end
67
+
68
+ return self
69
+ end
70
+ end
71
+
14
72
  class Helper
15
73
  include Shell
16
74
 
@@ -26,36 +84,25 @@ module Bake
26
84
  @gemspec&.files.grep(/lib(.*?)\/version.rb/).first
27
85
  end
28
86
 
29
- VERSION_PATTERN = /VERSION = ['"](?<value>\d+\.\d+\.\d+)(?<pre>.*?)['"]/
30
-
31
87
  def update_version(bump, version_path = self.version_path)
32
88
  return false unless version_path
33
89
 
34
90
  lines = File.readlines(version_path)
35
- version = nil
91
+ new_version = nil
36
92
 
37
93
  lines.each do |line|
38
- if match = line.match(VERSION_PATTERN)
39
- version = match[:value].split(/\./).map(&:to_i)
40
- bump.each_with_index do |increment, index|
41
- if increment == 1
42
- version[index] += 1
43
- elsif increment == 0
44
- version[index] = 0
45
- end
46
- end
47
-
48
- line.sub!(match[:value], version.join('.'))
94
+ Version.update_version(line) do |version|
95
+ new_version = version.increment(bump)
49
96
  end
50
97
  end
51
98
 
52
- if version
99
+ if new_version
100
+ File.write(version_path, lines.join)
101
+
53
102
  if block_given?
54
- yield version
103
+ yield new_version
55
104
  end
56
105
 
57
- File.write(version_path, lines.join)
58
-
59
106
  return version_path
60
107
  end
61
108
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Gem
8
- VERSION = "0.8.0"
8
+ VERSION = "0.10.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -10,6 +10,10 @@ Please see the [project documentation](https://ioquatix.github.io/bake-gem/) for
10
10
 
11
11
  - [Getting Started](https://ioquatix.github.io/bake-gem/guides/getting-started/index) - This guide explains how to use `bake-gem` to release gems.
12
12
 
13
+ ## See Also
14
+
15
+ - [Bake](https://github.com/ioquatix/bake) — The bake task execution tool.
16
+
13
17
  ## Contributing
14
18
 
15
19
  We welcome contributions to this project.
@@ -27,7 +31,3 @@ This project uses the [Developer Certificate of Origin](https://developercertifi
27
31
  ### Contributor Covenant
28
32
 
29
33
  This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
30
-
31
- ## See Also
32
-
33
- - [Bake](https://github.com/ioquatix/bake) — The bake task execution tool.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2024-06-23 00:00:00.000000000 Z
40
+ date: 2024-08-23 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: console
metadata.gz.sig CHANGED
Binary file