create_github_release 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +40 -20
  5. data/create_github_release.gemspec +2 -0
  6. data/exe/create-github-release +12 -8
  7. data/lib/create_github_release/assertion_base.rb +25 -11
  8. data/lib/create_github_release/assertions/bundle_is_up_to_date.rb +4 -3
  9. data/lib/create_github_release/assertions/{docker_is_running.rb → gh_authenticated.rb} +9 -8
  10. data/lib/create_github_release/assertions/gh_command_exists.rb +3 -2
  11. data/lib/create_github_release/assertions/git_command_exists.rb +3 -2
  12. data/lib/create_github_release/assertions/in_git_repo.rb +3 -2
  13. data/lib/create_github_release/assertions/in_repo_root_directory.rb +3 -2
  14. data/lib/create_github_release/assertions/last_release_tag_exists.rb +45 -0
  15. data/lib/create_github_release/assertions/local_and_remote_on_same_commit.rb +4 -3
  16. data/lib/create_github_release/assertions/local_release_branch_does_not_exist.rb +9 -6
  17. data/lib/create_github_release/assertions/local_release_tag_does_not_exist.rb +4 -4
  18. data/lib/create_github_release/assertions/no_staged_changes.rb +3 -2
  19. data/lib/create_github_release/assertions/no_uncommitted_changes.rb +3 -2
  20. data/lib/create_github_release/assertions/on_default_branch.rb +5 -4
  21. data/lib/create_github_release/assertions/remote_release_branch_does_not_exist.rb +6 -5
  22. data/lib/create_github_release/assertions/remote_release_tag_does_not_exist.rb +6 -5
  23. data/lib/create_github_release/assertions.rb +2 -2
  24. data/lib/create_github_release/backtick_debug.rb +69 -0
  25. data/lib/create_github_release/change.rb +73 -0
  26. data/lib/create_github_release/changelog.rb +54 -73
  27. data/lib/create_github_release/command_line_options.rb +367 -0
  28. data/lib/create_github_release/command_line_parser.rb +113 -25
  29. data/lib/create_github_release/project.rb +787 -0
  30. data/lib/create_github_release/release_assertions.rb +3 -3
  31. data/lib/create_github_release/release_tasks.rb +1 -1
  32. data/lib/create_github_release/task_base.rb +25 -11
  33. data/lib/create_github_release/tasks/commit_release.rb +4 -3
  34. data/lib/create_github_release/tasks/create_github_release.rb +16 -35
  35. data/lib/create_github_release/tasks/create_release_branch.rb +6 -5
  36. data/lib/create_github_release/tasks/create_release_pull_request.rb +10 -42
  37. data/lib/create_github_release/tasks/create_release_tag.rb +6 -5
  38. data/lib/create_github_release/tasks/push_release.rb +5 -4
  39. data/lib/create_github_release/tasks/update_changelog.rb +16 -67
  40. data/lib/create_github_release/tasks/update_version.rb +4 -3
  41. data/lib/create_github_release/version.rb +1 -1
  42. data/lib/create_github_release.rb +4 -2
  43. metadata +37 -7
  44. data/lib/create_github_release/assertions/changelog_docker_container_exists.rb +0 -73
  45. data/lib/create_github_release/options.rb +0 -397
  46. data/lib/create_github_release/release.rb +0 -82
@@ -55,13 +55,13 @@ module CreateGithubRelease
55
55
  CreateGithubRelease::Assertions::NoUncommittedChanges,
56
56
  CreateGithubRelease::Assertions::NoStagedChanges,
57
57
  CreateGithubRelease::Assertions::LocalAndRemoteOnSameCommit,
58
+ CreateGithubRelease::Assertions::LastReleaseTagExists,
58
59
  CreateGithubRelease::Assertions::LocalReleaseTagDoesNotExist,
59
60
  CreateGithubRelease::Assertions::RemoteReleaseTagDoesNotExist,
60
61
  CreateGithubRelease::Assertions::LocalReleaseBranchDoesNotExist,
61
62
  CreateGithubRelease::Assertions::RemoteReleaseBranchDoesNotExist,
