Version bump

This commit is contained in:
V 2026-05-16 20:38:13 +01:00
parent b0b5c3bd08
commit 3915f7ce4d
6 changed files with 27 additions and 2 deletions

View File

@ -16,6 +16,7 @@ WORKDIR /app
COPY --from=build /out/archi-folio /usr/local/bin/archi-folio COPY --from=build /out/archi-folio /usr/local/bin/archi-folio
COPY --chown=nonroot:nonroot web ./web COPY --chown=nonroot:nonroot web ./web
COPY --chown=nonroot:nonroot VERSION ./VERSION
COPY --chown=nonroot:nonroot data/uploads/.gitkeep ./data/uploads/.gitkeep COPY --chown=nonroot:nonroot data/uploads/.gitkeep ./data/uploads/.gitkeep
EXPOSE 8080 EXPOSE 8080

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.1.0

View File

@ -17,6 +17,10 @@ func main() {
if err := loadDotEnv(".env"); err != nil { if err := loadDotEnv(".env"); err != nil {
log.Fatal(err) log.Fatal(err)
} }
version, err := readVersion("VERSION")
if err != nil {
log.Fatal(err)
}
cfg := app.Config{ cfg := app.Config{
Addr: requiredEnv("ADDR"), Addr: requiredEnv("ADDR"),
@ -25,6 +29,7 @@ func main() {
AdminUsername: requiredEnv("ADMIN_USERNAME"), AdminUsername: requiredEnv("ADMIN_USERNAME"),
AdminPassword: requiredEnv("ADMIN_PASSWORD"), AdminPassword: requiredEnv("ADMIN_PASSWORD"),
UploadDir: requiredEnv("UPLOAD_DIR"), UploadDir: requiredEnv("UPLOAD_DIR"),
Version: version,
} }
db, err := store.Open(cfg.DatabasePath) db, err := store.Open(cfg.DatabasePath)
@ -94,3 +99,15 @@ func requiredEnv(key string) string {
} }
return value return value
} }
func readVersion(path string) (string, error) {
data, err := os.ReadFile(path)
if err != nil {
return "", err
}
version := strings.TrimSpace(string(data))
if version == "" {
return "", fmt.Errorf("%s is empty", path)
}
return version, nil
}

View File

@ -35,6 +35,7 @@ type Config struct {
AdminUsername string AdminUsername string
AdminPassword string AdminPassword string
UploadDir string UploadDir string
Version string
} }
type Server struct { type Server struct {
@ -56,6 +57,7 @@ type pageData struct {
Error string Error string
Success string Success string
CurrentPath string CurrentPath string
Version string
} }
func New(cfg Config, st *store.Store) (*Server, error) { func New(cfg Config, st *store.Store) (*Server, error) {
@ -493,7 +495,7 @@ func (s *Server) adminData(r *http.Request, tab string) (pageData, error) {
if err != nil { if err != nil {
return pageData{}, err return pageData{}, err
} }
data := pageData{Title: "Admin", Admin: true, AdminTab: tab, Content: content, Success: r.URL.Query().Get("ok"), Error: r.URL.Query().Get("err")} data := pageData{Title: "Admin", Admin: true, AdminTab: tab, Content: content, Success: r.URL.Query().Get("ok"), Error: r.URL.Query().Get("err"), Version: s.cfg.Version}
if tab == "projects" { if tab == "projects" {
projects, err := s.store.Projects(r.Context(), false) projects, err := s.store.Projects(r.Context(), false)
if err != nil { if err != nil {

View File

@ -32,6 +32,7 @@ func newTestServer(t *testing.T) *Server {
AdminUsername: "admin", AdminUsername: "admin",
AdminPassword: "changeme", AdminPassword: "changeme",
UploadDir: filepath.Join(dir, "uploads"), UploadDir: filepath.Join(dir, "uploads"),
Version: "test-version",
}, st) }, st)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -119,7 +120,7 @@ func TestAdminTabs(t *testing.T) {
t.Fatalf("%s returned %d", test.path, rec.Code) t.Fatalf("%s returned %d", test.path, rec.Code)
} }
body, _ := io.ReadAll(rec.Result().Body) body, _ := io.ReadAll(rec.Result().Body)
if !strings.Contains(string(body), test.want) || !strings.Contains(string(body), "<!doctype html>") { if !strings.Contains(string(body), test.want) || !strings.Contains(string(body), "<!doctype html>") || !strings.Contains(string(body), "Version test-version") {
t.Fatalf("%s did not render full tab page: %s", test.path, body) t.Fatalf("%s did not render full tab page: %s", test.path, body)
} }
} }

View File

@ -22,6 +22,9 @@
{{define "admin_shell_end"}} {{define "admin_shell_end"}}
</section> </section>
</main> </main>
<footer class="mx-auto max-w-7xl px-5 pb-8 text-xs text-neutral-500 md:px-8">
<p>Version {{.Version}}</p>
</footer>
</body> </body>
</html> </html>
{{end}} {{end}}