diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-14 14:11:27 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-14 14:11:27 +0800 |
commit | 74a840f5299a76942d33fa491fcae2de1e831a34 (patch) | |
tree | f1c3ff65c52d0ecdcb4f15b02a6f71a66ac0552f | |
parent | go.mod: Bump lindenii-common (diff) | |
download | forge-74a840f5299a76942d33fa491fcae2de1e831a34.tar.gz forge-74a840f5299a76942d33fa491fcae2de1e831a34.tar.zst forge-74a840f5299a76942d33fa491fcae2de1e831a34.zip |
*: Use Makefile, and generate a version
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | http_global.go | 1 | ||||
-rw-r--r-- | resources.go | 1 | ||||
-rw-r--r-- | templates/_footer.html.tmpl | 2 |
6 files changed, 16 insertions, 2 deletions
@@ -1 +1,2 @@ /forge +/version.go diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..227cef9 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +.PHONY: clean + +forge: $(filter-out forge,$(wildcard *)) version.go + go build -o $@ + +version.go: + printf 'package main\nconst VERSION="%s"\n' $(shell git describe --tags --long --always --dirty) > $@ + +clean: + $(RM) forge version.go + @@ -7,7 +7,7 @@ primarily designed for self-hosting by small organizations and individuals. ## Setup -* Clone the source code and build a binary with `go build`. +* Clone the source code and build a binary with GNU make. * Generate an SSH key pair with `ssh-keygen`. * Create a PostgreSQL database and run `schema.sql`. * Set up reverse proxies, etc., if desired. diff --git a/http_global.go b/http_global.go index b1e5585..e007490 100644 --- a/http_global.go +++ b/http_global.go @@ -3,5 +3,6 @@ package main var global_data = map[string]any{ "server_public_key_string": &server_public_key_string, "server_public_key_fingerprint": &server_public_key_fingerprint, + "forge_version": VERSION, // Some other ones are populated after config parsing } diff --git a/resources.go b/resources.go index 12acb8f..44d685f 100644 --- a/resources.go +++ b/resources.go @@ -10,6 +10,7 @@ import ( //go:embed .gitignore LICENSE README.md //go:embed *.go go.mod go.sum //go:embed *.scfg +//go:embed Makefile //go:embed schema.sql //go:embed static/* templates/* var source_fs embed.FS diff --git a/templates/_footer.html.tmpl b/templates/_footer.html.tmpl index 7d9072b..b4cce19 100644 --- a/templates/_footer.html.tmpl +++ b/templates/_footer.html.tmpl @@ -1,3 +1,3 @@ {{- define "footer" -}} -<a href="https://lindenii.runxiyu.org/forge/">Lindenii Forge</a> (<a href="/:/source/">source</a>, <a href="https://forge.lindenii.runxiyu.org/lindenii/:/repos/forge/">upstream</a>) +<a href="https://lindenii.runxiyu.org/forge/">Lindenii Forge</a> {{ .global.forge_version }} (<a href="/:/source/">source</a>, <a href="https://forge.lindenii.runxiyu.org/lindenii/:/repos/forge/">upstream</a>) {{- end -}} |