Skip to content

Commit

Permalink
feat(*): add build{Date,Commit}
Browse files Browse the repository at this point in the history
  • Loading branch information
dwisiswant0 committed Sep 6, 2023
1 parent 8d62d97 commit eb46ecf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
TELER_WAF_VERSION := $(shell go list -m -f '{{ .Version }}' github.com/kitabisa/teler-waf)

BUILD_DATE := $(shell date '+%D %T %Z')
BUILD_COMMIT := $(shell git rev-parse --short HEAD)

build:
go build -ldflags "-s -w -X 'main.telerWAFVersion=$(TELER_WAF_VERSION)'" -o playground .
go build -ldflags "-s -w -X 'main.telerWAFVersion=$(TELER_WAF_VERSION)' -X 'main.buildDate=$(BUILD_DATE)' -X 'main.buildCommit=$(BUILD_COMMIT)'" -o playground .
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ func init() {
hostPort = net.JoinHostPort("0.0.0.0", port)

meta = map[string]interface{}{
"Version": telerWAFVersion,
"Version": telerWAFVersion,
"BuildDate": buildDate,
"BuildCommit": buildCommit,
}
}

Expand All @@ -25,6 +27,7 @@ func main() {
http.HandleFunc("/", indexHandler)
http.HandleFunc("/api/play", playHandler)

log.Printf("teler-waf-playground %s (date: %s)\n", buildCommit, buildDate)
log.Printf("teler-waf version %s\n", telerWAFVersion)
log.Printf("Server started on http://%s\n", hostPort)
if err := http.ListenAndServe(hostPort, nil); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var (
hostPort string

telerWAFVersion string = "Unknown"
buildDate string = "Unknown"
buildCommit string = "Unknown"

meta map[string]any
)
6 changes: 5 additions & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
</head>
<body>
<h1>teler WAF Playground</h1>
<pre>> teler-waf version <a href="https://github.com/kitabisa/teler-waf/releases/tag/{{ .Version }}">{{ .Version }}</a></pre>
<div class="playground">
<button id="play" type="button" onclick="return bake(this);">Play</button>
<button id="clear" type="button" onclick="return clearLogs();">Clear logs</button>
Expand Down Expand Up @@ -139,6 +138,11 @@ <h1>teler WAF Playground</h1>
</ul>
</p>
</div>
<hr>
<pre>
> teler-waf version <a href="https://github.com/kitabisa/teler-waf/releases/tag/{{ .Version }}">{{ .Version }}</a>
> build <a href="https://github.com/teler-sh/teler-waf-playground/commit/{{ .BuildCommit }}">{{ .BuildCommit }}</a> @ {{ .BuildDate }}
</pre>
</div>
<footer>
<span>made with <i>"is it <3? idk, you tell me"</i> by dw1</span>
Expand Down

0 comments on commit eb46ecf

Please sign in to comment.