1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #!/bin/bash
-
- __make_ver() {
- local level=$1
- local old=$2
- local oldx=${old%.*.*}
- local oldz=${old#*.*.}
- local tmpy=${old%.*}
- local oldy=${tmpy#*.}
- case $level in
- x) new="$((oldx+1)).0.0" ;;
- y) new="$oldx.$((oldy+1)).0" ;;
- z) new="$oldx.$oldy.$((oldz+1))" ;;
- *) die "invalid release level: $1" ;;
- esac
- echo $new
- }
-
- __release() {
- #
- # Prepare release
- #
- # Span release routines: make a signed tag, check branch
- # and update release branch
- #
- local level=$1
- git rev-parse HEAD >&/dev/null || die "cannot release outside git repo"
- local lastfile=$(git diff-tree --no-commit-id --name-only -r HEAD)
- local lasttag=$(git tag | grep ^v | sort -V | tail -n1)
- local changelog="$(git log --oneline $lasttag..HEAD)"
- local curbranch=$(git rev-parse --abbrev-ref HEAD)
- local dirt="$(git diff --shortstat 2>/dev/null)"
-
- local newver=$(__make_ver $level ${lasttag#v})
- local newtag=v$newver
- local higher=$(echo -e "$oldtag\n$newtag" | sort -V | tail -n1)
- test "$newtag" = "$higher" || die "generated tag looks older: $oldtag<$newtag"
-
- grep -qw "$newver" config.mk || die "new version not in config.mk: $newver"
- test -n "$lasttag" || die "cannot find last tag"
- grep '^....... WIP ' <<<"$changelog" && die "WIP commit since $lasttag"
- grep -qw "$curbranch" <<<"$RELSRC" || die "you are not on RELSRC branch: $RELSRC"
- test -z "$dirt" || die "tree is dirty: $dirt"
-
- # FIXME: Have user prepare proper message with changelog
-
- set -e
- git tag -m "$MKIT_PROJNAME $newtag-$STAGE - $CODENAME" $newtag
- git branch -f $RELDST $newtag
- }
-
- release_x() {
- __release x
- }
-
- release_y() {
- __release y
- }
-
- release_z() {
- __release z
- }
|