Enhance versioning tools
This commit is contained in:
parent
4986db1204
commit
5f31fbcf72
2 changed files with 60 additions and 25 deletions
|
@ -85,23 +85,22 @@ main() {
|
||||||
|
|
||||||
echo "Input a version number (hint: latest version is ${_latest_tag:1})"
|
echo "Input a version number (hint: latest version is ${_latest_tag:1})"
|
||||||
|
|
||||||
read _version
|
read -p "> " _version
|
||||||
|
|
||||||
if [[ $_version =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]$ ]]; then
|
[[ $_version =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]$ ]] ||
|
||||||
|
(
|
||||||
|
echo "Error: Illegal version number: '$_version'"
|
||||||
|
exit 1
|
||||||
|
)
|
||||||
|
|
||||||
if git tag --list | egrep -q "^v$_version$"; then
|
if git tag --list | egrep -q "^v$_version$"; then
|
||||||
echo "Error: version '$_version' already exists"
|
echo "Error: version '$_version' already exists"
|
||||||
exit -1
|
exit 1
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "Bump version to $_version\n"
|
|
||||||
bump "$_version"
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
echo "Error: Illegal version number: '$_version'"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -e "Bump version to $_version\n"
|
||||||
|
bump "$_version"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
|
@ -16,6 +16,20 @@ set -eu
|
||||||
|
|
||||||
GEM_SPEC="jekyll-theme-chirpy.gemspec"
|
GEM_SPEC="jekyll-theme-chirpy.gemspec"
|
||||||
|
|
||||||
|
opt_pre=false
|
||||||
|
|
||||||
|
help() {
|
||||||
|
echo "A tool to release new version Chirpy gem"
|
||||||
|
echo
|
||||||
|
echo "Usage:"
|
||||||
|
echo
|
||||||
|
echo " bash ./tools/release.sh [options]"
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " -p, --preview Enable preview mode, only pakcage, and will not modify the branches"
|
||||||
|
echo " -h, --help Print this information."
|
||||||
|
}
|
||||||
|
|
||||||
check() {
|
check() {
|
||||||
if [[ -n $(git status . -s) ]]; then
|
if [[ -n $(git status . -s) ]]; then
|
||||||
echo "Error: Commit unstaged files first, and then run this tool againt."
|
echo "Error: Commit unstaged files first, and then run this tool againt."
|
||||||
|
@ -43,19 +57,22 @@ release() {
|
||||||
_version="$(grep "spec.version" jekyll-theme-chirpy.gemspec | sed 's/.*= "//;s/".*//')" # X.Y.Z
|
_version="$(grep "spec.version" jekyll-theme-chirpy.gemspec | sed 's/.*= "//;s/".*//')" # X.Y.Z
|
||||||
_release_branch="release/${_version%.*}"
|
_release_branch="release/${_version%.*}"
|
||||||
|
|
||||||
if [[ -z $(git branch -v | grep "$_release_branch") ]]; then
|
if [[ $opt_pre = "false" ]]; then
|
||||||
# create a new release branch
|
# Modify the GitLab release branches
|
||||||
git checkout -b "$_release_branch"
|
if [[ -z $(git branch -v | grep "$_release_branch") ]]; then
|
||||||
else
|
# create a new release branch
|
||||||
# cherry-pick the latest commit from default branch to release branch
|
git checkout -b "$_release_branch"
|
||||||
_last_commit="$(git rev-parse "$_default_branch")"
|
else
|
||||||
git checkout "$_release_branch"
|
# cherry-pick the latest commit from default branch to release branch
|
||||||
git cherry-pick "$_last_commit" -m 1
|
_last_commit="$(git rev-parse "$_default_branch")"
|
||||||
fi
|
git checkout "$_release_branch"
|
||||||
|
git cherry-pick "$_last_commit" -m 1
|
||||||
|
fi
|
||||||
|
|
||||||
# create new tag
|
# Create a new tag
|
||||||
echo -e "Create tag v$_version\n"
|
echo -e "Create tag v$_version\n"
|
||||||
git tag "v$_version"
|
git tag "v$_version"
|
||||||
|
fi
|
||||||
|
|
||||||
# build a gem package
|
# build a gem package
|
||||||
echo -e "Build the gem pakcage for v$_version\n"
|
echo -e "Build the gem pakcage for v$_version\n"
|
||||||
|
@ -70,4 +87,23 @@ main() {
|
||||||
release
|
release
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (($#)); do
|
||||||
|
opt="$1"
|
||||||
|
case $opt in
|
||||||
|
-p | --preview)
|
||||||
|
opt_pre=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h | --help)
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# unknown option
|
||||||
|
help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
Loading…
Reference in a new issue