Skip to content

Commit

Permalink
Pin the version of Hugo
Browse files Browse the repository at this point in the history
  • Loading branch information
adonis0147 committed Oct 12, 2024
1 parent d8c84c9 commit 3b0a254
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
hugo-version: '0.131.0'
extended: true

- name: Build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.hugo_build.lock
resources/_gen
public
.hugo
59 changes: 59 additions & 0 deletions hugo
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

set -e

SCRIPT_PATH="$(
cd "$(dirname BASH_SOURCE[0])"
pwd
)"
declare -r SCRIPT_PATH
declare -r HUGO_PATH="${SCRIPT_PATH}/.hugo"

function get_url() {
local version="${1}"
local kernel
kernel="$(uname -s)"

if [[ "${kernel}" == 'Darwin' ]]; then
echo "https://github.com/gohugoio/hugo/releases/download/v${version}/hugo_extended_${version}_darwin-universal.tar.gz"
else
local arch
arch="$(uname -m)"
if [[ "${arch}" == 'x86_64' ]]; then
arch='amd64'
else
arch='arm64'
fi

echo "https://github.com/gohugoio/hugo/releases/download/v${version}/hugo_${version}_linux-${arch}.tar.gz"
fi
}

function install_hugo() {
local version='0.131.0'

local current
current="$(hugo version 2>/dev/null | awk '{print $2}')"

if [[ "${current}" =~ "${version}"-* ]]; then
return
fi

local url
url="$(get_url "${version}")"

mkdir -p "${HUGO_PATH}"

echo "Download ${url}"
curl -L "${url}" -o - | tar -C "${HUGO_PATH}" -zxf -
}

function main() {
export PATH="${HUGO_PATH}:${PATH}"

install_hugo

hugo "${@}"
}

main "${@}"

0 comments on commit 3b0a254

Please sign in to comment.