glfs/git-version.sh
Marton Szasz d6dd6c3133
auto publish github pages
Squashed commit of the following:

amend: removed push trigger, because it doesn't work, and I don't know
why. You may only want to publish manually anyway.

commit 9339b3999809ef0631dbed43333facdb6adb7264
Author: Marton Szasz <szaszm@apache.org>
Date:   Mon May 20 17:48:58 2024 +0200

    hardcode output path

    because no variables are available in the publish context

commit a6c320d1ff366f3d1f352295f132376e3b0d486d
Author: Marton Szasz <szaszm@apache.org>
Date:   Mon May 20 17:46:01 2024 +0200

    add missing packages

commit 4cefbe602444968e1210863ca443dbebda33cd9d
Author: Marton Szasz <szaszm@apache.org>
Date:   Mon May 20 17:36:49 2024 +0200

    attempting to fix git describe error during publish

commit e4453320bb9e0878e635cf763dee6eec3bcefd02
Author: Marton Szasz <szaszm@apache.org>
Date:   Mon May 20 17:29:01 2024 +0200

    add xsltproc + debug

commit 1be4323e822f6df67d58ed090dbb9a38971d551a
Author: Marton Szasz <szaszm@apache.org>
Date:   Mon May 20 17:24:06 2024 +0200

    try gh pages publish with actions
2024-05-20 17:59:57 +02:00

58 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
if [ "$1" = sysv ]; then
SYSV="INCLUDE"
SYSTEMD="IGNORE "
elif [ "$1" = systemd ]; then
SYSV="IGNORE "
SYSTEMD="INCLUDE"
else
echo You must provide either \"sysv\" or \"systemd\" as argument
exit 1
fi
echo "<!ENTITY % sysv \"$SYSV\">" > conditional.ent
echo "<!ENTITY % systemd \"$SYSTEMD\">" >> conditional.ent
if ! git status > /dev/null; then
# Either it's not a git repository, or git is unavaliable.
# Just workaround.
echo "<!ENTITY year \"????\">" > version.ent
echo "<!ENTITY version \"unknown\">" >> version.ent
echo "<!ENTITY releasedate \"unknown\">" >> version.ent
echo "<!ENTITY pubdate \"unknown\">" >> version.ent
exit 0
fi
export LC_ALL=en_US.utf8
export TZ=America/Chicago
commit_date=$(git show -s --format=format:"%cd" --date=local)
short_date=$(date --date "$commit_date" "+%Y-%m-%d")
year=$(date --date "$commit_date" "+%Y")
month=$(date --date "$commit_date" "+%B")
day_digit=$(date --date "$commit_date" "+%d")
day=$(echo $day_digit | sed 's/^0//')
case $day in
"1" | "21" | "31" ) suffix="st";;
"2" | "22" ) suffix="nd";;
"3" | "23" ) suffix="rd";;
* ) suffix="th";;
esac
full_date="$month $day$suffix, $year"
sha="$(git describe --abbrev=1 --always)"
version=$(echo "$sha" | sed 's/-g[^-]*$//')
if [ "$(git diff HEAD | wc -l)" != "0" ]; then
version="$version-wip"
fi
echo "<!ENTITY year \"$year\">" > version.ent
echo "<!ENTITY version \"$version\">" >> version.ent
echo "<!ENTITY releasedate \"$full_date\">" >> version.ent
echo "<!ENTITY pubdate \"$short_date\">" >> version.ent