From 169575e574263d1b3c66bc897810309f85dd6e5d Mon Sep 17 00:00:00 2001 From: Taras Kushnir Date: Wed, 28 Aug 2024 08:26:21 +0300 Subject: [PATCH] Update build steps --- .github/workflows/go.yml | 6 ++++-- .gitignore | 1 + Makefile | 5 ++--- main.go | 5 +++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 942da0d..470e5b4 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -24,6 +24,8 @@ jobs: - uses: actions/checkout@v3 - name: Build + env: + GIT_COMMIT: "${{ github.sha }}" run: | - go get -d -v - go build -v . + make vendors + make build diff --git a/.gitignore b/.gitignore index 1377554..8e434fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +bin/ diff --git a/Makefile b/Makefile index 07dd952..81138f8 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,10 @@ GIT_COMMIT ?= $(shell git rev-list -1 HEAD) build: - export GOFLAGS="-mod=vendor" - go build + env GOFLAGS="-mod=vendor" CGO_ENABLED=0 go build -ldflags="-s -w -X main.GitCommit=$(GIT_COMMIT)" -o bin/github-tdg *.go test: - go test ./... + env GOFLAGS="-mod=vendor" CGO_ENABLED=0 go test ./... vendors: go mod tidy diff --git a/main.go b/main.go index 0aa20e9..f918e0d 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,10 @@ import ( "golang.org/x/oauth2" ) +var ( + GitCommit string +) + const ( defaultMinWords = 3 defaultMinChars = 30 @@ -533,6 +537,7 @@ func appendGitHubActionOutput() { func main() { log.SetOutput(os.Stdout) + log.Printf("Starting. version=%v", GitCommit) env := environment() ctx := context.Background()