-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (34 loc) · 1.14 KB
/
Copy pathMakefile
File metadata and controls
44 lines (34 loc) · 1.14 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
GO ?= go
DOCKER ?= docker
IMAGE ?= ghcr.io/adityathebe/restic-exporter
TAG ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo latest)
NAME ?= restic-exporter
ifeq ($(VERSION),)
VERSION_TAG=$(shell git describe --abbrev=0 --tags --exact-match 2>/dev/null || echo latest)
else
VERSION_TAG=$(VERSION)
endif
.PHONY: all build docker
all: build
build:
mkdir -p bin
CGO_ENABLED=0 $(GO) build -o bin/restic-exporter ./src
docker:
$(DOCKER) build -t $(IMAGE):$(TAG) .
.PHONY: test
test:
$(GO) test -v ./...
.PHONY: linux
linux:
GOOS=linux GOARCH=amd64 go build -o ./bin/$(NAME)_linux_amd64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" ./src
GOOS=linux GOARCH=arm64 go build -o ./bin/$(NAME)_linux_arm64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" ./src
.PHONY: darwin
darwin:
GOOS=darwin GOARCH=amd64 go build -o ./bin/$(NAME)_darwin_amd64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" ./src
GOOS=darwin GOARCH=arm64 go build -o ./bin/$(NAME)_darwin_arm64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" ./src
.PHONY: binaries
binaries: linux darwin
.PHONY: release
release: binaries
mkdir -p .release
cp bin/restic-exporter* .release/