feta/Makefile

50 lines
1.2 KiB
Makefile
Raw Normal View History

2019-10-24 10:38:16 +00:00
VERSION := $(shell git rev-parse --short HEAD)
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
2019-10-24 15:23:29 +00:00
BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ')
BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S')
2019-10-24 10:38:16 +00:00
BUILDUSER := $(shell whoami)
BUILDHOST := $(shell hostname -s)
BUILDARCH := $(shell uname -m)
2019-10-24 15:23:29 +00:00
FN := fediverse-archive
IMAGENAME := sneak/$(FN)
2019-10-24 10:38:16 +00:00
GOLDFLAGS += -X main.Version=$(VERSION)
GOLDFLAGS += -X main.Buildtime=$(BUILDTIME)
GOLDFLAGS += -X main.Builduser=$(BUILDUSER)@$(BUILDHOST)
GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
GOFLAGS = -ldflags "$(GOLDFLAGS)"
default: rundebug
rundebug: build
2019-10-24 15:23:29 +00:00
./$(FN) -debug
2019-10-24 10:38:16 +00:00
run: build
2019-10-24 15:23:29 +00:00
./$(FN)
2019-10-24 10:38:16 +00:00
2019-10-24 15:23:29 +00:00
build: ./$(FN)
2019-10-24 10:38:16 +00:00
2019-10-24 15:23:29 +00:00
./$(FN): *.go
2019-10-24 10:38:16 +00:00
go build -o $@ $(GOFLAGS) .
fmt:
go fmt *.go
2019-10-24 15:23:29 +00:00
test: build-docker-image
build-docker-image:
docker build -t $(IMAGENAME):$(VERSION) -t $(IMAGENAME):latest -t $(IMAGENAME):$(BUILDTIMETAG) .
2019-10-24 15:23:29 +00:00
dist: build-docker-image
-mkdir -p ./output
docker run --rm --entrypoint cat $(IMAGENAME) /bin/$(FN) > output/$(FN)
docker save $(IMAGENAME) | bzip2 > output/$(BUILDTIMEFILENAME).$(FN).tbz2
hub: upload-docker-image
upload-docker-image: build-docker-image
docker push $(IMAGENAME):$(VERSION)
docker push $(IMAGENAME):$(BUILDTIMETAG)
docker push $(IMAGENAME):latest