chore: simplify the release tool

Tagging on the`master` or `patch` branch
This commit is contained in:
Cotes Chung 2022-09-10 00:56:38 +08:00
parent 0dcd39d491
commit 4023be9bef
No known key found for this signature in database
GPG key ID: 0D9E54843167A808

View file

@ -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"