diff --git a/antora-ui/build.sh b/antora-ui/build.sh index 44a7c18..850029e 100755 --- a/antora-ui/build.sh +++ b/antora-ui/build.sh @@ -7,11 +7,15 @@ if [ -z "$npm_version" ]; then echo "npm is not installed" exit 1 fi + gulp_version=$(gulp --version 2>/dev/null) if [ -z "$gulp_version" ]; then echo "gulp is not installed" exit 1 fi -npm install +if [ ! -d "node_modules" ] || [ "$(find package.json -prune -printf '%T@\n' | cut -d . -f 1)" -gt "$(find node_modules -prune -printf '%T@\n' | cut -d . -f 1)" ]; then + npm install +fi + gulp bundle diff --git a/antora-ui/src/partials/footer-content.hbs b/antora-ui/src/partials/footer-content.hbs index cdeeb47..2724c41 100644 --- a/antora-ui/src/partials/footer-content.hbs +++ b/antora-ui/src/partials/footer-content.hbs @@ -1,4 +1,11 @@ diff --git a/build.sh b/build.sh index deb3bf2..f07ef64 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,13 @@ #!/bin/sh -./sitedoc.sh develop +if command -v git >/dev/null && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + branch=$(git rev-parse --abbrev-ref HEAD) +else + branch="develop" +fi + +if [ "$branch" != "master" ] && [ "$branch" != "develop" ]; then + branch="develop" +fi + +./sitedoc.sh "$branch" diff --git a/libdoc.sh b/libdoc.sh index a09b274..31b05d9 100755 --- a/libdoc.sh +++ b/libdoc.sh @@ -55,18 +55,27 @@ if ! [ -e "$script_dir/antora-ui/build/ui-bundle.zip" ]; then cd "$cwd" || exit fi +if command -v git >/dev/null && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + commit_id=$(git rev-parse HEAD) + commit_id=$(expr substr "$commit_id" $(expr length "$commit_id" - 7) 8) +else + commit_id="" +fi + # Run antora command while test $# -gt 0; do if [ "$1" = "develop" ] || [ "$1" = "master" ]; then $ANTORA_CMD --fetch \ --attribute page-boost-branch=$1 \ --attribute page-boost-ui-branch=$1 \ + --attribute page-commit-id="$commit_id" \ libs.playbook.yml elif [ "$1" = "release" ]; then $ANTORA_CMD --fetch \ --attribute page-boost-branch=master \ --attribute page-boost-ui-branch=master \ + --attribute page-commit-id="$commit_id" \ --attribute page-boost-is-release=true \ libs.playbook.yml @@ -77,6 +86,7 @@ while test $# -gt 0; do $ANTORA_CMD --fetch \ --attribute page-boost-branch=$1 \ --attribute page-boost-ui-branch=master \ + --attribute page-commit-id="$commit_id" \ "$f" else echo "Playbook \"$f\" does not exist" diff --git a/libs.playbook.yml b/libs.playbook.yml index 473be68..67ecb05 100644 --- a/libs.playbook.yml +++ b/libs.playbook.yml @@ -30,6 +30,7 @@ asciidoc: page-boost-branch: develop page-boost-ui-branch: develop page-boost-is-release: '' + page-commit-id: '' site: url: https://antora.cppalliance.org/${page-boost-branch}/lib/doc diff --git a/site.playbook.yml b/site.playbook.yml index 7c8ccd8..114e40d 100644 --- a/site.playbook.yml +++ b/site.playbook.yml @@ -20,6 +20,7 @@ asciidoc: attributes: page-boost-branch: develop + page-commit-id: '' site: url: https://antora.cppalliance.org diff --git a/sitedoc.sh b/sitedoc.sh index 8c5eb69..0a4ad32 100755 --- a/sitedoc.sh +++ b/sitedoc.sh @@ -42,23 +42,27 @@ fi cwd=$(pwd) script_dir=$(dirname "$(readlink -f "$0")") -if ! [ -e "$script_dir/antora-ui/build/ui-bundle.zip" ]; then +if ! [ -e "$script_dir/antora-ui/build/ui-bundle.zip" ] || \ + find "$script_dir/antora-ui" -newer "$script_dir/antora-ui/build/ui-bundle.zip" -print -quit | grep -q . +then cd "$script_dir/antora-ui" || exit ./build.sh cd "$cwd" || exit fi -while test $# -gt 0; do - if [ "$1" = "develop" ]; then - $ANTORA_CMD --fetch \ - --attribute page-boost-branch=$1 \ - site.playbook.yml - elif [ "$1" = "master" ]; then - $ANTORA_CMD --fetch \ - --attribute page-boost-branch=$1 \ - site.playbook.yml - else - echo "invalid argument: '$1'" - fi - shift -done +if command -v git >/dev/null && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + commit_id=$(git rev-parse HEAD) + commit_id=$(expr substr "$commit_id" $(expr length "$commit_id" - 7) 8) +else + commit_id="" +fi + +if [ "$1" != "develop" ] && [ "$1" != "master" ]; then + echo "invalid argument: '$1'" + exit 1 +fi + +$ANTORA_CMD --fetch \ + --attribute page-boost-branch="$1" \ + --attribute page-commit-id="$commit_id" \ + site.playbook.yml