ci: Allow specifying hugo version
This commit is contained in:
@@ -22,12 +22,21 @@ jobs:
|
|||||||
apt-get update -y
|
apt-get update -y
|
||||||
apt-get install -y wget tar jq # Install necessary components
|
apt-get install -y wget tar jq # Install necessary components
|
||||||
ldd --version
|
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
|
# 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')
|
HUGO_VERSION=$(wget -qO- https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.tag_name')
|
||||||
echo "Latest Hugo version: $latest"
|
echo "Using latest Hugo version: $HUGO_VERSION"
|
||||||
# Use ${latest#v} to strip the v from v1.0.0
|
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
|
# 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
|
tar -xzf hugo.tar.gz hugo
|
||||||
mv hugo /usr/local/bin/hugo
|
mv hugo /usr/local/bin/hugo
|
||||||
chmod +x /usr/local/bin/hugo
|
chmod +x /usr/local/bin/hugo
|
||||||
|
|||||||
Reference in New Issue
Block a user