create_github_release 0.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 +7 -0
- data/.markdownlint.yml +25 -0
- data/.rspec +3 -0
- data/.rubocop.yml +20 -0
- data/.yardopts +5 -0
- data/CHANGELOG.md +31 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +85 -0
- data/create_github_release.gemspec +49 -0
- data/exe/create-github-release +22 -0
- data/lib/create_github_release/assertion_base.rb +62 -0
- data/lib/create_github_release/assertions/bundle_is_up_to_date.rb +73 -0
- data/lib/create_github_release/assertions/changelog_docker_container_exists.rb +73 -0
- data/lib/create_github_release/assertions/docker_is_running.rb +42 -0
- data/lib/create_github_release/assertions/gh_command_exists.rb +42 -0
- data/lib/create_github_release/assertions/git_command_exists.rb +42 -0
- data/lib/create_github_release/assertions/in_git_repo.rb +44 -0
- data/lib/create_github_release/assertions/in_repo_root_directory.rb +47 -0
- data/lib/create_github_release/assertions/local_and_remote_on_same_commit.rb +45 -0
- data/lib/create_github_release/assertions/local_release_branch_does_not_exist.rb +43 -0
- data/lib/create_github_release/assertions/local_release_tag_does_not_exist.rb +45 -0
- data/lib/create_github_release/assertions/no_staged_changes.rb +46 -0
- data/lib/create_github_release/assertions/no_uncommitted_changes.rb +46 -0
- data/lib/create_github_release/assertions/on_default_branch.rb +44 -0
- data/lib/create_github_release/assertions/remote_release_branch_does_not_exist.rb +43 -0
- data/lib/create_github_release/assertions/remote_release_tag_does_not_exist.rb +43 -0
- data/lib/create_github_release/assertions.rb +25 -0
- data/lib/create_github_release/changelog.rb +372 -0
- data/lib/create_github_release/command_line_parser.rb +137 -0
- data/lib/create_github_release/options.rb +397 -0
- data/lib/create_github_release/release.rb +82 -0
- data/lib/create_github_release/release_assertions.rb +86 -0
- data/lib/create_github_release/release_tasks.rb +78 -0
- data/lib/create_github_release/task_base.rb +62 -0
- data/lib/create_github_release/tasks/commit_release.rb +42 -0
- data/lib/create_github_release/tasks/create_github_release.rb +106 -0
- data/lib/create_github_release/tasks/create_release_branch.rb +42 -0
- data/lib/create_github_release/tasks/create_release_pull_request.rb +107 -0
- data/lib/create_github_release/tasks/create_release_tag.rb +42 -0
- data/lib/create_github_release/tasks/push_release.rb +42 -0
- data/lib/create_github_release/tasks/update_changelog.rb +126 -0
- data/lib/create_github_release/tasks/update_version.rb +46 -0
- data/lib/create_github_release/tasks.rb +18 -0
- data/lib/create_github_release/version.rb +6 -0
- data/lib/create_github_release.rb +21 -0
- metadata +235 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1a06b294acfb6e5357f5fbba1f47b1c0baa64acb6f8b93f9ea5f3c262afb3ae1
|
4
|
+
data.tar.gz: 56dc6312fafcc3ca2b3244a9ba453651f17d2dfed4225830d2e594df48d2546c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6119db8f31ca3a9e0d77d1fff5deb1b6fe66443d41024300469d6849542698de0e5af00163b12158ec480c22a330baeb321d765398c08adf30c52722367930ba
|
7
|
+
data.tar.gz: 791cfe69208757b5eba420a190150575686aeb554f4acde1dd584c3c22e282c3083e52e5d2e221e31aca4de2811ba783c14a00a61170b72c5d3f70fc1e012477
|
data/.markdownlint.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
default: true
|
2
|
+
|
3
|
+
# Unordered list indentation
|
4
|
+
MD007: { indent: 4 }
|
5
|
+
|
6
|
+
# Line length
|
7
|
+
MD013: { line_length: 90, tables: false, code_blocks: false }
|
8
|
+
|
9
|
+
# Heading duplication is allowed for non-sibling headings
|
10
|
+
MD024: { siblings_only: true }
|
11
|
+
|
12
|
+
# Do not allow the specified trailig punctuation in a header
|
13
|
+
MD026: { punctuation: '.,;:' }
|
14
|
+
|
15
|
+
# Order list items must have a prefix that increases in numerical order
|
16
|
+
MD029: { style: 'ordered' }
|
17
|
+
|
18
|
+
# Lists do not need to be surrounded by blank lines
|
19
|
+
MD032: false
|
20
|
+
|
21
|
+
# Allow raw HTML in Markdown
|
22
|
+
MD033: false
|
23
|
+
|
24
|
+
# Allow emphasis to be used instead of a heading
|
25
|
+
MD036: false
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
# Output extra information for each offense to make it easier to diagnose:
|
4
|
+
DisplayCopNames: true
|
5
|
+
DisplayStyleGuide: true
|
6
|
+
ExtraDetails: true
|
7
|
+
SuggestExtensions: false
|
8
|
+
# RuboCop enforces rules depending on the oldest version of Ruby which
|
9
|
+
# your project supports:
|
10
|
+
TargetRubyVersion: 2.7
|
11
|
+
|
12
|
+
# The default max line length is 80 characters
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
# The DSL for RSpec and the gemspec file make it very hard to limit block length:
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Exclude:
|
19
|
+
- "spec/**/*_spec.rb"
|
20
|
+
- "*.gemspec"
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## v0.2.0 (2022-11-15)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v0.1.0...v0.2.0)
|
11
|
+
|
12
|
+
* 039b152 Make it so Options#default_branch does not actually run git (#17)
|
13
|
+
* 754224c Require date (#15)
|
14
|
+
* 7789a28 Do not hardcode the version file path (#14)
|
15
|
+
* 73b61bd Do not use unneeded regexps in tests (#13)
|
16
|
+
* 6fa12e5 Create the release tag before trying to create the release branch (#12)
|
17
|
+
* 819afd3 Call the right method for creating the release (#11)
|
18
|
+
* 8a0fe61 Fix error in the create-github-release script (#10)
|
19
|
+
* 6999d91 Execute the tasks from the create-github-release script (#9)
|
20
|
+
* 819b657 Add a changelog file (#8)
|
21
|
+
* 697fb95 Add 'tmp' and 'sig' directories to rake cleanup (#7)
|
22
|
+
* 993e121 Add release tasks (#6)
|
23
|
+
* a2d0b4d Add assertion to check that the git command is in the path (#5)
|
24
|
+
* c3ed55b Refactor assertions (#4)
|
25
|
+
* 0f3733e Add release assertions (#3)
|
26
|
+
* a2c00ee Add the CommandLineParser class (#2)
|
27
|
+
* 9535c0e Add the Options class (#1)
|
28
|
+
|
29
|
+
## v0.1.0 (2022-10-26)
|
30
|
+
|
31
|
+
* Initial version (976b790)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 James Couball
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# The create_github_release Gem
|
2
|
+
|
3
|
+
Create a GitHub release for a new gem version.
|
4
|
+
|
5
|
+
To create a new GitHub release for a gem, run the following from the top level
|
6
|
+
project directory with the default branch selected:
|
7
|
+
|
8
|
+
```shell
|
9
|
+
create-github-release [major|minor|patch]
|
10
|
+
```
|
11
|
+
|
12
|
+
The following conditions must be met in order to create a release:
|
13
|
+
|
14
|
+
* The bundle must be up to date (via bundle update)
|
15
|
+
* You current directory must be in the top level of the git repository
|
16
|
+
* The default branch must be checked out
|
17
|
+
* There are no uncommitted changes
|
18
|
+
* The local and remote must be on the same commit
|
19
|
+
* The new release tag must not already exist either locally or remotely
|
20
|
+
* The new release branch must not already exist either locally or remotely
|
21
|
+
* Docker must be running
|
22
|
+
* The changelog docker container must already exist or be able to be built
|
23
|
+
* The gh command must be installed
|
24
|
+
|
25
|
+
The result of running this command is:
|
26
|
+
* A new release branch is created
|
27
|
+
* CHANGELOG.md is updated with a list of PRs since the last release
|
28
|
+
* The Gem version is updated via Bump
|
29
|
+
* The CHANGELOG.md and version changes are committed and tagged on the new release branch
|
30
|
+
* The new release branch is pushed to the remote
|
31
|
+
* A release is created on GitHub
|
32
|
+
* A release PR is created on GitHub
|
33
|
+
|
34
|
+
## Installation
|
35
|
+
|
36
|
+
Add `create_github_release` as a development dependency in your project's gemspec:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
spec.add_development_dependency 'create_github_release', '~> 0.1'
|
40
|
+
```
|
41
|
+
|
42
|
+
and then install using `bundle update`.
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
47
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
48
|
+
prompt that will allow you to experiment.
|
49
|
+
|
50
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
51
|
+
release a new version, update the version number in `version.rb`, and then run
|
52
|
+
`bundle exec rake release`, which will create a git tag for the version, push git
|
53
|
+
commits and the created tag, and push the `.gem` file to
|
54
|
+
[rubygems.org](https://rubygems.org).
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
Bug reports and pull requests are welcome on
|
59
|
+
[this project's GitHub issue tracker](https://github.com/main-branch/create_github_release)
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the
|
64
|
+
[MIT License](https://github.com/main-branch/create_github_release/blob/main/LICENSE.txt).
|
data/Rakefile
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The default task
|
4
|
+
|
5
|
+
desc 'Run the same tasks that the CI build will run'
|
6
|
+
task default: %w[spec rubocop yard yard:audit yard:coverage bundle:audit build]
|
7
|
+
|
8
|
+
# Bundler Audit
|
9
|
+
|
10
|
+
require 'bundler/audit/task'
|
11
|
+
Bundler::Audit::Task.new
|
12
|
+
|
13
|
+
# Bundler Gem Build
|
14
|
+
|
15
|
+
require 'bundler'
|
16
|
+
require 'bundler/gem_tasks'
|
17
|
+
|
18
|
+
begin
|
19
|
+
Bundler.setup(:default, :development)
|
20
|
+
rescue Bundler::BundlerError => e
|
21
|
+
warn e.message
|
22
|
+
warn 'Run `bundle install` to install missing gems'
|
23
|
+
exit e.status_code
|
24
|
+
end
|
25
|
+
|
26
|
+
CLEAN << 'pkg'
|
27
|
+
CLOBBER << 'Gemfile.lock'
|
28
|
+
|
29
|
+
# Bump
|
30
|
+
|
31
|
+
require 'bump/tasks'
|
32
|
+
|
33
|
+
# RSpec
|
34
|
+
|
35
|
+
require 'rspec/core/rake_task'
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new
|
38
|
+
|
39
|
+
CLEAN << 'coverage'
|
40
|
+
CLEAN << '.rspec_status'
|
41
|
+
CLEAN << 'rspec-report.xml'
|
42
|
+
|
43
|
+
# Rubocop
|
44
|
+
|
45
|
+
require 'rubocop/rake_task'
|
46
|
+
|
47
|
+
RuboCop::RakeTask.new do |t|
|
48
|
+
t.options = %w[
|
49
|
+
--format progress
|
50
|
+
--format json --out rubocop-report.json
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
CLEAN << 'rubocop-report.json'
|
55
|
+
|
56
|
+
# YARD
|
57
|
+
|
58
|
+
require 'yard'
|
59
|
+
YARD::Rake::YardocTask.new do |t|
|
60
|
+
t.files = %w[lib/**/*.rb examples/**/*]
|
61
|
+
t.stats_options = ['--list-undoc']
|
62
|
+
end
|
63
|
+
|
64
|
+
CLEAN << '.yardoc'
|
65
|
+
CLEAN << 'doc'
|
66
|
+
|
67
|
+
# Yardstick
|
68
|
+
|
69
|
+
desc 'Run yardstick to show missing YARD doc elements'
|
70
|
+
task :'yard:audit' do
|
71
|
+
sh "yardstick 'lib/**/*.rb'"
|
72
|
+
end
|
73
|
+
|
74
|
+
# Yardstick coverage
|
75
|
+
|
76
|
+
require 'yardstick/rake/verify'
|
77
|
+
|
78
|
+
Yardstick::Rake::Verify.new(:'yard:coverage') do |verify|
|
79
|
+
verify.threshold = 100
|
80
|
+
end
|
81
|
+
|
82
|
+
# Additional cleanup
|
83
|
+
|
84
|
+
CLEAN << 'tmp'
|
85
|
+
CLEAN << 'sig'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/create_github_release/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'create_github_release'
|
7
|
+
spec.version = CreateGithubRelease::VERSION
|
8
|
+
spec.authors = ['James']
|
9
|
+
spec.email = ['jcouball@yahoo.com']
|
10
|
+
|
11
|
+
spec.summary = 'Create a GitHub release PR for a Ruby Gem'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'https://github.com/main-branch/create_github_release'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.7.0'
|
16
|
+
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
21
|
+
spec.metadata['changelog_uri'] = spec.homepage
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(__dir__) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
spec.add_development_dependency 'bump', '~> 0.10'
|
35
|
+
spec.add_development_dependency 'bundler-audit', '~> 0.9'
|
36
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
37
|
+
spec.add_development_dependency 'redcarpet', '~> 3.5'
|
38
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
39
|
+
spec.add_development_dependency 'rubocop', '~> 1.36'
|
40
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
41
|
+
spec.add_development_dependency 'solargraph', '~> 0.47'
|
42
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
43
|
+
spec.add_development_dependency 'yardstick', '~> 0.9'
|
44
|
+
|
45
|
+
# For more information and examples about making a new gem, check out our
|
46
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
47
|
+
|
48
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
49
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'create_github_release'
|
5
|
+
|
6
|
+
options = CreateGithubRelease::CommandLineParser.new.parse(ARGV)
|
7
|
+
CreateGithubRelease::ReleaseAssertions.new(options).make_assertions
|
8
|
+
puts unless options.quiet
|
9
|
+
CreateGithubRelease::ReleaseTasks.new(options).run
|
10
|
+
|
11
|
+
puts <<~MESSAGE unless options.quiet
|
12
|
+
Release '#{options.tag}' created successfully
|
13
|
+
See the release notes at #{options.release_url}
|
14
|
+
|
15
|
+
Next steps:
|
16
|
+
* Get someone to review and approve the release pull request
|
17
|
+
* Merge the pull request manually from the command line with the following commands:
|
18
|
+
|
19
|
+
git checkout #{options.default_branch}
|
20
|
+
git merge --ff-only #{options.branch}
|
21
|
+
git push
|
22
|
+
MESSAGE
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CreateGithubRelease
|
4
|
+
# Base class for assertions
|
5
|
+
#
|
6
|
+
# All assertions must inherit from this class.
|
7
|
+
# It holds the options and knows how to print, puts and error while respecting the `quiet` flag.
|
8
|
+
#
|
9
|
+
# @api private
|
10
|
+
#
|
11
|
+
class AssertionBase
|
12
|
+
# Create a new assertion object and save the given `options`
|
13
|
+
# @param options [CreateGithubRelease::Options] the options
|
14
|
+
# @api private
|
15
|
+
def initialize(options)
|
16
|
+
@options = options
|
17
|
+
end
|
18
|
+
|
19
|
+
# This method must be overriden by a subclass
|
20
|
+
#
|
21
|
+
# The subclass is expected to call `error` if the assertion fails.
|
22
|
+
#
|
23
|
+
# @return [void]
|
24
|
+
#
|
25
|
+
# @api private
|
26
|
+
def assert
|
27
|
+
raise NotImplementedError
|
28
|
+
end
|
29
|
+
|
30
|
+
# @!attribute [r] options
|
31
|
+
#
|
32
|
+
# The options passed to the assertion object
|
33
|
+
# @return [CreateGithubRelease::Options] the options
|
34
|
+
# @api private
|
35
|
+
attr_reader :options
|
36
|
+
|
37
|
+
# Calls `Kernel.print` if the `quiet` flag is not set in the `options`
|
38
|
+
# @param args [Array] the arguments to pass to `Kernel.print`
|
39
|
+
# @return [void]
|
40
|
+
# @api private
|
41
|
+
def print(*args)
|
42
|
+
super unless options.quiet
|
43
|
+
end
|
44
|
+
|
45
|
+
# Calls `Kernel.puts` if the `quiet` flag is not set in the `options`
|
46
|
+
# @param args [Array] the arguments to pass to `Kernel.puts`
|
47
|
+
# @return [void]
|
48
|
+
# @api private
|
49
|
+
def puts(*args)
|
50
|
+
super unless options.quiet
|
51
|
+
end
|
52
|
+
|
53
|
+
# Writes a message to stderr and exits with exitcode 1
|
54
|
+
# @param message [String] the message to write to stderr
|
55
|
+
# @return [void]
|
56
|
+
# @api private
|
57
|
+
def error(message)
|
58
|
+
warn "ERROR: #{message}"
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
require 'create_github_release/assertion_base'
|
5
|
+
|
6
|
+
module CreateGithubRelease
|
7
|
+
module Assertions
|
8
|
+
# Assert that options.branch does not exist
|
9
|
+
#
|
10
|
+
# Checks both the local repository and the remote repository.
|
11
|
+
#
|
12
|
+
# @api public
|
13
|
+
#
|
14
|
+
class BundleIsUpToDate < AssertionBase
|
15
|
+
# Make sure the bundle is up to date
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# require 'create_github_release'
|
19
|
+
#
|
20
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
21
|
+
# assertion = CreateGithubRelease::Assertions::BundleIsUpToDate.new(options)
|
22
|
+
# begin
|
23
|
+
# assertion.assert
|
24
|
+
# puts 'Assertion passed'
|
25
|
+
# rescue SystemExit
|
26
|
+
# puts 'Assertion failed'
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# @return [void]
|
30
|
+
#
|
31
|
+
# @raise [SystemExit] if the assertion fails
|
32
|
+
#
|
33
|
+
def assert
|
34
|
+
print 'Checking that the bundle is up to date...'
|
35
|
+
if File.exist?('Gemfile.lock')
|
36
|
+
run_bundle_update
|
37
|
+
else
|
38
|
+
run_bundle_install
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# Run bundle update
|
45
|
+
# @return [void]
|
46
|
+
# @raise [SystemExit] if bundle update fails
|
47
|
+
# @api private
|
48
|
+
def run_bundle_update
|
49
|
+
print 'Running bundle update...'
|
50
|
+
`bundle update --quiet`
|
51
|
+
if $CHILD_STATUS.success?
|
52
|
+
puts 'OK'
|
53
|
+
else
|
54
|
+
error 'bundle update failed'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Run bundle install
|
59
|
+
# @return [void]
|
60
|
+
# @raise [SystemExit] if bundle update fails
|
61
|
+
# @api private
|
62
|
+
def run_bundle_install
|
63
|
+
print 'Running bundle install...'
|
64
|
+
`bundle install --quiet`
|
65
|
+
if $CHILD_STATUS.success?
|
66
|
+
puts 'OK'
|
67
|
+
else
|
68
|
+
error 'bundle install failed'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'create_github_release/assertion_base'
|
6
|
+
|
7
|
+
module CreateGithubRelease
|
8
|
+
module Assertions
|
9
|
+
# Assert that the changelog docker container exists
|
10
|
+
#
|
11
|
+
# @api public
|
12
|
+
#
|
13
|
+
class ChangelogDockerContainerExists < AssertionBase
|
14
|
+
# Make sure the changelog docker container exists
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# require 'create_github_release'
|
18
|
+
#
|
19
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
20
|
+
# assertion = CreateGithubRelease::Assertions::ChangelogDockerContainerExists.new(options)
|
21
|
+
# begin
|
22
|
+
# assertion.assert
|
23
|
+
# puts 'Assertion passed'
|
24
|
+
# rescue SystemExit
|
25
|
+
# puts 'Assertion failed'
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# @return [void]
|
29
|
+
#
|
30
|
+
# @raise [SystemExit] if the assertion fails
|
31
|
+
#
|
32
|
+
def assert
|
33
|
+
Dir.mktmpdir do |dir|
|
34
|
+
@dir = dir
|
35
|
+
@docker_file = "#{dir}/Dockerfile"
|
36
|
+
File.write(@docker_file, DOCKERFILE)
|
37
|
+
assert_changelog_docker_container_exists
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# Create the changelog docker container
|
44
|
+
# @return [void]
|
45
|
+
# @raise [SystemExit] if docker build fails
|
46
|
+
# @api private
|
47
|
+
def assert_changelog_docker_container_exists
|
48
|
+
print 'Checking that the changelog docker container exists (might take time to build)...'
|
49
|
+
`docker build --file "#{@docker_file}" --tag changelog-rs . 1>/dev/null 2>#{@dir}/stderr`
|
50
|
+
if $CHILD_STATUS.success?
|
51
|
+
puts 'OK'
|
52
|
+
else
|
53
|
+
error 'Failed to build the changelog-rs docker container'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
DOCKERFILE = <<~CONTENTS
|
58
|
+
FROM rust
|
59
|
+
|
60
|
+
# Build the docker image (from this project's root directory):
|
61
|
+
# docker build --file Dockerfile.changelog-rs --tag changelog-rs .
|
62
|
+
#
|
63
|
+
# Use this image to output a changelog (from this project's root directory):
|
64
|
+
# docker run --rm --volume "$PWD:/worktree" changelog-rs v1.9.1 v1.10.0
|
65
|
+
|
66
|
+
RUN cargo install changelog-rs
|
67
|
+
WORKDIR /worktree
|
68
|
+
|
69
|
+
ENTRYPOINT ["/usr/local/cargo/bin/changelog-rs", "/worktree"]
|
70
|
+
CONTENTS
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
require 'create_github_release/assertion_base'
|
5
|
+
|
6
|
+
module CreateGithubRelease
|
7
|
+
module Assertions
|
8
|
+
# Assert that docker is running
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
class DockerIsRunning < AssertionBase
|
13
|
+
# Make sure that docker is running
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# require 'create_github_release'
|
17
|
+
#
|
18
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
19
|
+
# assertion = CreateGithubRelease::Assertions::DockerIsRunning.new(options)
|
20
|
+
# begin
|
21
|
+
# assertion.assert
|
22
|
+
# puts 'Assertion passed'
|
23
|
+
# rescue SystemExit
|
24
|
+
# puts 'Assertion failed'
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# @return [void]
|
28
|
+
#
|
29
|
+
# @raise [SystemExit] if the assertion fails
|
30
|
+
#
|
31
|
+
def assert
|
32
|
+
print 'Checking that docker is installed and running...'
|
33
|
+
`docker info > /dev/null 2>&1`
|
34
|
+
if $CHILD_STATUS.success?
|
35
|
+
puts 'OK'
|
36
|
+
else
|
37
|
+
error 'Docker is not installed or not running'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
require 'create_github_release/assertion_base'
|
5
|
+
|
6
|
+
module CreateGithubRelease
|
7
|
+
module Assertions
|
8
|
+
# Assert that the 'gh' command is in the path
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
class GhCommandExists < AssertionBase
|
13
|
+
# Make sure that the 'gh' command is in the path
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# require 'create_github_release'
|
17
|
+
#
|
18
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
19
|
+
# assertion = CreateGithubRelease::Assertions::GhCommandExists.new(options)
|
20
|
+
# begin
|
21
|
+
# assertion.assert
|
22
|
+
# puts 'Assertion passed'
|
23
|
+
# rescue SystemExit
|
24
|
+
# puts 'Assertion failed'
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# @return [void]
|
28
|
+
#
|
29
|
+
# @raise [SystemExit] if the assertion fails
|
30
|
+
#
|
31
|
+
def assert
|
32
|
+
print 'Checking that the gh command exists...'
|
33
|
+
`which gh > /dev/null 2>&1`
|
34
|
+
if $CHILD_STATUS.success?
|
35
|
+
puts 'OK'
|
36
|
+
else
|
37
|
+
error 'The gh command was not found'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
require 'create_github_release/assertion_base'
|
5
|
+
|
6
|
+
module CreateGithubRelease
|
7
|
+
module Assertions
|
8
|
+
# Assert that the 'git' command is in the path
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
class GitCommandExists < AssertionBase
|
13
|
+
# Make sure that the 'git' command is in the path
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# require 'create_github_release'
|
17
|
+
#
|
18
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
19
|
+
# assertion = CreateGithubRelease::Assertions::GitCommandExists.new(options)
|
20
|
+
# begin
|
21
|
+
# assertion.assert
|
22
|
+
# puts 'Assertion passed'
|
23
|
+
# rescue SystemExit
|
24
|
+
# puts 'Assertion failed'
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# @return [void]
|
28
|
+
#
|
29
|
+
# @raise [SystemExit] if the assertion fails
|
30
|
+
#
|
31
|
+
def assert
|
32
|
+
print 'Checking that the git command exists...'
|
33
|
+
`which git > /dev/null 2>&1`
|
34
|
+
if $CHILD_STATUS.success?
|
35
|
+
puts 'OK'
|
36
|
+
else
|
37
|
+
error 'The git command was not found'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|