-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
29 lines (24 loc) · 793 Bytes
/
Makefile
File metadata and controls
29 lines (24 loc) · 793 Bytes
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
# Variables
PACKAGE := github.com/ffais/yaml-sort
VERSION := $(shell git describe --tags --always --abbrev=0 --match='v[0-9]*.[0-9]*.[0-9]*' 2> /dev/null | sed 's/^.//')
COMMIT_HASH := $(shell git rev-parse --short HEAD)
BUILD_TIMESTAMP := $(shell date '+%Y-%m-%dT%H:%M:%S')
# LDFLAGS construction
LDFLAGS := -X '$(PACKAGE)/cmd.version=$(VERSION)' \
-X '$(PACKAGE)/cmd.commitHash=$(COMMIT_HASH)' \
-X '$(PACKAGE)/cmd.buildTimestamp=$(BUILD_TIMESTAMP)'
.PHONY: build
build:
@echo "Building yaml-sort..."
go build -ldflags="$(LDFLAGS)"
.PHONY: version
version:
@echo "Version: $(VERSION)"
@echo "Commit Hash: $(COMMIT_HASH)"
@echo "Build Time: $(BUILD_TIMESTAMP)"
.PHONY: clean
clean:
@echo "Cleaning..."
rm -f yaml-sort
# Default target
.DEFAULT_GOAL := build