#!/usr/bin/env bash
# Extract lastest release tag from git log
Last_Release=$(git describe | cut -d '-' -f 1)
# Bump version in I-Nex.gambas
sed -i -e 's|^Version.*|Version='$1'|' ./I-Nex/i-nex/.project
sed -i -e 's|^PackageName=i-nex-.*|PackageName=i-nex-'$1'|' ./I-Nex/i-nex/.project
# Update changelog based on git log.
git log $Last_Release..HEAD > changelogs/changelog-$1

cat > ./debian/changelog2 <<EOF
i-nex ($1) stable; urgency=medium

  * Chengelog for version $1 see file /usr/share/doc/i-nex/changelog-$1

 -- eloaders <eloaders@linux.pl>  `date -R`

EOF

cat ./debian/changelog >> ./debian/changelog2
rm ./debian/changelog
mv ./debian/changelog2 ./debian/changelog
