File tree Expand file tree Collapse file tree 6 files changed +39
-4
lines changed
Expand file tree Collapse file tree 6 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 44 hooks :
55 - go mod tidy
66
7+ snapshot :
8+ version_template : " {{ .Version }}"
9+
710builds :
811 - env :
912 - CGO_ENABLED=0
@@ -13,7 +16,8 @@ builds:
1316 - amd64
1417 - arm64
1518 ldflags :
16- - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
19+ - -s -w
20+ - -X github.com/skidoodle/safebin/internal/app.Version={{.Version}}
1721 flags :
1822 - -trimpath
1923
Original file line number Diff line number Diff line change @@ -9,10 +9,11 @@ COPY . .
99
1010ARG TARGETOS
1111ARG TARGETARCH
12+ ARG VERSION=dev
1213
1314RUN --mount=type=cache,target=/root/.cache/go-build \
1415 CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
15- -ldflags="-s -w" \
16+ -ldflags="-s -w -X github.com/skidoodle/safebin/internal/app.Version=$VERSION " \
1617 -trimpath \
1718 -o /app/safebin .
1819
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ import (
1313 "go.etcd.io/bbolt"
1414)
1515
16+ var (
17+ Version = "dev"
18+ )
19+
1620const (
1721 DefaultHost = "0.0.0.0"
1822 DefaultPort = 8080
Original file line number Diff line number Diff line change @@ -39,8 +39,9 @@ func (app *App) Routes() *http.ServeMux {
3939
4040func (app * App ) HandleHome (writer http.ResponseWriter , request * http.Request ) {
4141 err := app .Tmpl .ExecuteTemplate (writer , "layout" , map [string ]any {
42- "MaxMB" : app .Conf .MaxMB ,
43- "Host" : request .Host ,
42+ "MaxMB" : app .Conf .MaxMB ,
43+ "Host" : request .Host ,
44+ "Version" : Version ,
4445 })
4546
4647 if err != nil {
Original file line number Diff line number Diff line change @@ -29,6 +29,15 @@ <h2 class="header-title">safebin</h2>
2929 < div class ="dim cli-label "> CLI Usage</ div >
3030 < pre class ="cli-pre "> curl -F file=@yourfile {{.Host}}</ pre >
3131 </ section >
32+ < footer class ="footer ">
33+ < div class ="dim ">
34+ {{if eq .Version "dev"}}
35+ < a href ="https://github.com/skidoodle/safebin " target ="_blank " rel ="noopener noreferrer "> dev</ a >
36+ {{else}}
37+ < a href ="https://github.com/skidoodle/safebin/releases/tag/v{{.Version}} " target ="_blank " rel ="noopener noreferrer "> v{{.Version}}</ a >
38+ {{end}}
39+ </ div >
40+ </ footer >
3241 </ div >
3342 < input type ="file " id ="file-input " class ="hidden " />
3443 < script src ="/static/app.js "> </ script >
Original file line number Diff line number Diff line change @@ -237,10 +237,26 @@ button {
237237 display : none !important ;
238238}
239239
240+ .footer {
241+ margin-top : 20px ;
242+ text-align : center;
243+ opacity : 0.5 ;
244+ }
245+
246+ .footer a {
247+ color : inherit;
248+ text-decoration : none;
249+ }
250+
251+ .footer a : hover {
252+ text-decoration : underline;
253+ }
254+
240255@media (max-width : 400px ) {
241256 .github-btn span {
242257 display : none;
243258 }
259+
244260 .github-btn {
245261 padding : 6px ;
246262 }
You can’t perform that action at this time.
0 commit comments