aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-15 18:45:33 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-15 18:45:33 +0800
commit993717127039160835f673e434dcd67b4fff73d0 (patch)
tree289f0ebe72abe6cf83651ea67e7db4d9a2f2c081
parentDetect static mime type instead of assuming everything's CSS (diff)
downloadforge-993717127039160835f673e434dcd67b4fff73d0.tar.gz
forge-993717127039160835f673e434dcd67b4fff73d0.tar.zst
forge-993717127039160835f673e434dcd67b4fff73d0.zip
Generate VERSION from git describe
-rw-r--r--.gitignore3
-rw-r--r--Makefile9
-rw-r--r--global.ha2
3 files changed, 10 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index f61aa76..c9ce4a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/forge
-/templates.ha
+/.templates.ha
+/.version.ha
diff --git a/Makefile b/Makefile
index 7c71e4f..a36e9de 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,10 @@
-forge: templates.ha *.ha
+forge: .version.ha .templates.ha *.ha
hare build $(HAREFLAGS) -o $@ .
-templates.ha: templates/*.htmpl
+.templates.ha: templates/*.htmpl
htmplgen -o $@ $^
+
+.version.ha:
+ printf 'def VERSION="%s";\n' $(shell git describe --tags --always --dirty) > $@
+
+.PHONY: version.ha
diff --git a/global.ha b/global.ha
index 11d7886..ac5ac14 100644
--- a/global.ha
+++ b/global.ha
@@ -5,7 +5,7 @@ let global: struct {
ssh_fp: str,
} = struct {
title: str = "Test Forge",
- version: str = "v0.0.0",
+ version: str = VERSION,
ssh_pubkey: str = "pubkey",
ssh_fp: str = "fp",
};