diff --git a/.goreleaser.yaml b/.goreleaser.yaml index cd1c1fc..525f11f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -4,6 +4,9 @@ before: hooks: - go mod tidy +snapshot: + version_template: "{{ .Version }}" + builds: - env: - CGO_ENABLED=0 @@ -13,7 +16,8 @@ builds: - amd64 - arm64 ldflags: - - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} + - -s -w + - -X github.com/skidoodle/safebin/internal/app.Version={{.Version}} flags: - -trimpath diff --git a/Dockerfile b/Dockerfile index 6acea40..551436b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,11 @@ COPY . . ARG TARGETOS ARG TARGETARCH +ARG VERSION=dev RUN --mount=type=cache,target=/root/.cache/go-build \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \ - -ldflags="-s -w" \ + -ldflags="-s -w -X github.com/skidoodle/safebin/internal/app.Version=$VERSION" \ -trimpath \ -o /app/safebin . diff --git a/internal/app/config.go b/internal/app/config.go index 165ce96..0e71946 100644 --- a/internal/app/config.go +++ b/internal/app/config.go @@ -13,6 +13,10 @@ import ( "go.etcd.io/bbolt" ) +var ( + Version = "dev" +) + const ( DefaultHost = "0.0.0.0" DefaultPort = 8080 diff --git a/internal/app/server.go b/internal/app/server.go index d64bdf0..0b8463f 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -39,8 +39,9 @@ func (app *App) Routes() *http.ServeMux { func (app *App) HandleHome(writer http.ResponseWriter, request *http.Request) { err := app.Tmpl.ExecuteTemplate(writer, "layout", map[string]any{ - "MaxMB": app.Conf.MaxMB, - "Host": request.Host, + "MaxMB": app.Conf.MaxMB, + "Host": request.Host, + "Version": Version, }) if err != nil { diff --git a/web/layout.html b/web/layout.html index 161dcc4..9d2aa9c 100644 --- a/web/layout.html +++ b/web/layout.html @@ -29,6 +29,15 @@
curl -F file=@yourfile {{.Host}}
+
diff --git a/web/style.css b/web/style.css
index 8db3323..3cb5675 100644
--- a/web/style.css
+++ b/web/style.css
@@ -237,10 +237,26 @@ button {
display: none !important;
}
+.footer {
+ margin-top: 20px;
+ text-align: center;
+ opacity: 0.5;
+}
+
+.footer a {
+ color: inherit;
+ text-decoration: none;
+}
+
+.footer a:hover {
+ text-decoration: underline;
+}
+
@media (max-width: 400px) {
.github-btn span {
display: none;
}
+
.github-btn {
padding: 6px;
}