added version information

This commit is contained in:
Bryan Joshua Pedini 2024-08-21 21:49:00 +02:00
parent 85bf73bdf3
commit fc9fce6e6d
4 changed files with 52 additions and 1 deletions

9
content/version.md Normal file
View File

@ -0,0 +1,9 @@
+++
date = "2024-08-21T20:58:34+02:00"
title = "Version Information"
url = "/version"
+++
Version: VAR_VERSION
Commit ID: [VAR_COMMIT_ID](VAR_COMMIT_URL)
Theme Commit ID: [VAR_THEME_COMMIT](VAR_THEME_URL)

View File

@ -4,6 +4,11 @@ languageCode: "en-us"
title: "Bryan Joshua Pedini" title: "Bryan Joshua Pedini"
theme: "hugo-coder" theme: "hugo-coder"
markup:
goldmark:
renderer:
hardWraps: true
params: params:
author: "Bryan Joshua Pedini" author: "Bryan Joshua Pedini"
info: "FullStack Developer - Integration Manager - Cloud/PBX/Network/Docker Specialist - DevOps Enthusiast - Kubernetes/Ceph Apprentice" info: "FullStack Developer - Integration Manager - Cloud/PBX/Network/Docker Specialist - DevOps Enthusiast - Kubernetes/Ceph Apprentice"

View File

@ -6,7 +6,7 @@ prep:
git submodule foreach --recursive bash -c "git checkout $$(git remote show origin | grep HEAD | sed 's/.*\: //'); git pull" git submodule foreach --recursive bash -c "git checkout $$(git remote show origin | grep HEAD | sed 's/.*\: //'); git pull"
build: prep build: prep
hugo ./version.sh
run: prep run: prep
hugo server hugo server

37
version.sh Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e
# Get version from user
read -p "Version [latest]: " VERSIONINPUT
# If version was not provided, use the latest commit short hash as version
if [ -z ${VERSIONINPUT} ]; then
APP_VERSION="latest"
else
APP_VERSION=${VERSIONINPUT}
fi
# Get project commit id and URL
COMMIT_ID=$(git log HEAD --oneline | awk '{print $1}' | head -n1)
COMMIT_URL="$(git remote get-url origin | sed 's/\.git$//g;s/:/\//;s/git@/https:\/\//')/commit/${COMMIT_ID}"
# Get the theme used and its commit id and URL
THEME=$(cat hugo.yaml | grep "theme:" | awk '{print $2}' | sed 's/"//g')
pushd themes/${THEME} &>/dev/null
THEME_COMMIT=$(git log HEAD --oneline | awk '{print $1}' | head -n1)
THEME_URL="$(git remote get-url origin | sed 's/\.git$//g')/commit/${THEME_COMMIT}"
popd &>/dev/null
# Create version tag (if provided)
if [ ! -z ${VERSIONINPUT} ]; then
git tag ${APP_VERSION}
fi
# Build the website
hugo
# Put the correct version information in the website
sed -i "s|VAR_VERSION|${APP_VERSION}|" public/version/index.html
sed -i "s|VAR_COMMIT_ID|${COMMIT_ID}|" public/version/index.html
sed -i "s|VAR_COMMIT_URL|${COMMIT_URL}|" public/version/index.html
sed -i "s|VAR_THEME_URL|${THEME_URL}|" public/version/index.html
sed -i "s|VAR_THEME_COMMIT|${THEME_COMMIT}|" public/version/index.html