Tamarin/hooks/prebuild/eole/add-package-version-suffix

40 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2020-07-27 14:27:00 +02:00
#!/usr/bin/env bash
cd src
if [ ! -f debian/changelog ]; then
tamarin_info "No changelog. Skipping adding suffix to package version"
2020-07-27 14:27:00 +02:00
exit
fi
if [ $(tamarin_db get no_version_suffix 'no') == 'yes' ]; then
tamarin_info "Not adding version suffix."
exit
fi
tamarin_info "Suffixing package version"
2020-07-27 14:27:00 +02:00
if [ -d .git ]; then
tamarin_info "It seems to be a Git repository. Generating version suffix based on Git history..."
release_tag=$(git describe --match "release/*" --abbrev=0 2>/dev/null)
if [ -z "${release_tag}" ]
then
dev_commit_count=$(git rev-list --count --no-merges develop)
else
dev_commit_count=$(git rev-list --count ${release_tag}..master)
fi
if [ ${dev_commit_count} -gt 0 ]
then
build_level=$(tamarin_db get build_level 'dev')
version_suffix="~$build_level+${dev_commit_count}-$(git log -n1 --format=%h)"
else
version_suffix=''
fi
2020-07-27 14:27:00 +02:00
else
tamarin_info "Not a Git project. Fallback to timestamp for suffix generation..."
version_suffix=tamarin$(date +%Y%m%d%H%M)
fi
tamarin_info "Suffixing package version with $version_suffix"
2020-07-27 14:27:00 +02:00
sed -i "0,/(\(.*\))/s/(\(.*\))/(\1${version_suffix})/" debian/changelog
cp debian/changelog /dist/changelog