Skip to content

Commit

Permalink
feat: Include changelog notes to release tag message
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdugan3 committed Jan 8, 2021
1 parent e9889a4 commit 500d926
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 10 additions & 5 deletions lib/git_ops/changelog.ex
Expand Up @@ -56,23 +56,28 @@ defmodule GitOps.Changelog do
["## ", current_version, " ", date]
end

new_contents =
new_message =
IO.iodata_to_binary([
String.trim(head),
"\n\n<!-- changelog -->\n\n",
version_header,
"\n",
breaking_changes_contents,
"\n\n",
contents_to_insert,
contents_to_insert
])

new_contents =
IO.iodata_to_binary([
String.trim(head),
"\n\n<!-- changelog -->\n\n",
new_message,
rest
])

unless opts[:dry_run] do
File.write!(path, new_contents)
end

String.trim(original_file_contents, new_contents)
String.trim(new_message)
end

@spec initialize(String.t(), Keyword.t()) :: :ok
Expand Down
12 changes: 6 additions & 6 deletions lib/mix/tasks/git_ops.release.ex
Expand Up @@ -135,11 +135,11 @@ defmodule Mix.Tasks.GitOps.Release do
:ok

opts[:yes] ->
tag(repo, changelog_file, prefixed_new_version)
tag(repo, changelog_file, prefixed_new_version, changelog_changes)
:ok

true ->
confirm_and_tag(repo, changelog_file, prefixed_new_version)
confirm_and_tag(repo, changelog_file, prefixed_new_version, changelog_changes)
:ok
end
end
Expand Down Expand Up @@ -195,23 +195,23 @@ defmodule Mix.Tasks.GitOps.Release do
end
end

defp tag(repo, changelog_file, new_version) do
defp tag(repo, changelog_file, new_version, new_message) do
Git.add!(repo, "#{changelog_file}")
Git.commit!(repo, ["-am", "chore: release version #{new_version}"])
Git.tag!(repo, ["-a", new_version, "-m", "release #{new_version}"])
Git.tag!(repo, ["-a", new_version, "-m", new_message])

Mix.shell().info("Don't forget to push with tags:\n\n git push --follow-tags")
end

defp confirm_and_tag(repo, changelog_file, new_version) do
defp confirm_and_tag(repo, changelog_file, new_version, new_message) do
message = """
Shall we commit and tag?
Instructions will be printed for committing and tagging if you choose no.
"""

if Mix.shell().yes?(message) do
tag(repo, changelog_file, new_version)
tag(repo, changelog_file, new_version, new_message)
else
Mix.shell().info("""
If you want to do it on your own, make sure you tag the release with:
Expand Down

0 comments on commit 500d926

Please sign in to comment.