semantic_release 1.0.1 → 1.2.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: 91fc39f15e36b70debd6a5aef9b8046709d9a2afb9e67af57745e81a49b38968
4
- data.tar.gz: b663616e65a61c83a84524927aff9277a5c28aee526dfba28e05972589aa1551
3
+ metadata.gz: 0a204e59fe728f22a01acf960d9d5d7098499df2bccad1bc49a6c92ea4029d2d
4
+ data.tar.gz: 471caaac5e1f4017ce564917554333d2da54aa7860522a700ffe3049e4be3e0d
5
5
  SHA512:
6
- metadata.gz: a670190a1415055ce97e9271eb8937080096cbea25bcc92ad766f5d3699ce35912848f1bc7206dc308ee7489fe3ea3ef999dc417a61669bb260663358d64d93a
7
- data.tar.gz: 7b761dfa2c043b381d0156843172d84bec9d7b48d7b5f6eefd161a200aa1d360cab1553ee2009ad30fd9ea443ad3971e80f4f5330a34684b96717db0d86ceee7
6
+ metadata.gz: 6ac502eeddea51f3947de0cba72763db2d51d44a00eb1edec413d79f4501c67696453220aa1914da165bfc78381c390d2dcc40e1578e2d1219f80b2924a74c52
7
+ data.tar.gz: 6cfbffd0d594fdc00377f8010f957d292b57866f53117288be79ea63616c7dc660e9d37afad881a90e735e3abc13569776f40e7a4599709268adbdef95abf506
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.2.0 (06 February 2025)
2
+
3
+ - feat: Mention 'rake release' in git tag updater output if a gemspec file is present
4
+ - feat: Stage Gemfile.lock after bumping version.rb if a gemspec file is present
5
+
6
+ ## 1.1.0 (03 February 2025)
7
+
8
+ - Add check to prevent re-initialising if semver file already exists
9
+ - Add configuration options for semver file
10
+ - Change rake task namespace from `semantic_release` to `release` and make configurable
11
+
1
12
  ## 1.0.1 (02 February 2025)
2
13
 
3
14
  - Add blank line after version number in changelog
data/README.md CHANGED
@@ -1,11 +1,15 @@
1
1
  # SemanticRelease
2
2
 
