Skip to content

Commit

Permalink
changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
hds committed Sep 22, 2023
1 parent 24ea477 commit 184b611
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
42 changes: 30 additions & 12 deletions bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ USAGE:
$(basename "$0") [FLAGS] <CRATE> <VERSION>
FLAGS:
-h, --help Show this help text and exit.
-v, --verbose Enable verbose output.
-d, --dry-run Do not change any files or commit a git tag.
--publish-dry-run
Perform a dry run on the publish step only."
-h, --help Show this help text and exit.
-v, --verbose Enable verbose output.
-d, --dry-run Do not change any files or commit a git tag.
--publish-dry-run Perform a dry run on the publish step only."

set -euo pipefail

Expand Down Expand Up @@ -118,9 +117,10 @@ commit() {
fi

# Prepare a commit message including the changelog from just this release.
tmp_changelog_path="tmp-changelog"
tmp_commit_msg_path="tmp-commit-msg"
"$bindir/update-changelog.sh" --unreleased --changelog-path tmp-changelog "$crate" "$crate-v$version"
tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
tmp_changelog_path="$tmp_dir/tmp-changelog"
tmp_commit_msg_path="$tmp_dir/tmp-commit-msg"
"$bindir/update-changelog.sh" --unreleased --changelog-path "$tmp_changelog_path" "$crate" "$crate-v$version"
(echo -e "chore($slug): prepare to release $crate $version\n" && cat $tmp_changelog_path | grep -v "generated by git-cliff") > $tmp_commit_msg_path

git_commit=(git commit -sS -F $tmp_commit_msg_path)
Expand All @@ -132,11 +132,8 @@ commit() {
if [[ "$dry_run" ]]; then
echo ""
echo "# " "${git_commit[@]}"
echo "# Clean up"
echo "# " "rm $tmp_changelog_path $tmp_commit_msg_path"
else
"${git_commit[@]}"
rm $tmp_changelog_path $tmp_commit_msg_path
fi
}

Expand Down Expand Up @@ -174,7 +171,20 @@ publish() {
echo "# " "${git_push_tags[@]}"
else
"${git_tag[@]}"
#"${git_push_tags[@]}"
fi
}

push() {
status "Pushing" "release commit and tag $tag"
local git_push=(git push -u origin)
local git_push_tag=(git push origin "$tag")

if [[ "$dry_run" ]]; then
echo "# " "${git_push[@]}"
echo "# " "${git_push_tag[@]}"
else
"${git_push[@]}"
"${git_push_tag[@]}"
fi
}

Expand Down Expand Up @@ -323,3 +333,11 @@ else
echo "okay, exiting"
exit 1
fi

if confirm "push release commit and tag?"; then
echo ""
push
else
echo "okay, exiting"
exit 1
fi
11 changes: 5 additions & 6 deletions bin/update-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ USAGE:
$(basename "$0") [FLAGS] <CRATE_PATH> <TAG>
FLAGS:
-h, --help Show this help text and exit.
-v, --verbose Enable verbose output.
-u, --unreleased Only add unreleased changes to changelog
--changelog-path <FILE_PATH>
Write the changelog to this path.
default: <CRATE_PATH>/CHANGELOG.md"
-h, --help Show this help text and exit.
-v, --verbose Enable verbose output.
-u, --unreleased Only add unreleased changes to changelog
--changelog-path <FILE_PATH> Write the changelog to this path.
default: <CRATE_PATH>/CHANGELOG.md"

set -euo pipefail

Expand Down
10 changes: 0 additions & 10 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ filter_unconventional = true
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
# Fixes for specific commit messages that we wish we'd committed differently
{ pattern = """^bump tonic\\/prost dependencies and MSRV to 1.64 \\(#464\\)\\s+
(.+\\s+.+)""", replace = """feat(api): update `tonic` to v0.10 and increase MSRV to 1.64 (#464)
BREAKING CHANGE:
This is a breaking change for users of `console-api` and `console-subscriber`,
as it changes the public `tonic` dependency to a semver-incompatible version.
This breaks compatibility with `tonic` 0.9. and `prost` 0.11.""" },

# General fixes and replacements
{ pattern = '^(feat|fix|doc|perf)\((api|subscriber|console)\) ', replace = '${1}(${2}): '}, # fix missing colon after commit type
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/tokio-rs/console/issues/${2}))"}, # replace issue numbers
]
Expand Down

0 comments on commit 184b611

Please sign in to comment.