-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added a new target `download-hugo` in the Makefile to download Hugo. - Updated the `dev-docs` target to use the downloaded Hugo binary. - Created a new script `hack/download-hugo.sh` to handle the download. - Modified the documentation to reflect the changes in the development process. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
- Loading branch information
Showing
4 changed files
with
89 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
# description: Download hugo binary from github directly. | ||
# this let us pin the version the way we want it. | ||
# Author: Chmouel Boudjnah <chmouel@chmouel.com> | ||
set -eufo pipefail | ||
set -x | ||
|
||
TARGET_VERSION=${1:-} | ||
TARGETDIR=${2:-} | ||
|
||
[[ -z ${TARGET_VERSION} || -z ${TARGETDIR} ]] && { echo "Usage: $0 <version> [targetdir]" && exit 1; } | ||
[[ -d ${TARGETDIR} ]] || mkdir -p ${TARGETDIR} | ||
[[ -x ${TARGETDIR}/hugo ]] && { | ||
${TARGETDIR}/hugo version | grep -q "${TARGET_VERSION}.*extended " && { | ||
exit 0 | ||
} | ||
rm -f ${TARGETDIR}/hugo | ||
} | ||
|
||
detect_os_arch() { | ||
local os | ||
local arch | ||
|
||
# Detect OS | ||
case "$(uname -s)" in | ||
Linux*) os=Linux ;; | ||
Darwin*) os=macOS ;; | ||
*) os="UNKNOWN" ;; | ||
esac | ||
|
||
# Detect architecture | ||
case "$(uname -m)" in | ||
x86_64) arch=64bit ;; | ||
arm64) arch=ARM64 ;; | ||
aarch64) arch=ARM64 ;; | ||
*) arch="UNKNOWN" ;; | ||
esac | ||
|
||
[[ ${os} == "UNKNOWN" ]] && echo "Unknown OS" && exit 1 | ||
[[ ${arch} == "UNKNOWN" ]] && echo "Unknown Arch" && exit 1 | ||
|
||
echo "${os}-${arch}" | ||
} | ||
|
||
os_arch=$(detect_os_arch) | ||
download_url=https://github.com/gohugoio/hugo/releases/download/v${TARGET_VERSION}/hugo_extended_${TARGET_VERSION}_${os_arch}.tar.gz | ||
|
||
# If we are on a 64 bit arch we can use the go install method because older hugo don't have a binary for it | ||
[[ ${os_arch} == *64 || ${os_arch} == *64bit ]] && { | ||
export GOBIN=${TARGETDIR} | ||
go install -mod=mod github.com/gohugoio/hugo@v${TARGET_VERSION} | ||
exit 0 | ||
} | ||
echo -n "Downloading ${download_url} to ${TARGETDIR}: " | ||
curl -s -L --fail-early -f -o- ${download_url} | tar -xz -C ${TARGETDIR} hugo | ||
echo "Done" |