From 4686be04a157772b61bd7b2941786f0304ebfe08 Mon Sep 17 00:00:00 2001 From: Xiretza <xiretza@xiretza.xyz> Date: Tue, 11 Feb 2025 20:17:20 +0000 Subject: [PATCH] Add just build target, use in CI --- .forgejo/workflows/deploy.yml | 10 ++-------- Justfile | 4 ++++ create_versioned_hugo_toml.sh | 11 +++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100755 create_versioned_hugo_toml.sh diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 94f7320..b434528 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -22,15 +22,9 @@ jobs: - name: Check run: just check - - name: Replace version and timestamp - run: | - sed -i -e "s#{{TAG}}#$GITHUB_REF_NAME#g" ./hugo.toml - sed -i -e "s/{{COMMIT}}/$GITHUB_SHA/g" ./hugo.toml - sed -i -e "s/show_version = false/show_version = true/g" ./hugo.toml - - name: Build website - run: | - hugo build --minify + run: just build + - name: Copy to server if: github.ref == 'refs/heads/master' run: | diff --git a/Justfile b/Justfile index d123175..dc9b535 100644 --- a/Justfile +++ b/Justfile @@ -5,5 +5,9 @@ check: format: clang-format -i assets/js/*.js +build: + ./create_versioned_hugo_toml.sh hugo.toml hugo_versioned.toml + hugo build --config hugo_versioned.toml --minify + serve: hugo serve diff --git a/create_versioned_hugo_toml.sh b/create_versioned_hugo_toml.sh new file mode 100755 index 0000000..3ccd01a --- /dev/null +++ b/create_versioned_hugo_toml.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Usage: ./create_versioned_hugo_toml.sh INFILE OUTFILE +# Replaces the version placeholders in hugo.toml with versions taken from +# $GITHUB_REF_NAME and $GITHUB_SHA environment variables. + +cp "$1" "$2" +sed -i -e "s#{{TAG}}#$GITHUB_REF_NAME#g" "$2" +sed -i -e "s/{{COMMIT}}/$GITHUB_SHA/g" "$2" +sed -i -e "s/show_version = false/show_version = true/g" "$2"