Skip to content

Commit

Permalink
feat: ✨ add & display version information
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Jan 1, 2022
1 parent 594eb78 commit 481ff62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ jobs:
- name: Build
run: |
mkdir -p output
export GOOS=darwin && export GOARCH=amd64 && go build -ldflags="-s -w" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=darwin && export GOARCH=arm64 && go build -ldflags="-s -w" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=linux && export GOARCH=386 && go build -ldflags="-s -w" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=linux && export GOARCH=amd64 && go build -ldflags="-s -w" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=linux && export GOARCH=arm && go build -ldflags="-s -w" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=linux && export GOARCH=arm64 && go build -ldflags="-s -w" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=windows && export GOARCH=386 && go build -ldflags="-s -w" -o ./output/snyk-lsp.$GOOS.$GOARCH.exe
export GOOS=windows && export GOARCH=amd64 && go build -ldflags="-s -w" -o ./output/snyk-lsp.$GOOS.$GOARCH.exe
export LDFLAGS="-X 'main.gitinfo=$(echo "$(git show --pretty="tformat:Commit: %h\nDate: %cD\nCommitter: %cn" -s)")' -s -w"
echo "Building with LDFLAGS=$LDFLAGS"
export GOOS=darwin && export GOARCH=amd64 && go build -ldflags="$LDFLAGS" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=darwin && export GOARCH=arm64 && go build -ldflags="$LDFLAGS" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=linux && export GOARCH=386 && go build -ldflags="$LDFLAGS" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=linux && export GOARCH=amd64 && go build -ldflags="$LDFLAGS" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=linux && export GOARCH=arm && go build -ldflags="$LDFLAGS" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=linux && export GOARCH=arm64 && go build -ldflags="$LDFLAGS" -o ./output/snyk-lsp.$GOOS.$GOARCH
export GOOS=windows && export GOARCH=386 && go build -ldflags="$LDFLAGS" -o ./output/snyk-lsp.$GOOS.$GOARCH.exe
export GOOS=windows && export GOARCH=amd64 && go build -ldflags="$LDFLAGS" -o ./output/snyk-lsp.$GOOS.$GOARCH.exe
chmod +x output/*
- name: Test
env:
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import (
"time"
)

var gitinfo string // set by build via go build -ldflags "-X main.gitinfo=xxx"

func main() {
fmt.Println(gitinfo)
output, err := parseFlags(os.Args)
if err != nil {
fmt.Println(err, output)
Expand Down

0 comments on commit 481ff62

Please sign in to comment.