aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-14 14:11:27 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-14 14:11:27 +0800
commit74a840f5299a76942d33fa491fcae2de1e831a34 (patch)
treef1c3ff65c52d0ecdcb4f15b02a6f71a66ac0552f
parentgo.mod: Bump lindenii-common (diff)
downloadforge-74a840f5299a76942d33fa491fcae2de1e831a34.tar.gz
forge-74a840f5299a76942d33fa491fcae2de1e831a34.tar.zst
forge-74a840f5299a76942d33fa491fcae2de1e831a34.zip
*: Use Makefile, and generate a version
-rw-r--r--.gitignore1
-rw-r--r--Makefile11
-rw-r--r--README.md2
-rw-r--r--http_global.go1
-rw-r--r--resources.go1
-rw-r--r--templates/_footer.html.tmpl2
6 files changed, 16 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index e90b0c9..324f5c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
+
diff --git a/README.md b/README.md
index 0082f68..f8ab85d 100644
--- a/README.md
+++ b/README.md
@@ -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 -}}