2019-04-01 16:24:05 +00:00
|
|
|
#!/bin/bash
|
2019-03-28 15:51:33 +00:00
|
|
|
#
|
2021-01-23 08:21:28 +00:00
|
|
|
#### $$VERSION$$ v1.32-dev-9-g13052f0
|
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
|
|
|
|
2021-01-15 13:23:19 +00:00
|
|
|
#shellcheck disable=SC1090
|
|
|
|
source "${0%/*}/dev.inc.sh"
|
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)"
|
2021-01-01 10:27:54 +00:00
|
|
|
printf "Update to version %s ...\n" "${VERSION}"
|
2019-03-28 15:51:33 +00:00
|
|
|
|
2021-01-22 07:34:37 +00:00
|
|
|
# only regular files, ignore .dot files/dirs, e.g. .git .gitinore in BASEDIR
|
|
|
|
FILES="$(find ./* -type f)"
|
2019-04-12 15:18:20 +00:00
|
|
|
[ "$1" != "" ] && FILES="$*"
|
|
|
|
|
2021-01-07 08:40:57 +00:00
|
|
|
# autogenerate REMADME.html REMADE.txt
|
|
|
|
if [[ "${FILES}" == *"README.md"* ]]; then
|
|
|
|
FILES+=" README.html README.txt"
|
|
|
|
type -f pandoc >/dev/null && pandoc -s -f commonmark -M "title=Bashbot README" README.md >README.html
|
2021-01-09 21:25:15 +00:00
|
|
|
cat "doc/bashbot.ascii" >"README.txt"
|
2021-01-08 21:32:05 +00:00
|
|
|
if [ -r "README.html" ] && type -f html2text >/dev/null; then
|
2021-01-08 14:52:07 +00:00
|
|
|
# convert html links to text [link]
|
2021-01-23 08:21:28 +00:00
|
|
|
sed -E 's/<a href="([^>]+)">([^<#]+)<\/a>/\2 [\1]/g' <README.html |\
|
2021-01-08 21:12:03 +00:00
|
|
|
html2text -style pretty -width 90 - >>README.txt
|
2021-01-07 08:40:57 +00:00
|
|
|
else
|
2021-01-08 21:12:03 +00:00
|
|
|
type -f fold >/dev/null && fold -s -w 90 README.md >>README.txt
|
2021-01-07 08:40:57 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# change version string in given files
|
2021-01-05 10:40:28 +00:00
|
|
|
for file in ${FILES}
|
2019-03-28 15:51:33 +00:00
|
|
|
do
|
2021-01-22 07:51:28 +00:00
|
|
|
# symlink is a file :-(
|
|
|
|
[[ -L "${file}" || ! -f "${file}" ]] && continue
|
2021-01-01 10:27:54 +00:00
|
|
|
#[ "${file}" == "version" ] && continue
|
|
|
|
printf "%s" " ${file}" >&2
|
|
|
|
sed -i 's/^#### $$VERSION$$.*/#### \$\$VERSION\$\$ '"${VERSION}"'/' "${file}"
|
2019-03-28 15:51:33 +00:00
|
|
|
done
|
2021-01-07 08:40:57 +00:00
|
|
|
|
2021-01-01 10:27:54 +00:00
|
|
|
printf " done.\n"
|
2019-03-28 15:51:33 +00:00
|
|
|
|