File tree Expand file tree Collapse file tree 3 files changed +26
-31
lines changed
Expand file tree Collapse file tree 3 files changed +26
-31
lines changed Original file line number Diff line number Diff line change 1313 fetch-depth : 0 # Needed for git history
1414 - name : Set up Go
1515 uses : actions/setup-go@v4
16- - name : Set version info
17- id : version
18- run : |
19- VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "development")
20- COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
21- BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
22- echo "VERSION=${VERSION}" >> $GITHUB_ENV
23- echo "COMMIT=${COMMIT}" >> $GITHUB_ENV
24- echo "BUILD_TIME=${BUILD_TIME}" >> $GITHUB_ENV
25- echo "LDFLAGS=-X 'codacy/cli-v2/version.Version=${VERSION}' -X 'codacy/cli-v2/version.GitCommit=${COMMIT}' -X 'codacy/cli-v2/version.BuildTime=${BUILD_TIME}'" >> $GITHUB_ENV
26- - name : Build CLI for Linux
27- run : |
28- GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o cli-v2-linux ./cli-v2.go
29- - name : Build CLI for Windows
30- run : |
31- GOOS=windows GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o cli-v2.exe ./cli-v2.go
32- - name : Build CLI for macOS
33- run : |
34- GOOS=darwin GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o cli-v2-macos ./cli-v2.go
16+ - name : Build CLI for all platforms
17+ run : make build-all
3518 - name : Upload CLI binaries
3619 uses : actions/upload-artifact@v4
3720 with :
5033 uses : actions/setup-go@v4
5134 - name : Install dependencies from .codacy/codacy.yaml
5235 run : |
53- go build ./cli-v2.go
36+ make build
5437 ./cli-v2 install
5538 - name : " Run tests"
5639 run : |
Original file line number Diff line number Diff line change 1616 steps :
1717 - name : Checkout code
1818 uses : actions/checkout@v4
19+ with :
20+ fetch-depth : 0 # Needed for git history
1921
2022 - name : Set up Go
2123 uses : actions/setup-go@v5
4648 if : matrix.os != 'windows-latest'
4749 run : chmod +x cli-v2
4850
49-
5051 - name : Run tool tests
5152 if : matrix.os != 'windows-latest'
5253 id : run_tests
Original file line number Diff line number Diff line change 1- .PHONY : build clean
1+ .PHONY : build clean build-all build-linux build-darwin build-windows
22
33# Get the version from git describe or fallback to a default version
44VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "development")
55COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
66BUILD_TIME := $(shell date -u '+% Y-% m-% d_% H:% M:% S')
77
88# Build flags
9- LDFLAGS := -X 'codacy/cli-v2/version.Version=$(VERSION ) ' -X 'codacy/cli-v2/version.GitCommit=$(COMMIT ) ' -X 'codacy/cli-v2/version.BuildTime=$(BUILD_TIME ) '
9+ LDFLAGS := -X 'codacy/cli-v2/version.Version=$(VERSION ) ' \
10+ -X 'codacy/cli-v2/version.GitCommit=$(COMMIT ) ' \
11+ -X 'codacy/cli-v2/version.BuildTime=$(BUILD_TIME ) '
1012
11- # Build the CLI
13+ # Build the CLI for current platform
1214build :
1315 go build -ldflags " $( LDFLAGS) " -o cli-v2
1416
15- # Clean build artifacts
16- clean :
17- rm -f cli-v2
17+ # Build for Linux
18+ build-linux :
19+ GOOS=linux GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o cli-v2-linux
20+
21+ # Build for macOS
22+ build-darwin :
23+ GOOS=darwin GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o cli-v2-macos
24+
25+ # Build for Windows
26+ build-windows :
27+ GOOS=windows GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o cli-v2.exe
1828
1929# Build for all platforms
20- build-all : clean
21- GOOS=linux GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o cli-v2_linux_amd64
22- GOOS=darwin GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o cli-v2_darwin_amd64
23- GOOS=windows GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o cli-v2_windows_amd64.exe
30+ build-all : build-linux build-darwin build-windows
31+
32+ # Clean build artifacts
33+ clean :
34+ rm -f cli-v2 cli-v2-linux cli-v2-macos cli-v2.exe
You can’t perform that action at this time.
0 commit comments