forked from kvinwang/dstack-mr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (65 loc) · 2.27 KB
/
Makefile
File metadata and controls
79 lines (65 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
.PHONY: build install clean test fmt vet tidy run check help
.PHONY: release release-snapshot release-dry-run
.DEFAULT_GOAL := help
# Variables
BINARY_NAME=dstack-mr-gcp
BUILD_DIR=build
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.Commit=$(COMMIT) -w -s"
## help: Display this help message
help:
@echo "Available targets:"
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/^## / /'
## build: Build the binary into build/
build:
@echo "Building $(BINARY_NAME) into $(BUILD_DIR)/..."
@mkdir -p $(BUILD_DIR)
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) .
## install: Install the binary to $GOPATH/bin
install:
@echo "Installing $(BINARY_NAME)..."
go install $(LDFLAGS) .
## clean: Remove build artifacts
clean:
@echo "Cleaning..."
rm -f $(BUILD_DIR)/$(BINARY_NAME)
rm -rf dist/
## test: Run tests
test:
@echo "Running tests..."
go test -v ./...
## fmt: Format code
fmt:
@echo "Formatting code..."
go fmt ./...
## vet: Run go vet
vet:
@echo "Running go vet..."
go vet ./...
## tidy: Tidy go modules
tidy:
@echo "Tidying go modules..."
go mod tidy
## run: Build and run the binary
run: build
$(BUILD_DIR)/$(BINARY_NAME)
## check: Run fmt, vet, and test
check: fmt vet test
@echo "All checks passed!"
## release: Create a release with GoReleaser (requires GITHUB_TOKEN)
release:
@echo "Creating release with GoReleaser..."
@which goreleaser > /dev/null || (echo "goreleaser not found. Install from https://goreleaser.com/install/" && exit 1)
@test -n "$(GITHUB_TOKEN)" || (echo "GITHUB_TOKEN is not set" && exit 1)
goreleaser release --clean
## release-snapshot: Create a snapshot release (no git tag required, no GitHub upload)
release-snapshot:
@echo "Creating snapshot release with GoReleaser..."
@which goreleaser > /dev/null || (echo "goreleaser not found. Install from https://goreleaser.com/install/" && exit 1)
goreleaser release --snapshot --clean
## release-dry-run: Dry run of the release process
release-dry-run:
@echo "Dry run of release process..."
@which goreleaser > /dev/null || (echo "goreleaser not found. Install from https://goreleaser.com/install/" && exit 1)
goreleaser release --skip=publish --clean