Something went wrong. Try again.
forked from cz-nic/bird
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283#!/bin/bash
set -e
toplevel=$(readlink -f $(dirname $0)/..)current_version=$(<$toplevel/VERSION)
pushd $toplevel > /dev/null
# Enforce clean repository (we are going to commit!)if [ $(git status --porcelain -uno | wc -l) != "0" ]; then echo "Dirty repository, commit or stash!" exit 1fi
# Enforce no fixups and no WIPstools/git-check-commits
# Compute the new versioncase $1 in patch) new_version=$(awk -F. 'OFS="." { $3+=1; print; }' <<<"$current_version") ;; minor) new_version=$(awk -F. 'OFS="." { $2+=1; print $1,$2,0; }' <<<"$current_version") ;; *) echo "Usage: $0 (minor|patch)" echo "Commits the version update commit" exit 2esac
file=$(mktemp)news=$(mktemp)function cleanup() { rm -f $file $news}trap cleanup EXIT ERR
# Prepare the NEWS fileecho "## Releasing version $new_version ##" >> $fileecho -n "########################" >> $filesed 's/./#/g' <<<"$new_version" >> $fileecho >> $filenews_headline="Version $new_version ($(date +%F))"echo $news_headline >> $filegit log --oneline v$current_version..HEAD | sed -r 's/^([^ ]+) (.*)/# commit \1\n o \2/' >> $fileecho >> $fileecho "# Empty the file to cancel the commit." >> $fileecho "# Do not change the Version header." >> $file
# Edit the NEWS file$(git var GIT_EDITOR) $file
# Collect the resultif ! egrep -v '^(#.*)?$' $file > $news; then echo "Release canceled" exit 1fi
# Check whether the result is correctif [ "$news_headline" != "$(head -n1 $news)" ]; then echo "Garbled headline, got $(head -n1 $news)" exit 1fi
badlines=$(tail -n+2 $news | grep -v '^ [o ] ' | wc -l)if [ "$badlines" != 0 ]; then echo "Garbled news file, offending lines:" tail -n+2 $news | grep -v '^ [o ] ' exit 1fi
# Do the changes in the repository: NEWS and VERSIONecho >> $newscat NEWS >> $newsmv $news NEWS
echo $new_version > VERSION
# Commit!git commit -m "NEWS and version update" -- NEWS VERSION