telegram-bot-bash/dev/make-distribution.sh

71 lines
2.2 KiB
Bash
Raw Normal View History

2019-04-22 18:34:43 +00:00
#!/usr/bin/env bash
2019-05-11 10:17:38 +00:00
# file: make-distribution.sh
# creates files and arcchives to dirtribute bashbot
#
2020-06-12 09:11:17 +00:00
#### $$VERSION$$ v0.96-0-g3871ca9
2019-04-22 18:34:43 +00:00
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
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-22 18:34:43 +00:00
2019-04-30 12:21:24 +00:00
VERSION="$(git describe --tags | sed -e 's/-[0-9].*//' -e 's/v//')"
2019-04-22 18:34:43 +00:00
DISTNAME="telegram-bot-bash"
2019-05-26 14:55:02 +00:00
DISTDIR="./DIST/${DISTNAME}"
DISTFILES="bashbot.rc bashbot.sh commands.sh mycommands.sh mycommands.sh.clean doc examples modules addons LICENSE README.md README.txt README.html"
2019-04-22 18:34:43 +00:00
# run tests first!
for test in dev/all-test*.sh
2019-04-22 18:34:43 +00:00
do
[ ! -x "${test}" ] && continue
2019-04-22 18:34:43 +00:00
if ! "${test}" ; then
echo "Test ${test} failed, can't create dist!"
exit 1
fi
done
2019-04-28 08:32:06 +00:00
# create dir for distribution and copy files
2019-04-22 18:34:43 +00:00
mkdir -p "${DISTDIR}" 2>/dev/null
# shellcheck disable=SC2086
cp -r ${DISTFILES} "${DISTDIR}"
cd "${DISTDIR}" || exit 1
2019-05-25 15:02:25 +00:00
# do not overwrite on update
for file in mycommands.sh bashbot.rc addons/*.sh
do
[ "${file}" = "addons/*.sh" ] && continue
mv "${file}" "${file}.dist"
done
2019-04-22 18:34:43 +00:00
2019-05-25 15:02:25 +00:00
# dwonload JSON.sh
2019-04-22 18:34:43 +00:00
JSONSHFILE="JSON.sh/JSON.sh"
if [ ! -f "${JSONSHFILE}" ]; then
2019-04-30 12:21:24 +00:00
mkdir "JSON.sh" 2>/dev/null
2019-04-22 18:34:43 +00:00
curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/dominictarr/JSON.sh/JSON.sh"
chmod +x "${JSONSHFILE}"
fi
2019-04-28 08:32:06 +00:00
# make html doc
2019-04-30 12:21:24 +00:00
mkdir html 2>/dev/null
2019-04-28 08:32:06 +00:00
cp README.html html/index.html
2019-12-07 12:59:54 +00:00
find doc -iname "*.md" -type f -exec sh -c 'pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "./html/$(basename ${0%.md}.html)"' {} \;
find examples -iname "*.md" -type f -exec sh -c 'pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "${0%.md}.html"' {} \;
2019-04-30 12:21:24 +00:00
find README.html html examples -iname "*.html" -type f -exec sh -c 'sed -i -E "s/href=\"(\.\.\/)*doc\//href=\"\1html\//g;s/href=\"(.*).md(#.*)*\"/href=\"\1.html\"/g" ${0}' {} \;
2019-04-28 08:32:06 +00:00
2019-04-22 18:34:43 +00:00
# create archive
cd .. || exit 1
zip -rq "${DISTNAME}-${VERSION}.zip" "${DISTNAME}"
tar -czf "${DISTNAME}-${VERSION}.tar.gz" "${DISTNAME}"
# shellcheck disable=SC2086
ls -ld ${DISTNAME}-${VERSION}.*