Tamarin/hooks/00-create-changelog-prebuild

86 lines
2.4 KiB
Plaintext
Raw Normal View History

2015-08-04 23:58:43 +02:00
#!/usr/bin/env bash
source "${TAMARIN_UTIL}"
if [ -f debian/changelog ] || [ ! -d .git ]; then
info "Not a Git repository or Debian changelog already exists !"
exit
fi
# Get commits log as changelog
2015-08-20 17:35:43 +02:00
BUILD_BRANCH=$(get_opt build_branch dist/ubuntu/precise/master)
BUILD_TAG=$(get_opt build_tag "last")
echo "BUILD TAG IS ${BUILD_TAG}"
if [[ ${BUILD_TAG} == "last" ]]
then
git checkout ${BUILD_BRANCH}
tags=$(git tag master -l "release/*"|sort -r)
else
info "DEBUG DEBUG DEBUG "
tagbranch="build-tag-${BUILD_TAG}"
2015-09-23 17:42:08 +02:00
git checkout -b ${tagbranch}
2015-08-20 17:35:43 +02:00
set_opt "tag_branch" "${tag_branch}"
2015-09-23 21:21:30 +02:00
local tags="${BUILD_TAG}"
2015-08-20 17:35:43 +02:00
fi
2015-08-04 23:58:43 +02:00
if [[ -z ${tags} ]]
then
error "No relase tag found, you repo must have a tag like 'release/X.X'"
exit 2
fi
touch debian/changelog
for tag in ${tags}
do
logs=$(git log --pretty=format:"%an - %h : %s" ${tag} | sed 's/"/\\"/g')
# Set the top commiter as the maintainer of the project if not defined
top_contributor=$(git log --pretty=short | git shortlog -s -n -e | sed 's/^\s*[0-9]*\s*//g' | head -n 1)
maintainer=$(get_opt maintainer "${top_contributor}")
2015-08-04 23:58:43 +02:00
project_name=$(get_opt project_name)
version=${tag#*/} #$(get_opt version 0.0.0)
version=${version/_/-} #$(get_opt version 0.0.0)
2015-09-23 21:21:30 +02:00
distribution=$(get_opt distribution UNRELEASED)
urgency=$(get_opt urgency low)
2015-08-04 23:58:43 +02:00
commit_count=$(git rev-list --count --first-parent HEAD)
current_commit=$(git log -n 1 --pretty=format:"%h")
2015-09-23 21:21:30 +02:00
version_suffix=tamarin${commit_count}~${current_commit}
package_version=${version}-${version_suffix}
# Define package_version opt if not defined
if [ -z "$(get_opt package_version)" ]; then
# Share computed package version
set_opt package_version "${package_version}"
fi
# Define project_version opt if not defined
if [ -z "$(get_opt project_version)" ]; then
# Share computed package version
set_opt project_version "${version}"
fi
# Native packages should not have a revision number
if [ $(get_opt package_format) == 'native' ]; then
package_version=$(echo ${version} | grep -oE '^[0-9.]+')
fi
2015-09-23 17:42:08 +02:00
echo "${project_name} (${package_version}) ${distribution}; urgency=${urgency}" >> debian/changelog
2015-08-04 23:58:43 +02:00
echo >> debian/changelog
2015-08-04 23:58:43 +02:00
while read -r entry; do
2015-08-04 23:58:43 +02:00
echo " * ${entry}" >> debian/changelog
done <<< "$(echo -e "${logs}" | sed 's/^"//')"
2015-08-04 23:58:43 +02:00
echo >> debian/changelog
2015-08-04 23:58:43 +02:00
echo " -- ${maintainer} $(date -R)" >> debian/changelog
echo >> debian/changelog
done