Skip to content

Commit d52704a

Browse files
style: Add version in footer.
1 parent aebadae commit d52704a

File tree

8 files changed

+17
-10
lines changed

8 files changed

+17
-10
lines changed

.github/workflows/publish-to-dockerhub.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
2626
--build-arg VCS_REF=${GITHUB_SHA::8} \
2727
${DOCKER_IMAGE_TAGS} .
28+
sed -i '2i\VERSION = {TAG_NAME}' gotty/Makefile
2829
- name: Set up Docker Buildx
2930
uses: crazy-max/ghaction-docker-buildx@v3
3031
- name: Docker Buildx (build)

gotty/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
OUTPUT_DIR = ./builds
2-
GIT_COMMIT = `git rev-parse HEAD | cut -c1-7`
3-
VERSION = 2.0.0-alpha.3
4-
BUILD_OPTIONS = -ldflags "-X main.Version=$(VERSION) -X main.CommitID=$(GIT_COMMIT)"
2+
BUILD_OPTIONS = -ldflags "-X main.Version=$(VERSION)"
53

64
gotty: main.go server/*.go webtty/*.go backend/*.go cache/token/*.go Makefile
75
go mod download

gotty/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import (
1818
func main() {
1919
app := cli.NewApp()
2020
app.Name = "gotty"
21-
app.Version = Version + "+" + CommitID
21+
app.Version = Version
22+
os.Setenv("app.Version", app.Version)
2223
app.Usage = "Share your terminal as a web application"
2324
app.HideHelp = true
2425

gotty/resources/index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ a, a:link, a:visited {
4545

4646
.footer-show {
4747
display: block !important;
48+
}
49+
50+
.version {
51+
float: right;
52+
padding-right: 10px;
4853
}

gotty/resources/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ <h5 class="modal-title">Delete Session</h5>
120120
</div>
121121
<div class="footer bg-dark footer-show">
122122
<a href="https://www.fit2cloud.com" target="_blank">Powered by FIT2CLOUD, www.fit2cloud.com.</a>
123+
<span class="version">#app.Version</span>
123124
</div>
124125
</body>
125126
</html>

gotty/server/asset.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gotty/server/handlers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,13 @@ func (server *Server) handleMain(w http.ResponseWriter, r *http.Request) {
237237
if err != nil {
238238
panic("index not found") // must be in bindata
239239
}
240+
indexData = bytes.Replace(indexData, []byte("#app.Version"), []byte(os.Getenv("app.Version")), -1)
240241
if len(os.Getenv("HIDE_INDEX_FOOTER")) > 0 {
241242
w.Write(bytes.Replace(indexData, []byte("footer-show"), []byte(""), -1))
242243
} else {
243244
w.Write(indexData)
244245
}
246+
245247
}
246248

247249
func (server *Server) handleAuthToken(w http.ResponseWriter, r *http.Request) {

gotty/version.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package main
22

3-
var Version = "unknown_version"
4-
var CommitID = "unknown_commit"
3+
var Version = ""

0 commit comments

Comments
 (0)