-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4cb8bf
commit 974ae1b
Showing
4 changed files
with
75 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
VERSION=$(shell git describe --tags `git rev-list --tags --max-count=1`) | ||
BUILD_TIME=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
GITCOMMIT=$(shell git rev-parse HEAD) | ||
|
||
GOVERSION=$(shell go version) | ||
|
||
GO_FLAGS=-ldflags="-X 'main.VERSION=$(VERSION)' -X 'main.BUILDTIME=$(BUILD_TIME)' -X 'main.GITCOMMIT=$(GITCOMMIT)' -X 'main.GOVERSION=$(GOVERSION)' -extldflags -static -s -w" -trimpath | ||
|
||
|
||
BINARY=CodeMerge | ||
DIR=output | ||
|
||
build: | ||
go build ${GO_FLAGS} | ||
|
||
install: | ||
go install ${GO_FLAGS} | ||
|
||
debug: | ||
go clean | ||
# build for linux_amd64 | ||
GOOS=linux GOARCH=amd64 go build -o ${DIR}/${BINARY}_linux_amd64 | ||
# build for linux_arm64 | ||
GOOS=linux GOARCH=arm64 go build -o ${DIR}/${BINARY}_linux_arm64 | ||
# build for windows_amd64 | ||
GOOS=windows GOARCH=amd64 go build -o ${DIR}/${BINARY}_windows_amd64.exe | ||
# build for windows_arm64 | ||
GOOS=windows GOARCH=arm64 go build -o ${DIR}/${BINARY}_windows_arm64.exe | ||
# build for darwin_amd64 | ||
GOOS=darwin GOARCH=amd64 go build -o ${DIR}/${BINARY}_darwin_amd64 | ||
# build for darwin_arm64 | ||
GOOS=darwin GOARCH=arm64 go build -o ${DIR}/${BINARY}_darwin_arm64 | ||
|
||
release: | ||
go clean | ||
CGO_ENABLED=0 | ||
|
||
# build for linux_amd64 | ||
GOOS=linux GOARCH=amd64 go build ${GO_FLAGS} -o ${DIR}/${BINARY}_linux_amd64 | ||
# build for linux_arm64 | ||
GOOS=linux GOARCH=arm64 go build ${GO_FLAGS} -o ${DIR}/${BINARY}_linux_arm64 | ||
# build for windows_amd64 | ||
GOOS=windows GOARCH=amd64 go build ${GO_FLAGS} -o ${DIR}/${BINARY}_windows_amd64.exe | ||
# build for windows_arm64 | ||
GOOS=windows GOARCH=arm64 go build ${GO_FLAGS} -o ${DIR}/${BINARY}_windows_arm64.exe | ||
# build for darwin_amd64 | ||
GOOS=darwin GOARCH=amd64 go build ${GO_FLAGS} -o ${DIR}/${BINARY}_darwin_amd64 | ||
# build for darwin_arm64 | ||
GOOS=darwin GOARCH=arm64 go build ${GO_FLAGS} -o ${DIR}/${BINARY}_darwin_arm64 | ||
|
||
clean: | ||
go clean | ||
|
||
.PHONY: clean build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
var VERSION = "DEV-1.0" | ||
var GOVERSION = "UNKNOWN" | ||
var GITCOMMIT = "UNKNOWN*" | ||
var BUILDTIME = "UNKNOWN" | ||
|
||
func version() string { | ||
return fmt.Sprintf(`CodeMerge %s | ||
Git commit: %s, | ||
Build with %s | ||
Build at %s`, VERSION, GITCOMMIT, GOVERSION, BUILDTIME) | ||
} | ||
|
||
func ShowVersion(showVersion *bool) { | ||
if *showVersion { | ||
fmt.Println(version()) | ||
os.Exit(0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters