-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
60 lines (55 loc) · 2.21 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
57
58
59
60
OUTPUT_DIR?=/usr/local/bin
PACKAGE_NAME := github.com/turbot/tailpipe
GOLANG_CROSS_VERSION ?= v1.23.2
# sed 's/[\/_]/-/g': Replaces both slashes (/) and underscores (_) with hyphens (-).
# sed 's/[^a-zA-Z0-9.-]//g': Removes any character that isn’t alphanumeric, a dot (.), or a hyphen (-).
# This is to ensure that the branch name is a valid semver pre-release identifier.
.PHONY: build
build:
$(eval TIMESTAMP := $(shell date +%Y%m%d%H%M%S))
$(eval GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/[\/_]/-/g' | sed 's/[^a-zA-Z0-9.-]//g'))
go build -o $(OUTPUT_DIR) -ldflags "-X main.version=0.0.0-dev-$(GIT_BRANCH).$(TIMESTAMP)" .
.PHONY: release-dry-run
release-dry-run:
@docker run \
--rm \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/tailpipe \
-v `pwd`/../pipe-fittings:/go/src/pipe-fittings \
-v `pwd`/../tailpipe-plugin-sdk:/go/src/tailpipe-plugin-sdk \
-v `pwd`/../tailpipe-plugin-core:/go/src/tailpipe-plugin-core \
-w /go/src/tailpipe \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip=validate --skip=publish --snapshot
.PHONY: release-acceptance
release-acceptance:
@docker run \
--rm \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/tailpipe \
-v `pwd`/../pipe-fittings:/go/src/pipe-fittings \
-v `pwd`/../tailpipe-plugin-sdk:/go/src/tailpipe-plugin-sdk \
-v `pwd`/../tailpipe-plugin-core:/go/src/tailpipe-plugin-core \
-w /go/src/tailpipe \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip=validate --skip=publish --snapshot --config=.acceptance.goreleaser.yml
.PHONY: release
release:
@if [ ! -f ".release-env" ]; then \
echo ".release-env is required for release";\
exit 1;\
fi
docker run \
--rm \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/tailpipe \
-v `pwd`/../pipe-fittings:/go/src/pipe-fittings \
-v `pwd`/../tailpipe-plugin-sdk:/go/src/tailpipe-plugin-sdk \
-v `pwd`/../tailpipe-plugin-core:/go/src/tailpipe-plugin-core \
-w /go/src/tailpipe \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean --skip=validate