add option to control branching and tagging

This commit is contained in:
Conduitry 2018-12-11 10:27:00 -05:00
parent 3c1dc99d61
commit af0f8c2da8
1 changed files with 7 additions and 2 deletions

View File

@ -2,6 +2,10 @@
# git ready # git ready
set -e set -e
C=; O=; S=; case "$1" in c) C=1 ;; cs) C=1; S=1 ;; o) O=1 ;; os) O=1; S=1 ;; *) echo "Usage: $0 c | cs | o | os
c = tag release as child of HEAD
o = tag release as orphan
s = tag HEAD as vX.X.X-src"; exit 1 ;; esac
cd "$(git rev-parse --show-toplevel)" cd "$(git rev-parse --show-toplevel)"
ORIG_HEAD="$(git symbolic-ref HEAD)" ORIG_HEAD="$(git symbolic-ref HEAD)"
ORIG_COMMIT="$(git rev-parse HEAD)" ORIG_COMMIT="$(git rev-parse HEAD)"
@ -21,7 +25,8 @@ PKG_VERSION="$(node -e '
# create new temporary branch # create new temporary branch
TEMP_BRANCH="NPM2GIT-$PKG_VERSION-$(date +%Y%m%d%H%M%S)" TEMP_BRANCH="NPM2GIT-$PKG_VERSION-$(date +%Y%m%d%H%M%S)"
git checkout --orphan="$TEMP_BRANCH" [ $C ] && git checkout -b "$TEMP_BRANCH"
[ $O ] && git checkout --orphan "$TEMP_BRANCH"
git rm --cached -rf . git rm --cached -rf .
# commit the files that should be included in the published package # commit the files that should be included in the published package
@ -36,7 +41,7 @@ git symbolic-ref HEAD "$ORIG_HEAD"
git reset git reset
# tag commit # tag commit
git tag "v$PKG_VERSION-src" [ $S ] && git tag "v$PKG_VERSION-src"
git tag "v$PKG_VERSION" "$TEMP_BRANCH" -am "v$PKG_VERSION @ $ORIG_COMMIT" git tag "v$PKG_VERSION" "$TEMP_BRANCH" -am "v$PKG_VERSION @ $ORIG_COMMIT"
# delete temporary branch # delete temporary branch