3
+ [![Build Status](https://github.com/ukdave/semantic_release/actions/workflows/main.yml/badge.svg)](https://github.com/ukdave/semantic_release/actions/workflows/main.yml)
4
+ [![Release](https://img.shields.io/github/v/release/ukdave/semantic_release)](https://github.com/ukdave/semantic_release/releases)
5
+ [![License](https://img.shields.io/github/license/ukdave/semantic_release)](https://github.com/ukdave/semantic_release/blob/main/LICENSE.txt)
6
+
3
7
  This gem helps you to manage the version number of your application or library.
4
8
 
5
9
  Use the provided Rake tasks to:
6
10
 
7
11
  - bump the major, minor, or patch number of your version
8
- - automatically update our verison file (e.g. `lib/version.rb`)
12
+ - automatically update your version file (e.g. `lib/version.rb`)
9
13
  - automatically update your changelog (`CHANGELOG.md` or `history.rdoc`)
10
14
  - automatically create a git commit and tag for the release
11
15
 
@@ -38,14 +42,23 @@ require "semantic_release/rake_task"
38
42
  SemanticRelease::RakeTask.new
39
43
  ```
40
44
 
45
+ The name of the rake task and other options are configurable like so:
46
+
47
+ ```ruby
48
+ require "semantic_release/rake_task"
49
+ SemanticRelease::RakeTask.new(:semver) do |config|
50
+ config.semver_file = "semver.json"
51
+ end
52
+ ```
53
+
41
54
  The following tasks are available:
42
55
 
43
56
  ```
44
- rake semantic_release:init
45
- rake semantic_release:current
46
- rake semantic_release:major
47
- rake semantic_release:minor
48
- rake semantic_release:patch
57
+ rake release:init
58
+ rake release:current
59
+ rake release:major
60
+ rake release:minor
61
+ rake release:patch
49
62
  ```
50
63
 
51
64
  To get the current version inside your application:
@@ -58,7 +71,9 @@ SemanticRelease.current_version
58
71
 
59
72
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
60
73
 
61
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
74
+ To install this gem onto your local machine, run `bundle exec rake install`.
75
+
76
+ To release a new version, run `bundle exec rake semver:XXX` (replacing `XXX` with `major` or `minor` or `patch`), which will bump the version number and create a git tag for the version. Then run `bundle exec rake release`, which will push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62
77
 
63
78
  ## Contributing
64
79
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SemanticRelease
4
+ class Configuration
5
+ attr_accessor :semver_file
6
+
7
+ def initialize
8
+ @semver_file = ".semver"
9
+ end
10
+ end
11
+ end
@@ -5,11 +5,13 @@ require "semantic_release"
5
5
 
6
6
  module SemanticRelease
7
7
  class RakeTask < Rake::TaskLib
8
- # rubocop:disable Metrics/MethodLength
9
- def initialize
10
- super
8
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
9
+ def initialize(name = :release)
10
+ super()
11
11
 
12
- namespace :semantic_release do
12
+ yield(SemanticRelease.configuration) if block_given?
13
+
14
+ namespace name do
13
15
  desc "Initialise version file"
14
16
  task :init do
15
17
  SemanticRelease.init
@@ -36,6 +38,6 @@ module SemanticRelease
36
38
  end
37
39
  end
38
40
  end
39
- # rubocop:enable Metrics/MethodLength
41
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
40
42
  end
41
43
  end
@@ -12,7 +12,11 @@ module SemanticRelease
12
12
  end
13
13
 
14
14
  def self.semver_file
15
- SemanticRelease::SEMVER_FILE
15
+ SemanticRelease.configuration.semver_file
16
+ end
17
+
18
+ def self.gemspec_present?
19
+ !Dir.glob("*.gemspec").empty?
16
20
  end
17
21
  end
18
22
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SemanticRelease
4
+ module Updaters
5
+ class GemfileLock < BaseUpdater
6
+ def self.update
7
+ return unless gemspec_present?
8
+ return if system("git check-ignore -q Gemfile.lock")
9
+
10
+ `bundle check && git add Gemfile.lock`
11
+ end
12
+ end
13
+ end
14
+ end
@@ -11,6 +11,7 @@ module SemanticRelease
11
11
 
12
12
  branch = `git rev-parse --abbrev-ref HEAD`.chomp
13
13
  puts "To push the new tag, use 'git push origin #{branch} --tags'"
14
+ puts "OR to push the tag and .gem file to rubygems.org use, 'bundle exec rake release'" if gemspec_present?
14
15
  end
15
16
  end
16
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SemanticRelease
4
- VERSION = "1.0.1"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "semantic_release/configuration"
3
4
  require_relative "semantic_release/semver"
4
5
  require_relative "semantic_release/version"
5
6
  Dir[File.join(__dir__, "semantic_release", "updaters", "*.rb")].each { |file| require file }
@@ -7,15 +8,19 @@ Dir[File.join(__dir__, "semantic_release", "updaters", "*.rb")].each { |file| re
7
8
  module SemanticRelease
8
9
  class Error < StandardError; end
9
10
 
10
- SEMVER_FILE = ".semver"
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
11
14
 
12
15
  def self.init
16
+ raise Error, "#{configuration.semver_file} already exists" if File.exist?(configuration.semver_file)
17
+
13
18
  version = Semver.new
14
- version.save(SEMVER_FILE)
19
+ version.save(configuration.semver_file)
15
20
  end
16
21
 
17
22
  def self.current_version
18
- Semver.load(SEMVER_FILE).to_s
23
+ Semver.load(configuration.semver_file).to_s
19
24
  end
20
25
 
21
26
  def self.inc_major
@@ -34,7 +39,7 @@ module SemanticRelease
34
39
  end
35
40
 
36
41
  def self.increment(term)
37
- version = Semver.load(SEMVER_FILE)
42
+ version = Semver.load(configuration.semver_file)
38
43
  version.increment(term)
39
44
  version.save
40
45
  end
@@ -42,6 +47,7 @@ module SemanticRelease
42
47
  def self.release
43
48
  Updaters::Changelog.update
44
49
  Updaters::VersionRb.update
50
+ Updaters::GemfileLock.update
45
51
  Updaters::GitTag.update
46
52
  end
47
53
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Bull
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-02 00:00:00.000000000 Z
10
+ date: 2025-02-06 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: |
13
13
  This gem helps you to manage the version number of your application or library. It provides Rake tasks to
@@ -22,10 +22,12 @@ files:
22
22
  - LICENSE.txt
23
23
  - README.md
24
24
  - lib/semantic_release.rb
25
+ - lib/semantic_release/configuration.rb
25
26
  - lib/semantic_release/rake_task.rb
26
27
  - lib/semantic_release/semver.rb
27
28
  - lib/semantic_release/updaters/base_updater.rb
28
29
  - lib/semantic_release/updaters/changelog.rb
30
+ - lib/semantic_release/updaters/gemfile_lock.rb
29
31
  - lib/semantic_release/updaters/git_tag.rb
30
32
  - lib/semantic_release/updaters/version_rb.rb
31
33
  - lib/semantic_release/version.rb