-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
56 lines (46 loc) · 1.32 KB
/
Makefile
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
.PHONY: clean test clean-all docker
SYSTEM:=$(shell uname)
META_PACKAGE_IMPORT_PATH := $(shell go list -f '{{ .ImportPath }}' ./meta)
GO_SOURCES :=$(shell go list -f '{{ range $$element := .GoFiles }}{{ $$.Dir }}/{{ $$element }}{{ "\n" }}{{ end }}' ./...)
VERSION :=$(shell git describe --tags --always | sed 's/^v//')
ifeq ($(SYSTEM), Darwin)
BUILD_DATE :=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
else
BUILD_DATE :=$(shell date --iso-8601=seconds --utc)
endif
GO_FLAGS :=-ldflags="-X $(META_PACKAGE_IMPORT_PATH).Version=$(VERSION) -X $(META_PACKAGE_IMPORT_PATH).BuildTime=$(BUILD_DATE)"
all: f3
f3: $(GO_SOURCES)
@touch meta/meta.go
@CGO_ENABLED=0 go build $(GO_FLAGS) ./cmd/f3
test: $(GO_SOURCES)
@go test ./...
install: f3
ifeq ($$EUID, 0)
@install -m 0755 -v f3 /usr/local/bin
else
@go install ./cmd/f3
endif
deb: f3 test
mkdir -p deb/usr/sbin
cp f3 deb/usr/sbin
fpm --force\
--input-type dir\
--output-type deb\
--version $(VERSION)\
--name f3-server\
--architecture amd64\
--prefix /\
--description 'An FTP to AWS s3 bridge'\
--url "$(NAMESPACE)"\
--no-deb-systemd-restart-after-upgrade\
--chdir deb
docker: Dockerfile f3
docker build -t spreadshirt/f3:$(VERSION) .
docker-push: docker
docker login docker.io
docker push spreadshirt/f3:$(VERSION)
clean:
rm -f f3
clean-all: clean
rm -f f3-server_*.deb