ci: Allow specifying hugo version

This commit is contained in:
2025-11-09 09:32:32 +01:00
parent 06ba0029b2
commit 677ea89517

View File

@@ -22,12 +22,21 @@ jobs:
apt-get update -y
apt-get install -y wget tar jq # Install necessary components
ldd --version
# If a Hugo version is provided in the secrets, use this
# else latest will be used
if [ -n "${{ secrets.HUGO_VERSION }}" ]; then
HUGO_VERSION="${{ secrets.HUGO_VERSION }}"
echo "Using Hugo version from secret: $HUGO_VERSION"
else
# Use the GitHub API to get information about the latest release, then use jq to find out the tag name
latest=$(wget -qO- https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.tag_name')
echo "Latest Hugo version: $latest"
# Use ${latest#v} to strip the v from v1.0.0
HUGO_VERSION=$(wget -qO- https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.tag_name')
echo "Using latest Hugo version: $HUGO_VERSION"
fi
# Use ${HUGO_VERSION#v} to strip the v from v1.0.0
# See "Substring Removal" in https://tldp.org/LDP/abs/html/string-manipulation.html
wget -O hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/${latest}/hugo_extended_${latest#v}_Linux-64bit.tar.gz"
wget -O hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_extended_${HUGO_VERSION#v}_Linux-64bit.tar.gz"
tar -xzf hugo.tar.gz hugo
mv hugo /usr/local/bin/hugo
chmod +x /usr/local/bin/hugo