Skip to content

Commit

Permalink
build(release): combine Cargo.toml and changelog into a single commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gibfahn committed Jan 28, 2022
1 parent e83ba8c commit a08c443
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,28 @@ main() {
last_release=$(gh release list -L 1 | awk '{print $1}')
cargo_toml_version=$(awk -F\" '/^version = /{print $2; exit}' Cargo.toml)

# Generate and commit the changelog:
# Bump version in Cargo.toml and changelog:

if [[ $changelog_version != $last_release ]]; then
if [[ $changelog_version != $last_release && $last_release != $cargo_toml_version ]]; then
prompt_to_skip "Last release was $last_release, but changelog updated to $changelog_version. Skipping changelog update..."
new_version=$changelog_version
else
log_section "Updating changelog..."
read "new_version?New version (old version is ${last_release?}): "

# TODO(gib): make this follow (and link to in CHANGELOG.md) https://keepachangelog.com/en/1.0.0/
clog -C CHANGELOG.md --from="${last_release?}" --setversion="${new_version?}"
# Make the header a link pointing to the release.
gsed -i "s/^## ${new_version?} (/## [${new_version?}][] (/" CHANGELOG.md
echo "[${new_version?}]: https://github.com/gibfahn/up-rs/releases/tag/${new_version?}" >>CHANGELOG.md
git add CHANGELOG.md
git commit -m "docs(changelog): update changelog for ${new_version?}"
fi

# Bump version:

version_bump_commit_message="docs(version): bump version to ${new_version?}"
if [[ $last_release != $cargo_toml_version ]]; then
prompt_to_skip "Skipping Cargo.toml update as commit is already present."
else
log_section "Updating Cargo.toml..."
gsed -i -E "0,/^version = \"${last_release?}\"\$/s//version = \"${new_version?}\"/" Cargo.toml
log_and_run cargo check # Bumps version in lockfile too.
git add Cargo.toml Cargo.lock
git commit -m "$version_bump_commit_message"
log_section "Committing version updates..."
git add Cargo.toml Cargo.lock CHANGELOG.md
git commit -m "chore: bump version to ${new_version?}"
git show # Check version is correct.
prompt_to_skip "Does this look correct?"
prompt_to_skip "Does this look correct (should change Cargo.toml, Cargo.lock, CHANGELOG.md)?"
fi

# Build and test Linux (static) and Darwin binaries locally:
Expand Down

0 comments on commit a08c443

Please sign in to comment.