62
- CreateGithubRelease::Assertions::DockerIsRunning,
63
- CreateGithubRelease::Assertions::ChangelogDockerContainerExists,
64
- CreateGithubRelease::Assertions::GhCommandExists
63
+ CreateGithubRelease::Assertions::GhCommandExists,
64
+ CreateGithubRelease::Assertions::GhAuthenticated
65
65
  ].freeze
66
66
 
67
67
  # Run all assertions
@@ -46,11 +46,11 @@ module CreateGithubRelease
46
46
  # @return [Array<Class>] The tasks that will be run to create a new Github release
47
47
  #
48
48
  TASKS = [
49
- CreateGithubRelease::Tasks::CreateReleaseTag,
50
49
  CreateGithubRelease::Tasks::CreateReleaseBranch,
51
50
  CreateGithubRelease::Tasks::UpdateVersion,
52
51
  CreateGithubRelease::Tasks::UpdateChangelog,
53
52
  CreateGithubRelease::Tasks::CommitRelease,
53
+ CreateGithubRelease::Tasks::CreateReleaseTag,
54
54
  CreateGithubRelease::Tasks::PushRelease,
55
55
  CreateGithubRelease::Tasks::CreateGithubRelease,
56
56
  CreateGithubRelease::Tasks::CreateReleasePullRequest
@@ -9,11 +9,14 @@ module CreateGithubRelease
9
9
  # @api private
10
10
  #
11
11
  class TaskBase
12
- # Create a new tasks object and save the given `options`
13
- # @param options [CreateGithubRelease::Options] the options
12
+ # Create a new tasks object and save the given `project`
13
+ # @param project [CreateGithubRelease::Project] the project to create the release for
14
14
  # @api private
15
- def initialize(options)
16
- @options = options
15
+ def initialize(project)
16
+ raise ArgumentError, 'project must be a CreateGithubRelease::Project' unless
17
+ project.is_a?(CreateGithubRelease::Project)
18
+
19
+ @project = project
17
20
  end
18
21
 
19
22
  # This method must be overriden by a subclass
@@ -27,27 +30,27 @@ module CreateGithubRelease
27
30
  raise NotImplementedError
28
31
  end
29
32
 
30
- # @!attribute [r] options
33
+ # @!attribute [r] project
31
34
  #
32
- # The options passed to the task object
33
- # @return [CreateGithubRelease::Options] the options
35
+ # The project passed to the task object
36
+ # @return [CreateGithubRelease::Project]
34
37
  # @api private
35
- attr_reader :options
38
+ attr_reader :project
36
39
 
37
40
  # Calls `Kernel.print` if the `quiet` flag is not set in the `options`
38
41
  # @param args [Array] the arguments to pass to `Kernel.print`
39
42
  # @return [void]
40
43
  # @api private
41
44
  def print(*args)
42
- super unless options.quiet
45
+ super unless project.quiet?
43
46
  end
44
47
 
45
- # Calls `Kernel.puts` if the `quiet` flag is not set in the `options`
48
+ # Calls `Kernel.puts` if the `quiet` flag is not set in the `project`
46
49
  # @param args [Array] the arguments to pass to `Kernel.puts`
47
50
  # @return [void]
48
51
  # @api private
49
52
  def puts(*args)
50
- super unless options.quiet
53
+ super unless project.quiet?
51
54
  end
52
55
 
53
56
  # Writes a message to stderr and exits with exitcode 1
@@ -58,5 +61,16 @@ module CreateGithubRelease
58
61
  warn "ERROR: #{message}"
59
62
  exit 1
60
63
  end
64
+
65
+ # `true` if the `project.verbose?` flag is `true`
66
+ # @return [Boolean]
67
+ # @api private
68
+ def backtick_debug?
69
+ project.verbose?
70
+ end
71
+
72
+ # This overrides the backtick operator for this class to output debug
73
+ # information if `verbose?` is true
74
+ include CreateGithubRelease::BacktickDebug
61
75
  end
62
76
  end
@@ -15,8 +15,9 @@ module CreateGithubRelease
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
19
- # task = CreateGithubRelease::Tasks::CommitRelease.new(options)
18
+ # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
19
+ # project = CreateGithubRelease::Project.new(options)
20
+ # task = CreateGithubRelease::Tasks::CommitRelease.new(project)
20
21
  # begin
21
22
  # task.run
22
23
  # puts 'Task completed successfully'
@@ -30,7 +31,7 @@ module CreateGithubRelease
30
31
  #
31
32
  def run
32
33
  print 'Making release commit...'
33
- `git commit -s -m 'Release #{options.tag}'`
34
+ `git commit -s -m 'Release #{project.next_release_tag}'`
34
35
  if $CHILD_STATUS.success?
35
36
  puts 'OK'
36
37
  else
@@ -16,8 +16,9 @@ module CreateGithubRelease
16
16
  # @example
17
17
  # require 'create_github_release'
18
18
  #
19
- # options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
20
- # task = CreateGithubRelease::Tasks::CreateGithubRelease.new(options)
19
+ # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
20
+ # project = CreateGithubRelease::Project.new(options)
21
+ # task = CreateGithubRelease::Tasks::CreateGithubRelease.new(project)
21
22
  # begin
22
23
  # task.run
23
24
  # puts 'Task completed successfully'
@@ -30,7 +31,7 @@ module CreateGithubRelease
30
31
  # @raise [SystemExit] if the task fails
31
32
  #
32
33
  def run
33
- path = write_changelog_to_temp_file(generate_changelog)
34
+ path = write_release_description_to_tmp_file(project.next_release_description)
34
35
  begin
35
36
  create_github_release(path)
36
37
  ensure
@@ -43,10 +44,10 @@ module CreateGithubRelease
43
44
  # Create the gh command to create the Github release
44
45
  # @return [String] the command to run
45
46
  # @api private
46
- def gh_command(default_branch, tag, changelog_path)
47
+ def gh_command(default_branch, tag, tmp_path)
47
48
  "gh release create '#{tag}' " \
48
49
  "--title 'Release #{tag}' " \
49
- "--notes-file '#{changelog_path}' " \
50
+ "--notes-file '#{tmp_path}' " \
50
51
  "--target '#{default_branch}'"
51
52
  end
52
53
 
@@ -54,9 +55,9 @@ module CreateGithubRelease
54
55
  # @return [void]
55
56
  # @raise [SystemExit] if the gh command fails
56
57
  # @api private
57
- def create_github_release(changelog_path)
58
- print "Creating GitHub release '#{options.tag}'..."
59
- `#{gh_command(options.default_branch, options.tag, changelog_path)}`
58
+ def create_github_release(tmp_path)
59
+ print "Creating GitHub release '#{project.next_release_tag}'..."
60
+ `#{gh_command(project.default_branch, project.next_release_tag, tmp_path)}`
60
61
  if $CHILD_STATUS.success?
61
62
  puts 'OK'
62
63
  else
@@ -64,43 +65,23 @@ module CreateGithubRelease
64
65
  end
65
66
  end
66
67
 
67
- # Writes the changelog to a temporary file
68
- # @return [void]
68
+ # Writes the release_description to a tmp file and returns the tmp file path
69
+ #
70
+ # The tmp file must be deleted by the caller.
71
+ #
72
+ # @return [String] the path to the tmp file that was create
69
73
  # @raise [SystemExit] if a temp file could not be created
70
74
  # @api private
71
- def write_changelog_to_temp_file(changelog)
75
+ def write_release_description_to_tmp_file(release_description)
72
76
  begin
73
77
  f = Tempfile.create
74
78
  rescue StandardError => e
75
79
  error "Could not create a temporary file: #{e.message}"
76
80
  end
77
- f.write(changelog)
81
+ f.write(release_description)
78
82
  f.close
79
83
  f.path
80
84
  end
81
-
82
- # Build the command that generates the description of the new release
83
- # @return [String] the command to run
84
- # @api private
85
- def docker_command(git_dir, from_tag, to_tag)
86
- "docker run --rm --volume '#{git_dir}:/worktree' changelog-rs '#{from_tag}' '#{to_tag}'"
87
- end
88
-
89
- # Generate the description of the new release using docker
90
- # @return [void]
91
- # @raise [SystemExit] if the docker command fails
92
- # @api private
93
- def generate_changelog
94
- print 'Generating changelog...'
95
- command = docker_command(FileUtils.pwd, options.current_tag, options.next_tag)
96
- `#{command}`.rstrip.lines[1..].join.tap do
97
- if $CHILD_STATUS.success?
98
- puts 'OK'
99
- else
100
- error 'Could not generate the changelog'
101
- end
102
- end
103
- end
104
85
  end
105
86
  end
106
87
  end
@@ -15,8 +15,9 @@ module CreateGithubRelease
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
19
- # task = CreateGithubRelease::Tasks::CreateReleaseBranch.new(options)
18
+ # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
19
+ # project = CreateGithubRelease::Project.new(options)
20
+ # task = CreateGithubRelease::Tasks::CreateReleaseBranch.new(project)
20
21
  # begin
21
22
  # task.run
22
23
  # puts 'Task completed successfully'
@@ -29,12 +30,12 @@ module CreateGithubRelease
29
30
  # @raise [SystemExit] if the task fails
30
31
  #
31
32
  def run
32
- print "Creating branch '#{options.branch}'..."
33
- `git checkout -b '#{options.branch}' > /dev/null 2>&1`
33
+ print "Creating branch '#{project.release_branch}'..."
34
+ `git checkout -b '#{project.release_branch}' > /dev/null 2>&1`
34
35
  if $CHILD_STATUS.success?
35
36
  puts 'OK'
36
37
  else
37
- error "Could not create branch '#{options.branch}'" unless $CHILD_STATUS.success?
38
+ error "Could not create branch '#{project.release_branch}'" unless $CHILD_STATUS.success?
38
39
  end
39
40
  end
40
41
  end
@@ -15,8 +15,9 @@ module CreateGithubRelease
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
19
- # task = CreateGithubRelease::Tasks::CreateReleasePullRequest.new(options)
18
+ # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
19
+ # project = CreateGithubRelease::Project.new(options)
20
+ # task = CreateGithubRelease::Tasks::CreateReleasePullRequest.new(project)
20
21
  # begin
21
22
  # task.run
22
23
  # puts 'Task completed successfully'
@@ -29,11 +30,11 @@ module CreateGithubRelease
29
30
  # @raise [SystemExit] if the task fails
30
31
  #
31
32
  def run
32
- path = write_pr_body_to_temp_file(generate_changelog)
33
+ tmp_path = write_pr_body_to_tmp_file
33
34
  begin
34
- create_release_pr(path)
35
+ create_release_pr(tmp_path)
35
36
  ensure
36
- File.unlink(path)
37
+ File.unlink(tmp_path)
37
38
  end
38
39
  end
39
40
 
@@ -45,8 +46,8 @@ module CreateGithubRelease
45
46
  # @api private
46
47
  def create_release_pr(path)
47
48
  print 'Creating GitHub pull request...'
48
- tag = options.tag
49
- default_branch = options.default_branch
49
+ tag = project.next_release_tag
50
+ default_branch = project.default_branch
50
51
  `gh pr create --title 'Release #{tag}' --body-file '#{path}' --base '#{default_branch}'`
51
52
  if $CHILD_STATUS.success?
52
53
  puts 'OK'
@@ -55,53 +56,20 @@ module CreateGithubRelease
55
56
  end
56
57
  end
57
58
 
58
- # The body of the pull request
59
- # @return [String] the body of the pull request
60
- # @api private
61
- def pr_body(changelog)
62
- <<~BODY.chomp
63
- ## Change Log
64
- #{changelog}
65
- BODY
66
- end
67
-
68
59
  # Write the changelog to a new temporary file
69
60
  # @return [String] the path to the temporary file
70
61
  # @raise [SystemExit] if the temp could not be created
71
62
  # @api private
72
- def write_pr_body_to_temp_file(changelog)
63
+ def write_pr_body_to_tmp_file
73
64
  begin
74
65
  f = Tempfile.create
75
66
  rescue StandardError => e
76
67
  error "Could not create a temporary file: #{e.message}"
77
68
  end
78
- f.write(pr_body(changelog))
69
+ f.write("# Release PR\n\n#{project.next_release_description}")
79
70
  f.close
80
71
  f.path
81
72
  end
82
-
83
- # The command to list the changes in the relese
84
- # @return [String] the command to run
85
- # @api private
86
- def docker_command(git_dir, from_tag, to_tag)
87
- "docker run --rm --volume '#{git_dir}:/worktree' changelog-rs '#{from_tag}' '#{to_tag}'"
88
- end
89
-
90
- # Generate the list of changes in the release using docker
91
- # @return [String] the list of changes
92
- # @raise [SystemExit] if the docker command fails
93
- # @api private
94
- def generate_changelog
95
- print 'Generating changelog...'
96
- command = docker_command(FileUtils.pwd, options.current_tag, options.next_tag)
97
- `#{command}`.rstrip.lines[1..].join.tap do
98
- if $CHILD_STATUS.success?
99
- puts 'OK'
100
- else
101
- error 'Could not generate the changelog'
102
- end
103
- end
104
- end
105
73
  end
106
74
  end
107
75
  end
@@ -15,8 +15,9 @@ module CreateGithubRelease
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
19
- # task = CreateGithubRelease::Tasks::CreateReleaseTag.new(options)
18
+ # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
19
+ # project = CreateGithubRelease::Project.new(options)
20
+ # task = CreateGithubRelease::Tasks::CreateReleaseTag.new(project)
20
21
  # begin
21
22
  # task.run
22
23
  # puts 'Task completed successfully'
@@ -29,12 +30,12 @@ module CreateGithubRelease
29
30
  # @raise [SystemExit] if the task fails
30
31
  #
31
32
  def run
32
- print "Creating tag '#{options.tag}'..."
33
- `git tag '#{options.tag}'`
33
+ print "Creating tag '#{project.next_release_tag}'..."
34
+ `git tag '#{project.next_release_tag}'`
34
35
  if $CHILD_STATUS.success?
35
36
  puts 'OK'
36
37
  else
37
- error "Could not create tag '#{options.tag}'"
38
+ error "Could not create tag '#{project.next_release_tag}'"
38
39
  end
39
40
  end
40
41
  end
@@ -15,8 +15,9 @@ module CreateGithubRelease
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
19
- # task = CreateGithubRelease::Tasks::PushRelease.new(options)
18
+ # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
19
+ # project = CreateGithubRelease::Project.new(options)
20
+ # task = CreateGithubRelease::Tasks::PushRelease.new(project)
20
21
  # begin
21
22
  # task.run
22
23
  # puts 'Task completed successfully'
@@ -29,8 +30,8 @@ module CreateGithubRelease
29
30
  # @raise [SystemExit] if the task fails
30
31
  #
31
32
  def run
32
- print "Pushing branch '#{options.branch}' to remote..."
33
- `git push --tags --set-upstream '#{options.remote}' '#{options.branch}' > /dev/null 2>&1`
33
+ print "Pushing branch '#{project.release_branch}' to remote..."
34
+ `git push --tags --set-upstream '#{project.remote}' '#{project.release_branch}' > /dev/null 2>&1`
34
35
  if $CHILD_STATUS.success?
35
36
  puts 'OK'
36
37
  else
@@ -13,11 +13,15 @@ module CreateGithubRelease
13
13
  class UpdateChangelog < TaskBase
14
14
  # Update the changelog file with changes made since the last release
15
15
  #
16
+ # The changes since the last release are determined by using git log of all
17
+ # changes after the previous release tag up to and including HEAD.
18
+ #
16
19
  # @example
17
20
  # require 'create_github_release'
18
21
  #
19
- # options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
20
- # task = CreateGithubRelease::Tasks::UpdateChangelog.new(options)
22
+ # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
23
+ # project = CreateGithubRelease::Project.new(options)
24
+ # task = CreateGithubRelease::Tasks::UpdateChangelog.new(project)
21
25
  # begin
22
26
  # task.run
23
27
  # puts 'Task completed successfully'
@@ -30,11 +34,7 @@ module CreateGithubRelease
30
34
  # @raise [SystemExit] if the task fails
31
35
  #
32
36
  def run
33
- current_tag = options.current_tag
34
- next_tag = options.next_tag
35
- next_tag_date = next_tag_date(next_tag)
36
- new_release = new_release(current_tag, next_tag, next_tag_date)
37
- update_changelog(existing_changelog, new_release)
37
+ update_changelog
38
38
  stage_updated_changelog
39
39
  end
40
40
 
@@ -45,65 +45,13 @@ module CreateGithubRelease
45
45
  # @raise [SystemExit] if the git command fails
46
46
  # @api private
47
47
  def stage_updated_changelog
48
- print 'Staging CHANGLOG.md...'
49
-
50
- `git add CHANGELOG.md`
51
- if $CHILD_STATUS.success?
52
- puts 'OK'
53
- else
54
- error 'Could not stage changes to CHANGELOG.md'
55
- end
56
- end
57
-
58
- # Read the existing changelog file
59
- # @return [String] the contents of the changelog file
60
- # @raise [SystemExit] if the file cannot be read
61
- # @api private
62
- def existing_changelog
63
- @existing_changelog ||= begin
64
- File.read('CHANGELOG.md')
65
- rescue Errno::ENOENT
66
- ''
67
- end
68
- end
69
-
70
- # Find the date the release tag was created using git
71
- # @return [Date] the date the release tag was created
72
- # @raise [SystemExit] if the git command fails
73
- # @api private
74
- def next_tag_date(next_tag)
75
- @next_tag_date ||= begin
76
- print "Determining date #{next_tag} was created..."
77
- date = `git show --format=format:%aI --quiet "#{next_tag}"`
78
- if $CHILD_STATUS.success?
79
- puts 'OK'
80
- Date.parse(date)
81
- else
82
- error 'Could not stage changes to CHANGELOG.md'
83
- end
84
- end
85
- end
48
+ print "Staging #{project.changelog_path}..."
86
49
 
87
- # Build the command to list the changes since the last release
88
- # @return [String] the command to list the changes since the last release
89
- # @api private
90
- def docker_command(git_dir, from_tag, to_tag)
91
- "docker run --rm --volume '#{git_dir}:/worktree' changelog-rs '#{from_tag}' '#{to_tag}'"
92
- end
93
-
94
- # Generate the new release section of the changelog
95
- # @return [CreateGithubRelease::Release] the new release section of the changelog
96
- # @raise [SystemExit] if the docker command fails
97
- # @api private
98
- def new_release(current_tag, next_tag, next_tag_date)
99
- print 'Generating release notes...'
100
- command = docker_command(FileUtils.pwd, current_tag, next_tag)
101
- release_description = `#{command}`.rstrip.lines[1..].join
50
+ `git add #{project.changelog_path}`
102
51
  if $CHILD_STATUS.success?
103
52
  puts 'OK'
104
- ::CreateGithubRelease::Release.new(next_tag, next_tag_date, release_description)
105
53
  else
106
- error 'Could not generate the release notes'
54
+ error "Could not stage changes to #{project.changelog_path}"
107
55
  end
108
56
  end
109
57
 
@@ -111,13 +59,14 @@ module CreateGithubRelease
111
59
  # @return [void]
112
60
  # @raise [SystemExit] if the file cannot be written
113
61
  # @api private
114
- def update_changelog(existing_changelog, new_release)
115
- print 'Updating CHANGELOG.md...'
116
- changelog = ::CreateGithubRelease::Changelog.new(existing_changelog, new_release)
62
+ def update_changelog
63
+ print "Updating #{project.changelog_path}..."
117
64
  begin
118
- File.write('CHANGELOG.md', changelog.to_s)
65
+ # File.open('debug.txt', 'w') { |f| f.write("CHANGELOG:\n#{project.next_release_changelog}") }
66
+ File.write(project.changelog_path, project.next_release_changelog)
119
67
  rescue StandardError => e
120
- error "Could not write to CHANGELOG.md: #{e.message}"
68
+ # File.open('debug.txt', 'w') { |f| f.write("#{project.changelog_path}\n\nERROR:\n#{e.message}") }
69
+ error "Could not update #{project.changelog_path}: #{e.message}"
121
70
  end
122
71
  puts 'OK'
123
72
  end
@@ -15,8 +15,9 @@ module CreateGithubRelease
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::Options.new { |o| o.release_type = 'major' }
19
- # task = CreateGithubRelease::Tasks::UpdateVersion.new(options)
18
+ # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
19
+ # project = CreateGithubRelease::Project.new(options)
20
+ # task = CreateGithubRelease::Tasks::UpdateVersion.new(project)
20
21
  # begin
21
22
  # task.run
22
23
  # puts 'Task completed successfully'
@@ -30,7 +31,7 @@ module CreateGithubRelease
30
31
  #
31
32
  def run
32
33
  print 'Updating version...'
33
- message, result = Bump::Bump.run(options.release_type, commit: false)
34
+ message, result = Bump::Bump.run(project.release_type, commit: false)
34
35
  error "Could not bump version: #{message}" unless result.zero?
35
36
 
36
37
  version_file = Bump::Bump.file
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CreateGithubRelease
4
4
  # The version of this gem
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'create_github_release/backtick_debug'
4
+ require 'create_github_release/command_line_options'
3
5
  require 'create_github_release/command_line_parser'
6
+ require 'create_github_release/project'
4
7
 
8
+ require 'create_github_release/change'
5
9
  require 'create_github_release/changelog'
6
- require 'create_github_release/options'
7
- require 'create_github_release/release'
8
10
 
9
11
  require 'create_github_release/assertion_base'
10
12
  require 'create_github_release/assertions'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: create_github_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-16 00:00:00.000000000 Z
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bump
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.21'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov-lcov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.8'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.8'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: solargraph
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0.47'
139
+ - !ruby/object:Gem::Dependency
140
+ name: timecop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.9'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.9'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: yard
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -173,12 +201,12 @@ files:
173
201
  - lib/create_github_release/assertion_base.rb
174
202
  - lib/create_github_release/assertions.rb
175
203
  - lib/create_github_release/assertions/bundle_is_up_to_date.rb
176
- - lib/create_github_release/assertions/changelog_docker_container_exists.rb
177
- - lib/create_github_release/assertions/docker_is_running.rb
204
+ - lib/create_github_release/assertions/gh_authenticated.rb
178
205
  - lib/create_github_release/assertions/gh_command_exists.rb
179
206
  - lib/create_github_release/assertions/git_command_exists.rb
180
207
  - lib/create_github_release/assertions/in_git_repo.rb
181
208
  - lib/create_github_release/assertions/in_repo_root_directory.rb
209
+ - lib/create_github_release/assertions/last_release_tag_exists.rb
182
210
  - lib/create_github_release/assertions/local_and_remote_on_same_commit.rb
183
211
  - lib/create_github_release/assertions/local_release_branch_does_not_exist.rb
184
212
  - lib/create_github_release/assertions/local_release_tag_does_not_exist.rb
@@ -187,10 +215,12 @@ files:
187
215
  - lib/create_github_release/assertions/on_default_branch.rb
188
216
  - lib/create_github_release/assertions/remote_release_branch_does_not_exist.rb
189
217
  - lib/create_github_release/assertions/remote_release_tag_does_not_exist.rb
218
+ - lib/create_github_release/backtick_debug.rb
219
+ - lib/create_github_release/change.rb
190
220
  - lib/create_github_release/changelog.rb
221
+ - lib/create_github_release/command_line_options.rb
191
222
  - lib/create_github_release/command_line_parser.rb
192
- - lib/create_github_release/options.rb
193
- - lib/create_github_release/release.rb
223
+ - lib/create_github_release/project.rb
194
224
  - lib/create_github_release/release_assertions.rb
195
225
  - lib/create_github_release/release_tasks.rb
196
226
  - lib/create_github_release/task_base.rb
@@ -228,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
258
  - !ruby/object:Gem::Version
229
259
  version: '0'
230
260
  requirements: []
231
- rubygems_version: 3.3.7
261
+ rubygems_version: 3.2.3
232
262
  signing_key:
233
263
  specification_version: 4
234
264
  summary: Create a GitHub release PR for a Ruby Gem