mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 02:34:42 +00:00
Add version info into the apps (#330)
Both worker and coordinator display version number in the console during startup. Coordinator displays its version number in the top right corner of the index.html page.
This commit is contained in:
parent
cbabe69f30
commit
30d104ee98
8 changed files with 59 additions and 5 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -113,4 +113,4 @@ jobs:
|
|||
if: github.event_name == 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: docker build .
|
||||
- run: docker build --build-arg VERSION=$(./scripts/version.sh) .
|
||||
|
|
|
|||
10
Dockerfile
vendored
10
Dockerfile
vendored
|
|
@ -20,7 +20,7 @@ RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
|
|||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# go setup layer
|
||||
ARG GO=go1.16.3.linux-amd64.tar.gz
|
||||
ARG GO=go1.16.6.linux-amd64.tar.gz
|
||||
RUN wget -q https://golang.org/dl/$GO \
|
||||
&& rm -rf /usr/local/go \
|
||||
&& tar -C /usr/local -xzf $GO \
|
||||
|
|
@ -35,7 +35,9 @@ RUN go mod download
|
|||
COPY pkg ./pkg
|
||||
COPY cmd ./cmd
|
||||
COPY Makefile .
|
||||
RUN make build
|
||||
COPY scripts ./scripts
|
||||
ARG VERSION
|
||||
RUN GIT_VERSION=${VERSION} make build
|
||||
|
||||
# base image
|
||||
FROM debian:bullseye-slim
|
||||
|
|
@ -51,5 +53,9 @@ RUN cp -s $(pwd)/* /usr/local/bin
|
|||
COPY assets/cores ./assets/cores
|
||||
COPY configs ./configs
|
||||
COPY web ./web
|
||||
ARG VERSION
|
||||
COPY scripts/version.sh version.sh
|
||||
RUN bash ./version.sh ./web/index.html ${VERSION} && \
|
||||
rm -rf version.sh
|
||||
|
||||
EXPOSE 8000 9000
|
||||
|
|
|
|||
7
Makefile
vendored
7
Makefile
vendored
|
|
@ -60,8 +60,8 @@ clean:
|
|||
@go clean ./cmd/*
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 go build -ldflags '-w -s' -o bin/ ./cmd/coordinator
|
||||
go build -buildmode=exe -tags static -ldflags '-w -s' $(EXT_WFLAGS) -o bin/ ./cmd/worker
|
||||
CGO_ENABLED=0 go build -ldflags "-w -s -X 'main.Version=$(GIT_VERSION)'" -o bin/ ./cmd/coordinator
|
||||
go build -buildmode=exe -tags static -ldflags "-w -s -X 'main.Version=$(GIT_VERSION)'" $(EXT_WFLAGS) -o bin/ ./cmd/worker
|
||||
|
||||
verify-cores:
|
||||
go test -run TestAllEmulatorRooms ./pkg/worker/room -v -renderFrames $(GL_CTX) -outputPath "../../../_rendered"
|
||||
|
|
@ -120,6 +120,7 @@ CORES_DIR = assets/cores
|
|||
GAMES_DIR = assets/games
|
||||
.PHONY: release
|
||||
.SILENT: release
|
||||
release: GIT_VERSION := "$(shell ./scripts/version.sh)"
|
||||
release: clean build
|
||||
rm -rf ./$(RELEASE_DIR) && mkdir ./$(RELEASE_DIR)
|
||||
mkdir -p $(COORDINATOR_DIR) && mkdir -p $(WORKER_DIR)
|
||||
|
|
@ -133,6 +134,8 @@ release: clean build
|
|||
$(DLIB_TOOL) $(WORKER_DIR) $(WORKER_DIR)/worker
|
||||
endif
|
||||
cp -R ./web $(COORDINATOR_DIR)
|
||||
# add version tag into index.html
|
||||
shell ./scripts/version.sh $(COORDINATOR_DIR)/web/index.html
|
||||
mkdir -p $(WORKER_DIR)/$(GAMES_DIR)
|
||||
ifneq (,$(wildcard ./$(GAMES_DIR)))
|
||||
cp -R ./$(GAMES_DIR) $(WORKER_DIR)/assets
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import (
|
|||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
var Version = ""
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
|
|
@ -28,6 +30,7 @@ func main() {
|
|||
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
|
||||
glog.Infof("[coordinator] version: %v", Version)
|
||||
glog.Infof("Initializing coordinator server")
|
||||
glog.V(4).Infof("Coordinator configs %v", conf)
|
||||
o := coordinator.New(ctx, conf)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import (
|
|||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
var Version = ""
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
|
@ -31,6 +33,7 @@ func run() {
|
|||
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
|
||||
glog.Infof("[worker] version: %v", Version)
|
||||
glog.V(4).Info("[worker] Initialization")
|
||||
glog.V(4).Infof("[worker] Local configuration %+v", conf)
|
||||
wrk := worker.New(ctx, conf)
|
||||
|
|
|
|||
30
scripts/version.sh
vendored
Executable file
30
scripts/version.sh
vendored
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
|
||||
file="$1"
|
||||
version="$2"
|
||||
from="(<span id=\"v\">).*?(<\/span>)"
|
||||
|
||||
# Prints app version derived from git in the following format:
|
||||
#
|
||||
# v2-1-gcafeb
|
||||
# ^ ^ ^ ^
|
||||
# | | | |
|
||||
# | | | '- commit hash of HEAD (1st 5 symbols)
|
||||
# | | '-- "g" stands for git
|
||||
# | '---- n commits since the last tag
|
||||
# '------- last tag
|
||||
#
|
||||
# See: https://git-scm.com/docs/git-describe
|
||||
#
|
||||
# The first input param replaces the version placeholder in the provided file.
|
||||
# The second input param forces the use of some version value instead of a git-derived one.
|
||||
#
|
||||
if [ "$version" = "" ]; then
|
||||
version=$(git describe --abbrev=5 --always --tags 2> /dev/null)
|
||||
fi
|
||||
if [ "$file" != "" ]; then
|
||||
sed -i -E "s/$from/\1$version\2/" "$file"
|
||||
echo "$file $version"
|
||||
else
|
||||
echo "$version"
|
||||
fi
|
||||
5
web/css/main.css
vendored
5
web/css/main.css
vendored
|
|
@ -780,3 +780,8 @@ input:checked + .dpad-toggle-slider:before {
|
|||
-ms-transform: translateX(15px);
|
||||
transform: translateX(15px);
|
||||
}
|
||||
|
||||
#version {
|
||||
color: #dddddd;
|
||||
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
|
||||
}
|
||||
|
|
|
|||
4
web/index.html
vendored
4
web/index.html
vendored
|
|
@ -109,6 +109,10 @@
|
|||
src="https://github.blog/wp-content/uploads/2008/12/forkme_right_gray_6d6d6d.png?resize=149%2C149"
|
||||
class="attachment-full size-full" alt="Fork me on GitHub" data-recalc-dims="1"></a>
|
||||
|
||||
<div id="version">
|
||||
<span id="v"></span>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/gui/gui.js?v=1"></script>
|
||||
<script src="/static/js/utils.js?v1"></script>
|
||||
<script src="/static/js/gui/message.js?v=1"></script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue