Version number moved to a separate file as a primary source of truth.
Added tools/release-commit to make the release process a little bit faster.
Fixes #218
exedir := @exedir@
# Find out which version we are actually building
+# This is rewritten by the release tools by hardcoded version
VERSION := $(strip $(shell bash $(srcdir)/tools/version))
+
CFLAGS += -DBIRD_VERSION='"$(VERSION)"'
ifeq ($(objdir),.)
$(srcdir)/tools/progdoc $(srcdir) $@
$(o)%.sgml: $(s)%.sgml $(objdir)/.dir-stamp
- cp $< $@
+ sed 's#{{ VERSION }}#$(VERSION)#' <$< >$@
$(o)%.html: $(o)%.sgml
cd $(dir $@) && $(toolsdir)/linuxdoc -B html $(notdir $<)
ifeq ($(PANDOC),)
-$(o)%.md: $(s)%.sgml
+$(o)%.md: $(o)%.sgml
@echo "ERROR: No pandoc available, install pandoc to build documentation"
@false
else
LINUXDOC_PANDOC_PARSER := $(srcdir)/tools/linuxdoc.lua
-$(o)%.md: $(s)%.sgml $(LINUXDOC_PANDOC_PARSER) $(objdir)/.dir-stamp
+$(o)%.md: $(o)%.sgml $(LINUXDOC_PANDOC_PARSER) $(objdir)/.dir-stamp
$(PANDOC) -f $(LINUXDOC_PANDOC_PARSER) -s -t markdown -o $@ $<
$(o)%-singlepage.html: $(o)%.md
<!doctype birddoc system>
<!--
- BIRD 2.17 documentation
+ BIRD documentation
This documentation can have 4 forms: sgml (this is master copy), html, ASCII
text and dvi/postscript (generated from sgml using sgmltools). You should always
<book>
-<title>BIRD 2.17 User's Guide
+<title>BIRD {{ VERSION }} User's Guide
<author>
Ondrej Filip <it/<feela@network.cz>/,
Martin Mares <it/<mj@ucw.cz>/,
#
#VERSION=`grep 'BIRD_VERSION \"' sysdep/config.h | sed '/BIRD_VERSION/!d;s/^.*"\(.*\)"$/\1/'`
-VERSION=`tools/version | sed 's/^v//'`
+VERSION=`tools/version`
REL=bird-$VERSION
DREL=bird-doc-$VERSION
T=/tmp/bird
pushd $SRCPKG
# Omit historical documents
- rm -rf misc rfc doc/slides doc/slt2001 doc/old bird.conf
+ rm -rf rfc doc/slides doc/slt2001 doc/old bird.conf
# Fix the version string
sed -i 's/^VERSION := .*/VERSION := '${VERSION}'/' Makefile.in
--- /dev/null
+#!/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 1
+fi
+
+# Enforce no fixups and no WIPs
+tools/git-check-commits
+
+# Compute the new version
+case $1 in
+ patch)
+ new_version=$(awk -F. 'OFS="." { $3+=1; print; }' <<<"$current_version")
+ ;;
+ minor)
+ new_version=$(awk -F. 'OFS="." { $2+=1; if ($1 < 3) print $1,$2; else print $1,$2,0; }' <<<"$current_version")
+ ;;
+ *)
+ echo "Usage: $0 (minor|patch)"
+ echo "Commits the version update commit"
+ exit 2
+esac
+
+file=$(mktemp)
+news=$(mktemp)
+function cleanup() {
+ rm -f $file $news
+}
+trap cleanup EXIT ERR
+
+# Prepare the NEWS file
+echo "## Releasing version $new_version ##" >> $file
+echo -n "########################" >> $file
+sed 's/./#/g' <<<"$new_version" >> $file
+echo >> $file
+news_headline="Version $new_version ($(date +%F))"
+echo $news_headline >> $file
+git log --oneline v$current_version..HEAD | sed -r 's/^([^ ]+) (.*)/# commit \1\n o \2/' >> $file
+echo >> $file
+echo "# Empty the file to cancel the commit." >> $file
+echo "# Do not change the Version header." >> $file
+
+# Edit the NEWS file
+$(git var GIT_EDITOR) $file
+
+# Collect the result
+if ! egrep -v '^(#.*)?$' $file > $news; then
+ echo "Release canceled"
+ exit 1
+fi
+
+# Check whether the result is correct
+if [ "$news_headline" != "$(head -n1 $news)" ]; then
+ echo "Garbled headline, got $(head -n1 $news)"
+ exit 1
+fi
+
+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 1
+fi
+
+# Do the changes in the repository: NEWS, bird.spec and VERSION
+echo >> $news
+cat NEWS >> $news
+mv $news NEWS
+
+sed -i "s/^Version: $current_version\$/Version: $new_version/" misc/bird.spec
+
+echo $new_version > VERSION
+
+# Commit!
+git commit -m "NEWS and version update" -- NEWS VERSION misc/bird.spec
-#!/bin/bash
+#!/bin/sh
-# Aren't we directly at version?
-TAG=$(git tag | grep -F $(git describe))
-if [ -n "$TAG" ]; then
- echo $TAG
+set -e
+
+# Get the release version
+toplevel="$(readlink -f $(dirname $0)/../)"
+RELEASE_VERSION=$(cat "$toplevel/VERSION")
+
+# Not in a git repo, or no git installed.
+if ! git status --porcelain > /dev/null; then
+ echo $RELEASE_VERSION
+ exit 0
+fi
+
+# Check VERSION file updates in uncommitted changes
+if git status --porcelain | grep -q '^...VERSION$'; then
+ echo "WARNING: Version file changed and not committed" >&2
+ echo $RELEASE_VERSION
exit 0
fi
-# Get version tag
-# Uses 'git log ...' insted of 'git tag --merged' to support older distros
-TAG=$(git log --oneline --pretty=format:"%d" \
- | grep -Eo '^ \(tag:\ v[[:digit:]]+.*(,|\))' \
- | head -n 1 \
- | sed -n 's/^ (tag:\ v//p' | sed -n 's/\(,.*\|)\)//p')
+# If clean, check VERSION file updates in the current commit
+if [ $(git status --porcelain -uno | wc -l) = "0" ] && [ $(git show -- VERSION | wc -l) != "0" ]; then
+ echo $RELEASE_VERSION
+ exit 0
+fi
+# We'll create a development version number, get the hash
HASH=$(git rev-parse --short=12 HEAD)
+# Find the release
+case "$(git tag -l | grep "^v$RELEASE_VERSION\$" | wc -l | sed -r 's/^ *//;s/ +-//')" in
+ "1") # Already tagged
+ RELEASE_COMMIT=v$RELEASE_VERSION
+ ;;
+ "0") # Not yet tagged
+ RELEASE_COMMIT=$(git log --oneline -- VERSION | sed 's/ .*//')
+ ;;
+ *)
+ echo "ERROR: There are too many matching tags in the repository"
+ git tag -l | grep "^v$RELEASE_VERSION\$"
+ git tag -l | grep "^v$RELEASE_VERSION\$" | wc -l
+ exit 1
+ ;;
+esac
+
# Add branch info if not passed via command line
if [ -z "${BRANCH}" ]; then
# There is also --show-current but it's too new to be portable.
# Found a branch
if [ -n "$BRANCH" ]; then
- LENGTH=$(git log --oneline v$TAG..HEAD | wc -l)
- echo $TAG+branch.$(echo $BRANCH | sed 's/[^a-zA-Z0-9]/./g').${HASH}
+ LENGTH=$(git log --oneline $RELEASE_COMMIT..HEAD | wc -l)
+ echo $RELEASE_VERSION+branch.$(echo $BRANCH | sed 's/[^a-zA-Z0-9]/./g').${HASH}
exit 0
fi
-echo $TAG+detached.${HASH}
+echo $RELEASE_VERSION+detached.${HASH}
exit 0