From 993717127039160835f673e434dcd67b4fff73d0 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 15 Mar 2025 18:45:33 +0800 Subject: [PATCH] Generate VERSION from git describe --- .gitignore | 3 ++- Makefile | 9 +++++++-- global.ha | 2 +- diff --git a/.gitignore b/.gitignore index f61aa7686898291fe19d8ae83bc5c7edac1840ad..c9ce4a7940e62e8ddc5631f6d7dbaf13786a1396 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /forge -/templates.ha +/.templates.ha +/.version.ha diff --git a/Makefile b/Makefile index 7c71e4f0dff4d338f19480f2431afe59c50dc407..a36e9de4845a73c67675c27bcc64e0e662776bb0 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 11d7886b0a65ae8bbe666e67243a106a30b5eb97..ac5ac143ee89ae954a046bbaa612323bf2f96cdb 100644 --- a/global.ha +++ b/global.ha @@ -5,7 +5,7 @@ ssh_pubkey: str, ssh_fp: str, } = struct { title: str = "Test Forge", - version: str = "v0.0.0", + version: str = VERSION, ssh_pubkey: str = "pubkey", ssh_fp: str = "fp", }; -- 2.48.1