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})"
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
@ -16,6 +16,20 @@ set -eu
|
|||
|
||||
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() {
|
||||
if [[ -n $(git status . -s) ]]; then
|
||||
echo "Error: Commit unstaged files first, and then run this tool againt."
|
||||
|
@ -43,6 +57,8 @@ release() {
|
|||
_version="$(grep "spec.version" jekyll-theme-chirpy.gemspec | sed 's/.*= "//;s/".*//')" # X.Y.Z
|
||||
_release_branch="release/${_version%.*}"
|
||||
|
||||
if [[ $opt_pre = "false" ]]; then
|
||||
# Modify the GitLab release branches
|
||||
if [[ -z $(git branch -v | grep "$_release_branch") ]]; then
|
||||
# create a new release branch
|
||||
git checkout -b "$_release_branch"
|
||||
|
@ -53,9 +69,10 @@ release() {
|
|||
git cherry-pick "$_last_commit" -m 1
|
||||
fi
|
||||
|
||||
# create new tag
|
||||
# Create a new tag
|
||||
echo -e "Create tag v$_version\n"
|
||||
git tag "v$_version"
|
||||
fi
|
||||
|
||||
# build a gem package
|
||||
echo -e "Build the gem pakcage for v$_version\n"
|
||||
|
@ -70,4 +87,23 @@ main() {
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue