From 2e82df8370a2067ecb3810644ca6c51689233ff4 Mon Sep 17 00:00:00 2001 From: Alex <119050107+ofSingularMind@users.noreply.github.com> Date: Wed, 5 Nov 2025 12:47:16 +0100 Subject: [PATCH] For Wouter Kouw to check --- Makefile | 3 ++ README.md | 15 +++++++++ publish.cmd | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 publish.cmd diff --git a/Makefile b/Makefile index 82b0c048..a31b12bf 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,9 @@ preview-website: ## Preview website publish: ## Publish website ./publish.sh +publish-windows: ## Publish website (Windows cmd) + publish.cmd + rebuild-docs: ## Build docs ./rebuild_docs.sh diff --git a/README.md b/README.md index 1b064639..5a5998d1 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,21 @@ Working installation of GNU Make is recommended, but not required. You can test * `build-website`: Generates all the static content for the website. * `preview-website`: Builds the website content and starts Hugo debugging server with live reload enabled. * `publish`: Publishes the contents of the `./public` directory to the `master` branch of [https://biaslab.github.io](https://biaslab.github.io) repository. + * `publish-windows`: Same as `publish`, but uses a Windows batch script (`publish.cmd`). + +### Windows users +If you're on Windows using cmd.exe: + +- Ensure Git and Hugo are installed and available in your PATH (verify with `git --version` and `hugo version`). +- To publish, run either: + + publish.cmd + + or, if you have GNU Make installed: + + make publish-windows + +The Windows script mirrors the built site to a fresh clone of `biaslab/biaslab.github.io` under your `%TEMP%` directory, commits changes if any, and pushes to `master`. # How can I publish my Jupyter notebook on this website? diff --git a/publish.cmd b/publish.cmd new file mode 100644 index 00000000..5a11c46d --- /dev/null +++ b/publish.cmd @@ -0,0 +1,88 @@ +@echo off +REM Publish the site to biaslab.github.io (Windows, cmd.exe) +setlocal enableextensions + +REM Verify prerequisites +where git >NUL 2>&1 +if errorlevel 1 ( + echo [ERROR] Git is not installed or not in PATH. + exit /b 1 +) + +where hugo >NUL 2>&1 +if errorlevel 1 ( + echo [ERROR] Hugo is not installed or not in PATH. + echo Get it from https://gohugo.io/getting-started/installing/ + exit /b 1 +) + +REM Paths +set "CHECKOUT=%TEMP%\biaslab.github.io.git" +set "BUILDPATH=%CD%" + +REM Fresh clone of the target repo +if exist "%CHECKOUT%" rmdir /s /q "%CHECKOUT%" +git clone git@github.com:biaslab/biaslab.github.io.git "%CHECKOUT%" +if errorlevel 1 ( + echo [WARN] SSH clone failed; attempting HTTPS clone instead... + git clone https://github.com/biaslab/biaslab.github.io.git "%CHECKOUT%" + if errorlevel 1 goto :error +) + +REM Update theme to latest master/main +pushd "%BUILDPATH%\themes\academic-group" 2>NUL +if errorlevel 1 ( + echo [ERROR] Theme directory not found: "%BUILDPATH%\themes\academic-group" + goto :error +) + +git rev-parse --verify master >NUL 2>&1 +if %errorlevel%==0 ( + git checkout master +) else ( + git rev-parse --verify main >NUL 2>&1 + if %errorlevel%==0 ( + git checkout main + ) else ( + echo [WARN] Neither 'master' nor 'main' branch found for theme; continuing on current branch. + ) +) +git pull +popd + +REM Clean build output and rebuild +if exist "%BUILDPATH%\public" rmdir /s /q "%BUILDPATH%\public" +mkdir "%BUILDPATH%\public" + +hugo -t academic-group +if errorlevel 1 goto :error + +REM Mirror build output into the cloned site repo, preserving .git +pushd "%CHECKOUT%" +REM Use robocopy to mirror; treat return codes 0-7 as success +robocopy "%BUILDPATH%\public" "%CHECKOUT%" /MIR /XD ".git" >NUL +set RC=%ERRORLEVEL% +if %RC% GEQ 8 goto :error + +REM Commit only if there are changes +git add -A +git diff --quiet --staged +if errorlevel 1 ( + git commit -m "Website update" + if errorlevel 1 goto :error + git push origin master + if errorlevel 1 goto :error +) else ( + echo No changes to commit; skipping push. +) + +popd + +REM Cleanup +if exist "%CHECKOUT%" rmdir /s /q "%CHECKOUT%" +echo All done. +exit /b 0 + +:error +echo [ERROR] Publishing failed. See messages above. +exit /b 1