From 953f58b3c346c60a2ae755262f032e2518ded521 Mon Sep 17 00:00:00 2001 From: Vanessa Freudenberg Date: Tue, 26 Mar 2024 14:03:35 -0700 Subject: [PATCH] Update build-pages.sh --- scripts/build-pages.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/scripts/build-pages.sh b/scripts/build-pages.sh index 1e5fee28..1e691df4 100755 --- a/scripts/build-pages.sh +++ b/scripts/build-pages.sh @@ -14,6 +14,8 @@ LINKS=() FAILED=() SUCCESS=() TOP=$(git rev-parse --show-toplevel) +COMMIT=$(git log -1 --format='%H') +COMMIT_DATE=$(git log -1 --format='%cd' --date=format:'%Y-%m-%d %H:%M:%S') for DIR in tutorials examples ; do cd $TOP mkdir _site/$DIR @@ -23,22 +25,21 @@ for DIR in tutorials examples ; do echo echo "=== Building $APP ===" cd $TOP/$APP - COMMIT=$(git log -1 --format='%ad %H' --date=format:'%Y-%m-%d %H:%M:%S') echo "Commit: $COMMIT" > build.log npm run build >> build.log 2>&1 BUILD_ERROR=$? cat build.log - DATE=$(git ls-tree -r --name-only HEAD -- . | grep -v 'package.*json' | xargs -n 1 git log -1 --format='%ad' --date=format:'%Y-%m-%d' | sort | tail -1) + APP_DATE=$(git ls-tree -r --name-only HEAD -- . | grep -v 'package.*json' | xargs -n 1 git log -1 --format='%cd' --date=format:'%Y-%m-%d' | sort | tail -1) if [ $BUILD_ERROR -eq 0 ] ; then mv -v dist ../../_site/$APP - LINKS+=("

${DATE} ${APP} (log)

") + LINKS+=("

${APP_DATE} ${APP} (log)

") SUCCESS+=($APP) else mkdir ../../_site/$APP echo "

Build failed

" > ../../_site/$APP/index.html
             cat build.log >> ../../_site/$APP/index.html
             echo "
" >> ../../_site/$APP/index.html - LINKS+=("

${DATE} ${APP} BUILD FAILED (log)

") + LINKS+=("

${APP_DATE} ${APP} BUILD FAILED (log)

") FAILED+=($APP) fi mv -v build.log ../../_site/$APP/ @@ -47,6 +48,13 @@ done cd $TOP +LATEST_TAG=$(git describe --tags --abbrev=0) +COMMITS_SINCE=$(git rev-list --count ${LATEST_TAG}..HEAD) +VERSION="${LATEST_TAG}" +if [ $COMMITS_SINCE -gt 0 ] ; then + VERSION="${VERSION}+${COMMITS_SINCE}" +fi + echo echo "=== Building index page ===" cat > _site/index.html < _site/index.html < - Worldcore Builds + Worldcore Build ${VERSION} -

Worldcore Builds

-

${COMMIT} +

Worldcore Build ${VERSION}

+

${COMMIT_DATE} ${COMMIT} (full log, previous)

${LINKS[@]} @@ -87,14 +95,18 @@ if [ -n "$SLACK_HOOK_URL" ] ; then NUM_FAILED=${#FAILED[@]} NUM_TOTAL=$((${#SUCCESS[@]} + ${#FAILED[@]})) if [ $NUM_FAILED -eq 0 ] ; then - JSON="{\"text\": \"šŸ˜ *Worldcore build succeeded for all apps* šŸ˜\n${URL}\"}" + JSON="{\"text\": \"šŸ˜ *Worldcore build ${VERSION} succeeded for all apps* šŸ˜\n${URL}\"}" else APPS="" for APP in ${FAILED[@]} ; do LOG="https://croquet.github.io/worldcore/${APP}/build.log" - APPS="${APPS}\nā€¢ <${LOG}|${APP}>" + APPS="${APPS}\nāŒ <${LOG}|${APP}>" + done + for APP in ${SUCCESS[@]} ; do + RUN="https://croquet.github.io/worldcore/${APP}/" + APPS="${APPS}\nāœ… <${RUN}|${APP}>" done - JSON="{\"text\": \"šŸ’© *Worldcore builds failed for ${NUM_FAILED}/${NUM_TOTAL} apps* šŸ’©\n${URL}\n${APPS}\"}" + JSON="{\"text\": \"šŸ‘·ā€ā™€ļø *Worldcore app build ${VERSION} failed for ${NUM_FAILED}/${NUM_TOTAL} apps* šŸ‘·ā€ā™€ļø\n${URL}\n${APPS}\"}" fi curl -sSX POST -H 'Content-type: application/json' --data "${JSON}" $SLACK_HOOK_URL else