diff --git a/scripts/pkg.sh b/scripts/pkg.sh index e3a2cffd..f9064243 100644 --- a/scripts/pkg.sh +++ b/scripts/pkg.sh @@ -85,6 +85,13 @@ write_map() cmd_version -p `platform` $1 write $2 } +release_tags() +{ + # a release of a version on a platform is tagged + # v@ + git tag -l "v*@`platform`" +} + find_path() { local p @@ -177,12 +184,6 @@ increase_build_no() check_next_version() { local v=`read_map $TOPDIR/VERSION | sed 's/-dev//'` - local n=`read_map -n $TOPDIR/RELEASES | sed 's/-dev//'` - if [ "$n" != "$v" ]; then - echo "+ $PKG_PROJECT version is already at $v, no need to increase for release" >&2 - echo $v - return - fi local h=`calculate_hash` [ -n "$h" ] || fatal "failed to calculate source hash" if [ ! -f $TOPDIR/HASH ]; then @@ -190,7 +191,7 @@ check_next_version() echo $v return fi - if ! read_map $TOPDIR/HASH | grep -q $h; then + if ! grep -q $h $TOPDIR/HASH; then echo "+ $PKG_PROJECT has no matching HASH value, needs release" >&2 increase_build_no $v return @@ -274,8 +275,8 @@ check_release_is_current() done shift - if ! read_map -n $TOPDIR/RELEASES | grep -Fq $next; then - echo "next version $next is not in RELEASES, needs release" >&2 + if ! release_tags | grep -qF "v$next@"; then + echo "next version $next is not released on `platform`, needs release" >&2 return 1 fi @@ -293,7 +294,7 @@ check_release_is_current() check_update_version() { - local comment="Start version" + local comment="Release" set -- `getopt 'c:' "$@"` while [ "$1" != -- ] ; do case "$1" in @@ -311,8 +312,19 @@ check_update_version() local next=`check_next_version` [ "$next" ] || fatal "Failed to get next version." if [ "$next" != "$v" ]; then + local h=`calculate_hash` + [ -n "$h" ] || fatal "failed to calculate source hash" + local files="VERSION $TOPDIR/HASH" + # the release tags replace the RELEASES file; the + # release commit drops it from the tree + if [ "$SCM" = git ] && [ -f $TOPDIR/RELEASES ] && \ + git rm -qf $TOPDIR/RELEASES 2>/dev/null; then + files="$files $TOPDIR/RELEASES" + fi echo "$next-dev" > VERSION - scm_commit -m "$comment: $next" VERSION + write_map $TOPDIR/HASH $h + $SCM add $TOPDIR/HASH || true + scm_commit -m "$comment $next" $files return 0 fi return 1 @@ -373,6 +385,7 @@ cmd_version() case $cmd in read) + [ -f "$file" ] || return 0 local p=`echo $platform | sed 's%/%\\\/%g'` local v=`sed "/$p:/ !d; s/$p: *//" $file` [ "$v" ] && { @@ -609,8 +622,6 @@ upload_pkg() set -e local p local v=`read_map $TOPDIR/VERSION | sed 's/-dev//'` - local h=`calculate_hash` - [ -n "$h" ] || fatal "failed to calculate source hash" case $PKG_FORMAT in rpm) server=pkg.janware.com @@ -657,17 +668,12 @@ upload_pkg() ;; esac - write_map $TOPDIR/RELEASES $v - $SCM add $TOPDIR/RELEASES || true - write_map $TOPDIR/HASH $h - $SCM add $TOPDIR/HASH || true echo "+ scheduling rebuild" $SSH -l root $server /opt/packager-server/bin/packager-server schedule-rebuild - scm_commit -m "Release $v@`platform`" $TOPDIR/RELEASES $TOPDIR/HASH - if [ "$SCM" = git ]; then - # Don't use extra options, they might contain -l - JW_PKG_SSH_EXTRA_OPTS="" git push || fatal "Failed to push changes to RELEASES and HASH" - fi + local tag="v$v@`platform`" + git tag -m "Release $v@`platform`" "$tag" || fatal "Failed to tag the release as $tag" + # Don't use extra options, they might contain -l + JW_PKG_SSH_EXTRA_OPTS="" git push origin HEAD "$tag" || fatal "Failed to push the release commit and tag $tag" } install_exe_wrapper() @@ -1297,7 +1303,7 @@ build) cmd_build "$@" ;; release-reinstall) - check_update_version -c "Start version" + check_update_version cmd_build "$@" cmd_upload ;;