forked from smallstep/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (89 loc) · 3.52 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
105
106
107
108
109
110
111
all: lint test build
ci: test build
.PHONY: all ci
#################################################
# Determine the type of `push` and `version`
#################################################
# If TRAVIS_TAG is set then we know this ref has been tagged.
ifdef TRAVIS_TAG
VERSION ?= $(TRAVIS_TAG)
NOT_RC := $(shell echo $(VERSION) | grep -v -e -rc)
ifeq ($(NOT_RC),)
PUSHTYPE := release-candidate
else
PUSHTYPE := release
endif
# GITHUB Actions
else ifdef GITHUB_REF
VERSION ?= $(shell echo $(GITHUB_REF) | sed 's/^refs\/tags\///')
NOT_RC := $(shell echo $(VERSION) | grep -v -e -rc)
ifeq ($(NOT_RC),)
PUSHTYPE := release-candidate
else
PUSHTYPE := release
endif
else
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))
ifeq ($(TRAVIS_BRANCH),master)
PUSHTYPE := master
else
PUSHTYPE := branch
endif
endif
VERSION := $(shell echo $(VERSION) | sed 's/^v//')
ifdef V
$(info TRAVIS_TAG is $(TRAVIS_TAG))
$(info GITHUB_REF is $(GITHUB_REF))
$(info VERSION is $(VERSION))
$(info PUSHTYPE is $(PUSHTYPE))
endif
include make/common.mk
#################################################
# Build statically compiled step binary for various operating systems
#################################################
BINARY_OUTPUT=$(OUTPUT_ROOT)binary/
RELEASE=./.releases
define BUNDLE_MAKE
# $(1) -- Go Operating System (e.g. linux, darwin, windows, etc.)
# $(2) -- Go Architecture (e.g. amd64, arm, arm64, etc.)
# $(3) -- Go ARM architectural family (e.g. 7, 8, etc.)
# $(4) -- Parent directory for executables generated by 'make'.
$(q) GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2) GOARM=$(3)' PREFIX=$(4) make $(4)bin/step
endef
binary-linux-amd64:
$(call BUNDLE_MAKE,linux,amd64,,$(BINARY_OUTPUT)linux-amd64/)
binary-linux-arm64:
$(call BUNDLE_MAKE,linux,arm64,,$(BINARY_OUTPUT)linux-arm64/)
binary-linux-armv7:
$(call BUNDLE_MAKE,linux,arm,7,$(BINARY_OUTPUT)linux-armv7/)
binary-linux-mips:
$(call BUNDLE_MAKE,linux,mips,,$(BINARY_OUTPUT)linux-mips/)
binary-darwin-amd64:
$(call BUNDLE_MAKE,darwin,amd64,,$(BINARY_OUTPUT)darwin-amd64/)
binary-darwin-arm64:
$(call BUNDLE_MAKE,darwin,amd64,,$(BINARY_OUTPUT)darwin-arm64/)
binary-windows-amd64:
$(call BUNDLE_MAKE,windows,amd64,,$(BINARY_OUTPUT)windows-amd64/)
define BUNDLE
# $(1) -- Format output as .ZIP archive, rather than .tar.gzip (for older windows architecture)
# $(2) -- Binary Output Dir Name
# $(3) -- Step Platform Name
# $(4) -- Step Binary Architecture
# $(5) -- Step Binary Name (For Windows Compatibility)
$(q) ./make/bundle.sh $(1) "$(BINARY_OUTPUT)$(2)" "$(RELEASE)" "$(VERSION)" "$(3)" "$(4)" "$(5)"
endef
bundle-linux: binary-linux-amd64 binary-linux-arm64 binary-linux-armv7 binary-linux-mips
$(call BUNDLE,,linux-amd64,linux,amd64,step)
$(call BUNDLE,,linux-arm64,linux,arm64,step)
$(call BUNDLE,,linux-armv7,linux,armv7,step)
$(call BUNDLE,,linux-mips,linux,mips,step)
bundle-darwin: binary-darwin-amd64 binary-darwin-arm64
$(call BUNDLE,,darwin-amd64,darwin,amd64,step)
$(call BUNDLE,,darwin-arm64,darwin,arm64,step)
bundle-windows: binary-windows-amd64
$(call BUNDLE,,windows-amd64,windows,amd64,step.exe)
$(call BUNDLE,--zip,windows-amd64,windows,amd64,step.exe)
.PHONY: binary-linux-amd64 binary-linux-arm64 binary-linux-armv7 binary-linux-mips binary-darwin-amd64 binary-darwin-arm64 binary-windows-amd64 bundle-linux bundle-darwin bundle-windows