Skip to content

Commit c927f5d

Browse files
Build Debug Version of Binary in Github Action (#335)
* can build symbol table with KEEP_SYMBOL=1 env * build debug version in github action
1 parent 923b6ee commit c927f5d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

.github/workflows/dockerimage.yml

+9
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ jobs:
2222
password: ${{ secrets.DOCKER_PASSWORD }}
2323
tag_with_ref: true
2424
tag_with_sha: false
25+
26+
- name: "[debug version] build and push"
27+
uses: docker/build-push-action@v1
28+
with:
29+
build_args: KEEP_SYMBOL=1
30+
repository: projecteru2/core
31+
username: ${{ secrets.DOCKER_USERNAME }}
32+
password: ${{ secrets.DOCKER_PASSWORD }}
33+
tag: ${{ github.sha }}-debug

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ FROM golang:alpine AS BUILD
44
RUN apk add --no-cache build-base musl-dev git curl make cmake
55
RUN git clone https://github.com/projecteru2/core.git /go/src/github.com/projecteru2/core
66
WORKDIR /go/src/github.com/projecteru2/core
7+
ARG KEEP_SYMBOL
78
RUN make build && ./eru-core --version
89

910
FROM alpine:latest

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ REPO_PATH := github.com/projecteru2/core
44
REVISION := $(shell git rev-parse HEAD || unknown)
55
BUILTAT := $(shell date +%Y-%m-%dT%H:%M:%S)
66
VERSION := $(shell git describe --tags $(shell git rev-list --tags --max-count=1))
7-
GO_LDFLAGS ?= -s -X $(REPO_PATH)/version.REVISION=$(REVISION) \
7+
GO_LDFLAGS ?= -X $(REPO_PATH)/version.REVISION=$(REVISION) \
88
-X $(REPO_PATH)/version.BUILTAT=$(BUILTAT) \
99
-X $(REPO_PATH)/version.VERSION=$(VERSION)
10+
ifneq ($(KEEP_SYMBOL), 1)
11+
GO_LDFLAGS += -s
12+
endif
1013

1114
grpc:
1215
protoc --proto_path=./rpc/gen --go_out=plugins=grpc:./rpc/gen --go_opt=module=github.com/projecteru2/core/rpc/gen core.proto

0 commit comments

Comments
 (0)