2019-04-01 16:24:05 +00:00
|
|
|
#!/bin/bash
|
2019-03-28 15:51:33 +00:00
|
|
|
#
|
2020-11-30 17:38:19 +00:00
|
|
|
#### $$VERSION$$ v1.2-0-gc50499c
|
2019-04-01 16:24:05 +00:00
|
|
|
# shellcheck disable=SC2016
|
2019-03-29 16:52:00 +00:00
|
|
|
#
|
2019-03-28 15:51:33 +00:00
|
|
|
# Easy Versioning in git:
|
|
|
|
#
|
|
|
|
# for setting your Version in git use e.g.:
|
|
|
|
# git tag -a v0.5 -m 'Version 0.5'
|
|
|
|
#
|
|
|
|
# Push tags upstream—this is not done by default:
|
|
|
|
# git push --tags
|
|
|
|
#
|
|
|
|
# # in case of a wrong tag remove it:
|
|
|
|
# git tag -d v0.5
|
|
|
|
#
|
|
|
|
# delete remote tag (eg, GitHub version)
|
|
|
|
# git push origin :refs/tags/v0.5
|
|
|
|
#
|
|
|
|
# Then use the describe command:
|
|
|
|
#
|
|
|
|
# git describe --tags --long
|
|
|
|
# This gives you a string of the format:
|
|
|
|
#
|
|
|
|
# v0.5-0-gdeadbee
|
|
|
|
# ^ ^ ^^
|
|
|
|
# | | ||
|
|
|
|
# | | |'-- SHA of HEAD (first seven chars)
|
|
|
|
# | | '-- "g" is for git
|
|
|
|
# | '---- number of commits since last tag
|
|
|
|
# |
|
|
|
|
# '--------- last tag
|
|
|
|
#
|
|
|
|
# run this script to (re)place Version number in files
|
|
|
|
#
|
2019-03-29 16:52:00 +00:00
|
|
|
|
2019-04-19 08:43:06 +00:00
|
|
|
# magic to ensure that we're always inside the root of our application,
|
|
|
|
# no matter from which directory we'll run script
|
2019-05-11 10:07:06 +00:00
|
|
|
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
|
|
|
if [ "$GIT_DIR" != "" ] ; then
|
|
|
|
cd "$GIT_DIR/.." || exit 1
|
|
|
|
else
|
|
|
|
echo "Sorry, no git repository $(pwd)" && exit 1
|
|
|
|
fi
|
2019-04-19 08:43:06 +00:00
|
|
|
|
2019-03-29 16:52:00 +00:00
|
|
|
unset IFS
|
|
|
|
# set -f # if you are paranoid use set -f to disable globbing
|
2019-03-28 15:51:33 +00:00
|
|
|
|
2019-04-01 16:24:05 +00:00
|
|
|
VERSION="$(git describe --tags --long)"
|
2019-04-19 08:43:06 +00:00
|
|
|
echo "Update to version $VERSION ..."
|
2019-03-28 15:51:33 +00:00
|
|
|
|
2019-04-19 15:31:01 +00:00
|
|
|
FILES="$(find ./*)"
|
2019-04-12 15:18:20 +00:00
|
|
|
[ "$1" != "" ] && FILES="$*"
|
|
|
|
|
|
|
|
for file in $FILES
|
2019-03-28 15:51:33 +00:00
|
|
|
do
|
|
|
|
[ ! -f "$file" ] && continue
|
|
|
|
#[ "$file" == "version" ] && continue
|
2019-04-19 08:43:06 +00:00
|
|
|
echo -n " $file" >&2
|
2019-04-01 16:24:05 +00:00
|
|
|
sed -i 's/^#### $$VERSION$$.*/#### \$\$VERSION\$\$ '"$VERSION"'/' "$file"
|
2019-03-28 15:51:33 +00:00
|
|
|
done
|
2019-04-11 08:09:29 +00:00
|
|
|
# try to compile README.txt
|
2019-04-19 08:43:06 +00:00
|
|
|
echo -n " README.txt" >&2
|
2019-12-07 12:59:54 +00:00
|
|
|
type -f pandoc >/dev/null && pandoc -s -f commonmark -M "title=Bashbot README" README.md >README.html
|
2019-04-28 07:54:51 +00:00
|
|
|
fold -s README.md >README.txt
|
2019-03-28 15:51:33 +00:00
|
|
|
echo " done."
|
|
|
|
|