Skip to content

Commit 3b0a254

Browse files
committed
Pin the version of Hugo
1 parent d8c84c9 commit 3b0a254

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

.github/workflows/gh-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Setup Hugo
2929
uses: peaceiris/actions-hugo@v2
3030
with:
31-
hugo-version: 'latest'
31+
hugo-version: '0.131.0'
3232
extended: true
3333

3434
- name: Build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.hugo_build.lock
33
resources/_gen
44
public
5+
.hugo

hugo

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
SCRIPT_PATH="$(
6+
cd "$(dirname BASH_SOURCE[0])"
7+
pwd
8+
)"
9+
declare -r SCRIPT_PATH
10+
declare -r HUGO_PATH="${SCRIPT_PATH}/.hugo"
11+
12+
function get_url() {
13+
local version="${1}"
14+
local kernel
15+
kernel="$(uname -s)"
16+
17+
if [[ "${kernel}" == 'Darwin' ]]; then
18+
echo "https://github.com/gohugoio/hugo/releases/download/v${version}/hugo_extended_${version}_darwin-universal.tar.gz"
19+
else
20+
local arch
21+
arch="$(uname -m)"
22+
if [[ "${arch}" == 'x86_64' ]]; then
23+
arch='amd64'
24+
else
25+
arch='arm64'
26+
fi
27+
28+
echo "https://github.com/gohugoio/hugo/releases/download/v${version}/hugo_${version}_linux-${arch}.tar.gz"
29+
fi
30+
}
31+
32+
function install_hugo() {
33+
local version='0.131.0'
34+
35+
local current
36+
current="$(hugo version 2>/dev/null | awk '{print $2}')"
37+
38+
if [[ "${current}" =~ "${version}"-* ]]; then
39+
return
40+
fi
41+
42+
local url
43+
url="$(get_url "${version}")"
44+
45+
mkdir -p "${HUGO_PATH}"
46+
47+
echo "Download ${url}"
48+
curl -L "${url}" -o - | tar -C "${HUGO_PATH}" -zxf -
49+
}
50+
51+
function main() {
52+
export PATH="${HUGO_PATH}:${PATH}"
53+
54+
install_hugo
55+
56+
hugo "${@}"
57+
}
58+
59+
main "${@}"

0 commit comments

Comments
 (0)