This repository has been archived by the owner on Jan 24, 2020. It is now read-only.
forked from smallstep/cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
104 lines (76 loc) · 3.2 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
all: build lint test
.PHONY: all
# Version flags to embed in the binaries
VERSION ?= $(shell [ -d .git ] && git describe --tags --always --dirty="-dev")
# If we are not in an active git dir then try reading the version from .VERSION.
# .VERSION contains a slug populated by `git archive`.
VERSION := $(or $(VERSION),$(shell ./.version.sh .VERSION))
-include make/common.mk
-include make/docker.mk
#########################################
# Debian
#########################################
changelog:
$Q echo "step-cli ($(VERSION)) unstable; urgency=medium" > debian/changelog
$Q echo >> debian/changelog
$Q echo " * See https://github.com/smallstep/cli/releases" >> debian/changelog
$Q echo >> debian/changelog
$Q echo " -- Smallstep Labs, Inc. <techadmin@smallstep.com> $(shell date -uR)" >> debian/changelog
debian: changelog
$Q set -e; mkdir -p $(RELEASE); \
OUTPUT=../step-cli_*.deb; \
rm -f $$OUTPUT; \
dpkg-buildpackage -b -rfakeroot -us -uc && cp $$OUTPUT $(RELEASE)/
distclean: clean
.PHONY: changelog debian distclean
#################################################
# Build statically compiled step binary for various operating systems
#################################################
BINARY_OUTPUT=$(OUTPUT_ROOT)binary/
BUNDLE_MAKE=v=$v GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2)' PREFIX=$(3) make $(3)bin/step
RELEASE=./.travis-releases
binary-linux:
$(call BUNDLE_MAKE,linux,amd64,$(BINARY_OUTPUT)linux/)
binary-darwin:
$(call BUNDLE_MAKE,darwin,amd64,$(BINARY_OUTPUT)darwin/)
define BUNDLE
$(q)set -e; BUNDLE_DIR=$(BINARY_OUTPUT)$(1)/bundle; \
stepName=step_$(2); \
mkdir -p $$BUNDLE_DIR $(RELEASE); \
TMP=$$(mktemp -d $$BUNDLE_DIR/tmp.XXXX); \
trap "rm -rf $$TMP" EXIT INT QUIT TERM; \
newdir=$$TMP/$$stepName; \
mkdir -p $$newdir/bin; \
cp $(BINARY_OUTPUT)$(1)/bin/step $$newdir/bin/; \
cp README.md $$newdir/; \
NEW_BUNDLE=$(RELEASE)/step_$(2)_$(1)_$(3).tar.gz; \
rm -f $$NEW_BUNDLE; \
tar -zcvf $$NEW_BUNDLE -C $$TMP $$stepName;
endef
bundle-linux: binary-linux
$(call BUNDLE,linux,$(VERSION),amd64)
bundle-darwin: binary-darwin
$(call BUNDLE,darwin,$(VERSION),amd64)
.PHONY: binary-linux binary-darwin bundle-linux bundle-darwin
#################################################
# Targets for creating OS specific artifacts and archives
#################################################
artifacts-linux-tag: bundle-linux debian
artifacts-darwin-tag: bundle-darwin
artifacts-archive-tag:
$Q mkdir -p $(RELEASE)
$Q git archive v$(VERSION) | gzip > $(RELEASE)/step-cli_$(VERSION).tar.gz
artifacts-tag: artifacts-linux-tag artifacts-darwin-tag artifacts-archive-tag
.PHONY: artifacts-linux-tag artifacts-darwin-tag artifacts-archive-tag artifacts-tag
#################################################
# Targets for creating step artifacts
#################################################
# For all builds that are not tagged
artifacts-master:
# For all builds with a release candidate tag
artifacts-release-candidate: artifacts-tag
# For all builds with a release tag
artifacts-release: artifacts-tag
# This command is called by travis directly *after* a successful build
artifacts: artifacts-$(PUSHTYPE) docker-$(PUSHTYPE)
.PHONY: artifacts-master artifacts-release-candidate artifacts-release artifacts