| 
									
										
										
										
											2025-03-26 21:55:31 +00:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Specify the base URL | 
					
						
							|  |  |  | BASE_URL=${1:-"http://localhost:1313"} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "Using base URL: $BASE_URL" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Version configuration - modify these arrays to specify versions to build | 
					
						
							| 
									
										
										
										
											2025-09-06 11:12:58 +00:00
										 |  |  | # MAIN_VERSION format: "ref:display_name:source_dir" | 
					
						
							| 
									
										
										
										
											2025-09-06 12:06:26 +01:00
										 |  |  | # VERSIONS format: "ref:display_name:source_dir" where source_dir is either "docs" or "exampleSite" | 
					
						
							| 
									
										
										
										
											2025-09-06 14:03:29 +01:00
										 |  |  | MAIN_VERSION="v0.11.1:latest:docs" | 
					
						
							| 
									
										
										
										
											2025-03-26 21:55:31 +00:00
										 |  |  | VERSIONS=( | 
					
						
							| 
									
										
										
										
											2025-09-06 12:06:26 +01:00
										 |  |  |   "main:latest:docs" # latest version always builds from main | 
					
						
							| 
									
										
										
										
											2025-09-06 11:12:58 +00:00
										 |  |  |   "v0.10.2:v0.10:exampleSite" | 
					
						
							| 
									
										
										
										
											2025-09-06 12:06:26 +01:00
										 |  |  |   "v0.9.6:v0.9:exampleSite" | 
					
						
							| 
									
										
										
										
											2025-03-26 21:55:31 +00:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Parse main version | 
					
						
							| 
									
										
										
										
											2025-09-06 11:12:58 +00:00
										 |  |  | IFS=':' read -r MAIN_REF MAIN_NAME MAIN_DIR <<< "$MAIN_VERSION" | 
					
						
							| 
									
										
										
										
											2025-03-26 21:55:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Ensure clean public directory | 
					
						
							|  |  |  | rm -rf public | 
					
						
							|  |  |  | mkdir -p public | 
					
						
							|  |  |  | mkdir -p public/versions | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Checkout and build main site | 
					
						
							|  |  |  | git checkout $MAIN_REF | 
					
						
							|  |  |  | GIT_HASH=$(git rev-parse --short HEAD) | 
					
						
							|  |  |  | echo "Building main site from $MAIN_REF (commit: $GIT_HASH)" | 
					
						
							|  |  |  | hugo \
 | 
					
						
							|  |  |  |   --minify \
 | 
					
						
							| 
									
										
										
										
											2025-09-06 11:12:58 +00:00
										 |  |  |   --themesDir=../.. --source=$MAIN_DIR \
 | 
					
						
							| 
									
										
										
										
											2025-03-26 21:55:31 +00:00
										 |  |  |   --baseURL "$BASE_URL/" \
 | 
					
						
							|  |  |  |   --destination=../public | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Build all versions | 
					
						
							|  |  |  | for VERSION in "${VERSIONS[@]}"; do | 
					
						
							| 
									
										
										
										
											2025-09-06 12:06:26 +01:00
										 |  |  |   IFS=':' read -r REF NAME DIR <<< "$VERSION" | 
					
						
							| 
									
										
										
										
											2025-03-26 21:55:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   git checkout $REF | 
					
						
							|  |  |  |   GIT_HASH=$(git rev-parse --short HEAD) | 
					
						
							|  |  |  |   echo "Building version $NAME from $REF (commit: $GIT_HASH)" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   mkdir -p "public/versions/$NAME" | 
					
						
							|  |  |  |   hugo \
 | 
					
						
							|  |  |  |     --minify \
 | 
					
						
							| 
									
										
										
										
											2025-09-06 12:06:26 +01:00
										 |  |  |     --themesDir=../.. --source=$DIR \
 | 
					
						
							| 
									
										
										
										
											2025-03-26 21:55:31 +00:00
										 |  |  |     --baseURL "$BASE_URL/versions/$NAME/" \
 | 
					
						
							|  |  |  |     --destination="../public/versions/$NAME" | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Return to main branch | 
					
						
							|  |  |  | git checkout main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "Build completed" |