Staffan Olsson 1240617bb1 updated protobuilder.yaml | 10 months ago | |
---|---|---|
example | 2 years ago | |
proto | 10 months ago | |
scripts | 1 year ago | |
.gitignore | 2 years ago | |
LICENSE | 2 years ago | |
README.md | 2 years ago | |
client.go | 2 years ago | |
env.pb.go | 10 months ago | |
env_grpc.pb.go | 1 year ago | |
environ.go | 2 years ago | |
go.mod | 2 years ago | |
go.sum | 2 years ago | |
protobuilder.yaml | 10 months ago | |
server.go | 2 years ago |
A simple lib to retrieve build time environment for client and server.
go get -u git.skogstorpet.nu/staffan/environ
The server should implement the EnvironmentSvc service. Given a grpc connection to the server, the client should be able to fetch the environment from the server.
To build an enviorn aware executable, build using these build settings:
# Version of program could be set by a git tag.
export VERSION=$(git describe --tags)
export GIT_COMMIT=$(git rev-list -1 HEAD --abbrev-commit)
export BUILD_TIME="$(date +%FT%T)"
export GO_OS_ARCH="$(go env GOOS)/$(go env GOARCH)"
export API_VERSION=$(cat $PROJ_ROOT/api.version)
echo "Version: $VERSION"
echo "GIT_COMMIT: $GIT_COMMIT"
echo "BUILD_TIME: $BUILD_TIME"
echo "GO_OS_ARCH: $GO_OS_ARCH"
echo "API_VERSION: $API_VERSION"
export LD_FLAGS="-X git.skogstorpet.nu/staffan/environ.GitCommit=$GIT_COMMIT \
-X git.skogstorpet.nu/staffan/environ.BuildTime=$BUILD_TIME \
-X git.skogstorpet.nu/staffan/environ.GoOsArch=$GO_OS_ARCH \
-X git.skogstorpet.nu/staffan/environ.Version=$VERSION \
-X git.skogstorpet.nu/staffan/environ.APIVersion=$API_VERSION"
# Build CLI
go build -ldflags "$LD_FLAGS" /your/path/to/client_main.go
# Build server
go build -ldflags "$LD_FLAGS" /your/path/to/server_main.go