create_github_release 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,44 @@
|
|
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 current directory is a git repository
|
9
|
+
#
|
10
|
+
# Checks both the local repository and the remote repository.
|
11
|
+
#
|
12
|
+
# @api public
|
13
|
+
#
|
14
|
+
class InGitRepo < AssertionBase
|
15
|
+
# Make sure that the current directory is a git repository
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# require 'create_github_release'
|
19
|
+
#
|
20
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
21
|
+
# assertion = CreateGithubRelease::Assertions::InGitRepo.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 you are in a git repo...'
|
35
|
+
`git rev-parse --is-inside-work-tree --quiet > /dev/null 2>&1`
|
36
|
+
if $CHILD_STATUS.success?
|
37
|
+
puts 'OK'
|
38
|
+
else
|
39
|
+
error 'You are not in a git repo'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'create_github_release/assertion_base'
|
6
|
+
|
7
|
+
module CreateGithubRelease
|
8
|
+
module Assertions
|
9
|
+
# Assert that the current directory is the root of the repository
|
10
|
+
#
|
11
|
+
# Checks both the local repository and the remote repository.
|
12
|
+
#
|
13
|
+
# @api public
|
14
|
+
#
|
15
|
+
class InRepoRootDirectory < AssertionBase
|
16
|
+
# Make sure that the current directory is the root of the repository
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# require 'create_github_release'
|
20
|
+
#
|
21
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
22
|
+
# assertion = CreateGithubRelease::Assertions::InRepoRootDirectory.new(options)
|
23
|
+
# begin
|
24
|
+
# assertion.assert
|
25
|
+
# puts 'Assertion passed'
|
26
|
+
# rescue SystemExit
|
27
|
+
# puts 'Assertion failed'
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# @return [void]
|
31
|
+
#
|
32
|
+
# @raise [SystemExit] if the assertion fails
|
33
|
+
#
|
34
|
+
def assert
|
35
|
+
print "Checking that you are in the repo's root directory..."
|
36
|
+
toplevel_directory = `git rev-parse --show-toplevel`.chomp
|
37
|
+
error "git rev-parse failed: #{$CHILD_STATUS.exitstatus}" unless $CHILD_STATUS.success?
|
38
|
+
|
39
|
+
if toplevel_directory == FileUtils.pwd
|
40
|
+
puts 'OK'
|
41
|
+
else
|
42
|
+
error "You are not in the repo's root directory"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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 local working directory and the remote are on the same commit
|
9
|
+
#
|
10
|
+
# Checks both the local repository and the remote repository.
|
11
|
+
#
|
12
|
+
# @api public
|
13
|
+
#
|
14
|
+
class LocalAndRemoteOnSameCommit < AssertionBase
|
15
|
+
# Make sure that the local working directory and the remote are on the same commit
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# require 'create_github_release'
|
19
|
+
#
|
20
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
21
|
+
# assertion = CreateGithubRelease::Assertions::LocalAndRemoteOnSameCommit.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 local and remote are on the same commit...'
|
35
|
+
local_commit = `git rev-parse HEAD`.chomp
|
36
|
+
remote_commit = `git ls-remote '#{options.remote}' '#{options.default_branch}' | cut -f 1`.chomp
|
37
|
+
if local_commit == remote_commit
|
38
|
+
puts 'OK'
|
39
|
+
else
|
40
|
+
error 'Local and remote are not on the same commit'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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 release branch does not exist in the local repository
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
class LocalReleaseBranchDoesNotExist < AssertionBase
|
13
|
+
# Assert that the release branch does not exist in the local repository
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# require 'create_github_release'
|
17
|
+
#
|
18
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
19
|
+
# assertion = CreateGithubRelease::Assertions::LocalReleaseBranchDoesNotExist.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 local branch ' #{options.branch}' does not exist..."
|
33
|
+
|
34
|
+
if `git branch --list '#{options.branch}' | wc -l`.to_i.zero? && $CHILD_STATUS.success?
|
35
|
+
puts 'OK'
|
36
|
+
else
|
37
|
+
error 'Could not list branches' unless $CHILD_STATUS.success?
|
38
|
+
error "'#{options.branch}' already exists."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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 release tag does not exist in the local repository
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
class LocalReleaseTagDoesNotExist < AssertionBase
|
13
|
+
# Assert that the release tag does not exist in the local repository
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# require 'create_github_release'
|
17
|
+
#
|
18
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
19
|
+
# assertion = CreateGithubRelease::Assertions::LocalReleaseTagDoesNotExist.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 local tag '#{options.tag}' does not exist..."
|
33
|
+
|
34
|
+
tags = `git tag --list "#{options.tag}"`.chomp
|
35
|
+
error 'Could not list tags' unless $CHILD_STATUS.success?
|
36
|
+
|
37
|
+
if tags.split.empty?
|
38
|
+
puts 'OK'
|
39
|
+
else
|
40
|
+
error "Local tag '#{options.tag}' already exists"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,46 @@
|
|
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 there are no staged changes in the local repository
|
9
|
+
#
|
10
|
+
# Checks both the local repository and the remote repository.
|
11
|
+
#
|
12
|
+
# @api public
|
13
|
+
#
|
14
|
+
class NoStagedChanges < AssertionBase
|
15
|
+
# Assert that there are no staged changes in the local repository
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# require 'create_github_release'
|
19
|
+
#
|
20
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
21
|
+
# assertion = CreateGithubRelease::Assertions::NoStagedChanges.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 there are no staged changes...'
|
35
|
+
change_count = `git diff --staged --name-only | wc -l`.to_i
|
36
|
+
error "git diff command failed: #{$CHILD_STATUS.exitstatus}" unless $CHILD_STATUS.success?
|
37
|
+
|
38
|
+
if change_count.zero?
|
39
|
+
puts 'OK'
|
40
|
+
else
|
41
|
+
error 'There are staged changes'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
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 there are no uncommitted changes in the local working copy
|
9
|
+
#
|
10
|
+
# Checks both the local repository and the remote repository.
|
11
|
+
#
|
12
|
+
# @api public
|
13
|
+
#
|
14
|
+
class NoUncommittedChanges < AssertionBase
|
15
|
+
# Assert that there are no uncommitted changes in the local working copy
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# require 'create_github_release'
|
19
|
+
#
|
20
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
21
|
+
# assertion = CreateGithubRelease::Assertions::NoUncommittedChanges.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 there are no uncommitted changes...'
|
35
|
+
change_count = `git status --porcelain | wc -l`.to_i
|
36
|
+
error "git status command failed: #{$CHILD_STATUS.exitstatus}" unless $CHILD_STATUS.success?
|
37
|
+
|
38
|
+
if change_count.zero?
|
39
|
+
puts 'OK'
|
40
|
+
else
|
41
|
+
error 'There are uncommitted changes'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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 default branch is checked out
|
9
|
+
#
|
10
|
+
# Checks both the local repository and the remote repository.
|
11
|
+
#
|
12
|
+
# @api public
|
13
|
+
#
|
14
|
+
class OnDefaultBranch < AssertionBase
|
15
|
+
# Assert that the default branch is checked out
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# require 'create_github_release'
|
19
|
+
#
|
20
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
21
|
+
# assertion = CreateGithubRelease::Assertions::OnDefaultBranch.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 you are on the default branch...'
|
35
|
+
current_branch = `git branch --show-current`.chomp
|
36
|
+
if current_branch == options.default_branch
|
37
|
+
puts 'OK'
|
38
|
+
else
|
39
|
+
error "You are not on the default branch '#{options.default_branch}'"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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 release branch does not exist in the remote repository
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
class RemoteReleaseBranchDoesNotExist < AssertionBase
|
13
|
+
# Assert that the release branch does not exist in the remote repository
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# require 'create_github_release'
|
17
|
+
#
|
18
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
19
|
+
# assertion = CreateGithubRelease::Assertions::RemoteReleaseBranchDoesNotExist.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 remote branch '#{options.branch}' does not exist..."
|
33
|
+
`git ls-remote --heads --exit-code '#{options.remote}' '#{options.branch}' >/dev/null 2>&1`
|
34
|
+
if $CHILD_STATUS.exitstatus == 2
|
35
|
+
puts 'OK'
|
36
|
+
else
|
37
|
+
error 'Could not list branches' unless $CHILD_STATUS.success?
|
38
|
+
error "'#{options.branch}' already exists"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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 release tag does not exist in the remote repository
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
class RemoteReleaseTagDoesNotExist < AssertionBase
|
13
|
+
# Assert that the release tag does not exist in the remote repository
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# require 'create_github_release'
|
17
|
+
#
|
18
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
|
19
|
+
# assertion = CreateGithubRelease::Assertions::RemoteReleaseTagDoesNotExist.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 remote tag '#{options.tag}' does not exist..."
|
33
|
+
`git ls-remote --tags --exit-code '#{options.remote}' #{options.tag} >/dev/null 2>&1`
|
34
|
+
if $CHILD_STATUS.exitstatus == 2
|
35
|
+
puts 'OK'
|
36
|
+
else
|
37
|
+
error 'Could not list tags' unless $CHILD_STATUS.success?
|
38
|
+
error "Remote tag '#{options.tag}' already exists"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CreateGithubRelease
|
4
|
+
# Assertions used to validate that everything is ready to create the release
|
5
|
+
#
|
6
|
+
# @api public
|
7
|
+
#
|
8
|
+
module Assertions; end
|
9
|
+
end
|
10
|
+
|
11
|
+
require_relative 'assertions/bundle_is_up_to_date'
|
12
|
+
require_relative 'assertions/changelog_docker_container_exists'
|
13
|
+
require_relative 'assertions/docker_is_running'
|
14
|
+
require_relative 'assertions/gh_command_exists'
|
15
|
+
require_relative 'assertions/git_command_exists'
|
16
|
+
require_relative 'assertions/in_git_repo'
|
17
|
+
require_relative 'assertions/in_repo_root_directory'
|
18
|
+
require_relative 'assertions/local_and_remote_on_same_commit'
|
19
|
+
require_relative 'assertions/local_release_branch_does_not_exist'
|
20
|
+
require_relative 'assertions/local_release_tag_does_not_exist'
|
21
|
+
require_relative 'assertions/no_staged_changes'
|
22
|
+
require_relative 'assertions/no_uncommitted_changes'
|
23
|
+
require_relative 'assertions/on_default_branch'
|
24
|
+
require_relative 'assertions/remote_release_branch_does_not_exist'
|
25
|
+
require_relative 'assertions/remote_release_tag_does_not_exist'
|