PowerDNS/pdns — pull request #756 by zeha (2013-04-29 23:07:23+00:00)
Title: rework automatic build versioning

Very tentative, and I assumed a few things along the way.

Versions for master and feature branches are really TBD, but how you like them is something you need to figure out.

I think the deb and rpm versions should work, the deb versions should also compare properly.

Examples
--------------

On feature branch:
```
% BUILD_NUMBER=4666 GIT_BRANCH=foo/bar GIT_COMMIT=11be5cb5af5437af2783ea5041dbd298c1f941ff ./build-scripts/make-jenkins-version
SOURCE_VERSION=git-foo-bar-20130430-4666-11be5cb
DEB_VERSION=0.0~foo.bar.20130430.4666.11be5cb
RPM_VERSION=0.0.foo_bar_20130430_4666_11be5cb
```

On master:
```
% BUILD_NUMBER=4666 GIT_BRANCH=master GIT_COMMIT=11be5cb5af5437af2783ea5041dbd298c1f941ff ./build-scripts/make-jenkins-version
SOURCE_VERSION=git-20130430-4666-11be5cb
DEB_VERSION=0.0.20130430.4666.11be5cb
RPM_VERSION=0.0.20130430_4666_11be5cb
```

On rel/rec-3.5.1:
```
% BUILD_NUMBER=4666 GIT_BRANCH=rel/rec-3.5.1 GIT_COMMIT=11be5cb5af5437af2783ea5041dbd298c1f941ff ./build-scripts/make-jenkins-version
SOURCE_VERSION=3.5.1-snapshot-20130430-4666-11be5cb
DEB_VERSION=3.5.1~snapshot20130430.4666.11be5cb
RPM_VERSION=3.5.1.snapshot20130430_4666_11be5cb
```

On rel/rec-3.5.1 with an rc tag:
```
git tag -m 'rc release' rec-3.5.1-rc2
% BUILD_NUMBER=4666 GIT_BRANCH=rel/rec-3.5.1 GIT_COMMIT=11be5cb5af5437af2783ea5041dbd298c1f941ff ./build-scripts/make-jenkins-version
SOURCE_VERSION=3.5.1-rc2
DEB_VERSION=3.5.1-rc2
RPM_VERSION=3.5.1-rc2
```

On rel/rec-3.5.1 with the final release tag:
```
% git tag -m 'release' rec-3.5.1
% BUILD_NUMBER=4666 GIT_BRANCH=rel/rec-3.5.1 GIT_COMMIT=11be5cb5af5437af2783ea5041dbd298c1f941ff ./build-scripts/make-jenkins-version
SOURCE_VERSION=3.5.1
DEB_VERSION=3.5.1
RPM_VERSION=3.5.1
```