From 4023be9befcbc6670c1ff4e32ec8f1fc4a9e267f Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sat, 10 Sep 2022 00:56:38 +0800 Subject: [PATCH] chore: simplify the release tool Tagging on the`master` or `patch` branch --- tools/release.sh | 49 ++++++++---------------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/tools/release.sh b/tools/release.sh index 762cae7..d812b67 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -140,37 +140,6 @@ resume_config() { mv _config.yml.bak _config.yml } -# auto-generate a new version number to the file 'package.json' -standard_version() { - if $opt_pre; then - standard-version --prerelease rc - else - standard-version - fi -} - -# Prevent changelogs generated on master branch from having duplicate content -# (the another bug of `standard-version`) -standard_version_plus() { - temp_branch="prod-mirror" - temp_dir="$(mktemp -d)" - - git checkout -b "$temp_branch" "$PROD_BRANCH" - git merge --no-ff --no-edit "$STAGING_BRANCH" - - standard_version - - cp package.json CHANGELOG.md "$temp_dir" - - git checkout "$STAGING_BRANCH" - git reset --hard HEAD # undo the changes from $temp_branch - mv "$temp_dir"/* . # rewrite the changelog - - # clean up the temp stuff - rm -rf "$temp_dir" - git branch -D "$temp_branch" -} - # build a gem package build_gem() { echo -e "Build the gem package for v$_version\n" @@ -184,13 +153,13 @@ build_gem() { release() { _version="$1" # X.Y.Z - git checkout "$PROD_BRANCH" - git merge --no-ff --no-edit "$working_branch" - - # Create a new tag on production branch + # Create a new tag on working branch echo -e "Create tag v$_version\n" git tag "v$_version" + git checkout "$PROD_BRANCH" + git merge --no-ff --no-edit "$working_branch" + # merge from patch branch to the staging branch # NOTE: This may break due to merge conflicts, so it may need to be resolved manually. if [[ $working_branch == hotfix/* ]]; then @@ -203,15 +172,13 @@ release() { main() { check - if [[ "$working_branch" == "$STAGING_BRANCH" ]]; then - standard_version_plus + # auto-generate a new version number to the file 'package.json' + if $opt_pre; then + standard-version --prerelease rc else - standard_version + standard-version fi - # Change heading of Patch version to level 2 (a bug from `standard-version`) - sed -i "s/^### \[/## \[/g" CHANGELOG.md - _version="$(grep '"version":' package.json | sed 's/.*: "//;s/".*//')" echo -e "Bump version number to $_version\n"