2018-11-01 04:36:01 +00:00
|
|
|
PKG?=github.com/smallstep/certificates/cmd/step-ca
|
2018-10-05 21:48:36 +00:00
|
|
|
BINNAME?=step-ca
|
2020-02-19 03:07:12 +00:00
|
|
|
CLOUDKMS_BINNAME?=step-cloudkms-init
|
|
|
|
CLOUDKMS_PKG?=github.com/smallstep/certificates/cmd/step-cloudkms-init
|
2020-05-20 00:35:58 +00:00
|
|
|
AWSKMS_BINNAME?=step-awskms-init
|
|
|
|
AWSKMS_PKG?=github.com/smallstep/certificates/cmd/step-awskms-init
|
2020-05-08 01:40:36 +00:00
|
|
|
YUBIKEY_BINNAME?=step-yubikey-init
|
|
|
|
YUBIKEY_PKG?=github.com/smallstep/certificates/cmd/step-yubikey-init
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
# Set V to 1 for verbose output from the Makefile
|
|
|
|
Q=$(if $V,,@)
|
|
|
|
PREFIX?=
|
|
|
|
SRC=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
|
|
|
GOOS_OVERRIDE ?=
|
2018-11-15 01:53:17 +00:00
|
|
|
OUTPUT_ROOT=output/
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2020-07-21 01:57:19 +00:00
|
|
|
all: lint test build
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Bootstrapping
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
bootstra%:
|
2020-01-11 01:19:56 +00:00
|
|
|
# Using a released version of golangci-lint to take into account custom replacements in their go.mod
|
2020-04-21 16:59:54 +00:00
|
|
|
$Q GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.24.0
|
2019-08-27 23:39:48 +00:00
|
|
|
|
2019-10-22 01:45:55 +00:00
|
|
|
.PHONY: bootstra%
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
#################################################
|
|
|
|
# Determine the type of `push` and `version`
|
|
|
|
#################################################
|
|
|
|
|
|
|
|
# If TRAVIS_TAG is set then we know this ref has been tagged.
|
|
|
|
ifdef TRAVIS_TAG
|
2020-04-10 03:36:54 +00:00
|
|
|
VERSION := $(TRAVIS_TAG)
|
|
|
|
NOT_RC := $(shell echo $(VERSION) | grep -v -e -rc)
|
2019-03-27 18:35:17 +00:00
|
|
|
ifeq ($(NOT_RC),)
|
2020-04-10 03:36:54 +00:00
|
|
|
PUSHTYPE := release-candidate
|
2019-03-27 18:35:17 +00:00
|
|
|
else
|
2020-04-10 03:36:54 +00:00
|
|
|
PUSHTYPE := release
|
2019-03-27 18:35:17 +00:00
|
|
|
endif
|
2018-10-05 21:48:36 +00:00
|
|
|
else
|
2020-04-10 03:36:54 +00:00
|
|
|
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))
|
2020-08-02 20:25:21 +00:00
|
|
|
ifeq ($(TRAVIS_BRANCH),master)
|
2020-04-10 03:36:54 +00:00
|
|
|
PUSHTYPE := master
|
2020-08-02 20:25:21 +00:00
|
|
|
else
|
|
|
|
PUSHTYPE := branch
|
|
|
|
endif
|
2020-04-10 03:36:54 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
VERSION := $(shell echo $(VERSION) | sed 's/^v//')
|
2020-08-03 16:23:29 +00:00
|
|
|
DEB_VERSION := $(shell echo $(VERSION) | sed 's/-/~/g')
|
2020-04-10 03:36:54 +00:00
|
|
|
|
|
|
|
ifdef V
|
|
|
|
$(info TRAVIS_TAG is $(TRAVIS_TAG))
|
|
|
|
$(info VERSION is $(VERSION))
|
2020-08-03 16:23:29 +00:00
|
|
|
$(info DEB_VERSION is $(DEB_VERSION))
|
2020-04-10 03:36:54 +00:00
|
|
|
$(info PUSHTYPE is $(PUSHTYPE))
|
2018-10-05 21:48:36 +00:00
|
|
|
endif
|
|
|
|
|
2020-08-02 20:25:21 +00:00
|
|
|
include make/docker.mk
|
|
|
|
|
2018-10-05 21:48:36 +00:00
|
|
|
#########################################
|
|
|
|
# Build
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
DATE := $(shell date -u '+%Y-%m-%d %H:%M UTC')
|
|
|
|
LDFLAGS := -ldflags='-w -X "main.Version=$(VERSION)" -X "main.BuildTime=$(DATE)"'
|
|
|
|
GOFLAGS := CGO_ENABLED=0
|
|
|
|
|
2019-10-22 01:52:01 +00:00
|
|
|
download:
|
|
|
|
$Q go mod download
|
|
|
|
|
2020-05-20 00:35:58 +00:00
|
|
|
build: $(PREFIX)bin/$(BINNAME) $(PREFIX)bin/$(CLOUDKMS_BINNAME) $(PREFIX)bin/$(AWSKMS_BINNAME) $(PREFIX)bin/$(YUBIKEY_BINNAME)
|
2018-10-05 21:48:36 +00:00
|
|
|
@echo "Build Complete!"
|
|
|
|
|
2019-10-22 01:52:01 +00:00
|
|
|
$(PREFIX)bin/$(BINNAME): download $(call rwildcard,*.go)
|
2018-10-05 21:48:36 +00:00
|
|
|
$Q mkdir -p $(@D)
|
|
|
|
$Q $(GOOS_OVERRIDE) $(GOFLAGS) go build -v -o $(PREFIX)bin/$(BINNAME) $(LDFLAGS) $(PKG)
|
|
|
|
|
2020-02-19 03:07:12 +00:00
|
|
|
$(PREFIX)bin/$(CLOUDKMS_BINNAME): download $(call rwildcard,*.go)
|
|
|
|
$Q mkdir -p $(@D)
|
|
|
|
$Q $(GOOS_OVERRIDE) $(GOFLAGS) go build -v -o $(PREFIX)bin/$(CLOUDKMS_BINNAME) $(LDFLAGS) $(CLOUDKMS_PKG)
|
|
|
|
|
2020-05-20 00:35:58 +00:00
|
|
|
$(PREFIX)bin/$(AWSKMS_BINNAME): download $(call rwildcard,*.go)
|
|
|
|
$Q mkdir -p $(@D)
|
|
|
|
$Q $(GOOS_OVERRIDE) $(GOFLAGS) go build -v -o $(PREFIX)bin/$(AWSKMS_BINNAME) $(LDFLAGS) $(AWSKMS_PKG)
|
|
|
|
|
2020-05-08 01:40:36 +00:00
|
|
|
$(PREFIX)bin/$(YUBIKEY_BINNAME): download $(call rwildcard,*.go)
|
|
|
|
$Q mkdir -p $(@D)
|
|
|
|
$Q $(GOOS_OVERRIDE) $(GOFLAGS) go build -v -o $(PREFIX)bin/$(YUBIKEY_BINNAME) $(LDFLAGS) $(YUBIKEY_PKG)
|
|
|
|
|
2019-10-22 01:45:55 +00:00
|
|
|
# Target to force a build of step-ca without running tests
|
2020-05-08 01:40:36 +00:00
|
|
|
simple: build
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2019-10-22 01:52:01 +00:00
|
|
|
.PHONY: download build simple
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Go generate
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
generate:
|
|
|
|
$Q go generate ./...
|
|
|
|
|
|
|
|
.PHONY: generate
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Test
|
|
|
|
#########################################
|
|
|
|
test:
|
2018-11-03 06:19:56 +00:00
|
|
|
$Q $(GOFLAGS) go test -short -coverprofile=coverage.out ./...
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2019-09-17 06:04:34 +00:00
|
|
|
.PHONY: test
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
integrate: integration
|
|
|
|
|
|
|
|
integration: bin/$(BINNAME)
|
|
|
|
$Q $(GOFLAGS) go test -tags=integration ./integration/...
|
|
|
|
|
|
|
|
.PHONY: integrate integration
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Linting
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
$Q gofmt -l -w $(SRC)
|
|
|
|
|
2019-08-27 23:39:48 +00:00
|
|
|
lint:
|
2020-04-21 17:10:33 +00:00
|
|
|
$Q LOG_LEVEL=error golangci-lint run --timeout=30m
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2019-09-24 21:31:07 +00:00
|
|
|
.PHONY: lint fmt
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Install
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
INSTALL_PREFIX?=/usr/
|
|
|
|
|
2020-08-19 20:21:14 +00:00
|
|
|
install: $(PREFIX)bin/$(BINNAME) $(PREFIX)bin/$(CLOUDKMS_BINNAME) $(PREFIX)bin/$(AWSKMS_BINNAME)
|
2018-10-05 21:48:36 +00:00
|
|
|
$Q install -D $(PREFIX)bin/$(BINNAME) $(DESTDIR)$(INSTALL_PREFIX)bin/$(BINNAME)
|
2020-02-19 03:07:12 +00:00
|
|
|
$Q install -D $(PREFIX)bin/$(CLOUDKMS_BINNAME) $(DESTDIR)$(INSTALL_PREFIX)bin/$(CLOUDKMS_BINNAME)
|
2020-08-19 20:21:14 +00:00
|
|
|
$Q install -D $(PREFIX)bin/$(AWSKMS_BINNAME) $(DESTDIR)$(INSTALL_PREFIX)bin/$(AWSKMS_BINNAME)
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
$Q rm -f $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BINNAME)
|
2020-02-19 03:07:12 +00:00
|
|
|
$Q rm -f $(DESTDIR)$(INSTALL_PREFIX)/bin/$(CLOUDKMS_BINNAME)
|
2020-08-19 20:21:14 +00:00
|
|
|
$Q rm -f $(DESTDIR)$(INSTALL_PREFIX)/bin/$(AWSKMS_BINNAME)
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
.PHONY: install uninstall
|
|
|
|
|
2019-02-20 20:45:10 +00:00
|
|
|
#########################################
|
|
|
|
# Clean
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
clean:
|
|
|
|
ifneq ($(BINNAME),"")
|
|
|
|
$Q rm -f bin/$(BINNAME)
|
|
|
|
endif
|
2020-02-19 03:07:12 +00:00
|
|
|
ifneq ($(CLOUDKMS_BINNAME),"")
|
|
|
|
$Q rm -f bin/$(CLOUDKMS_BINNAME)
|
|
|
|
endif
|
2020-08-19 20:21:14 +00:00
|
|
|
ifneq ($(AWSKMS_BINNAME),"")
|
|
|
|
$Q rm -f bin/$(AWSKMS_BINNAME)
|
|
|
|
endif
|
|
|
|
ifneq ($(YUBIKEY_BINNAME),"")
|
|
|
|
$Q rm -f bin/$(YUBIKEY_BINNAME)
|
|
|
|
endif
|
2019-02-20 20:45:10 +00:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
2020-03-25 20:11:03 +00:00
|
|
|
#########################################
|
|
|
|
# Dev
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
run:
|
|
|
|
$Q go run cmd/step-ca/main.go $(shell step path)/config/ca.json
|
|
|
|
|
|
|
|
.PHONY: run
|
|
|
|
|
2018-10-05 21:48:36 +00:00
|
|
|
#########################################
|
|
|
|
# Debian
|
|
|
|
#########################################
|
|
|
|
|
2018-11-02 22:08:50 +00:00
|
|
|
changelog:
|
2020-08-03 16:23:29 +00:00
|
|
|
$Q echo "step-certificates ($(DEB_VERSION)) unstable; urgency=medium" > debian/changelog
|
2018-11-02 22:08:50 +00:00
|
|
|
$Q echo >> debian/changelog
|
|
|
|
$Q echo " * See https://github.com/smallstep/certificates/releases" >> debian/changelog
|
|
|
|
$Q echo >> debian/changelog
|
|
|
|
$Q echo " -- Smallstep Labs, Inc. <techadmin@smallstep.com> $(shell date -uR)" >> debian/changelog
|
|
|
|
|
|
|
|
debian: changelog
|
2018-10-05 21:48:36 +00:00
|
|
|
$Q mkdir -p $(RELEASE); \
|
2018-11-02 22:08:50 +00:00
|
|
|
OUTPUT=../step-certificates_*.deb; \
|
2018-10-05 21:48:36 +00:00
|
|
|
rm $$OUTPUT; \
|
|
|
|
dpkg-buildpackage -b -rfakeroot -us -uc && cp $$OUTPUT $(RELEASE)/
|
|
|
|
|
|
|
|
distclean: clean
|
|
|
|
|
2018-11-02 22:08:50 +00:00
|
|
|
.PHONY: changelog debian distclean
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
#################################################
|
|
|
|
# Build statically compiled step binary for various operating systems
|
|
|
|
#################################################
|
|
|
|
|
|
|
|
BINARY_OUTPUT=$(OUTPUT_ROOT)binary/
|
|
|
|
RELEASE=./.travis-releases
|
|
|
|
|
2020-04-08 21:06:50 +00:00
|
|
|
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'.
|
2020-08-19 20:21:14 +00:00
|
|
|
$(q) GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2) GOARM=$(3)' PREFIX=$(4) make $(4)bin/$(BINNAME) $(4)bin/$(CLOUDKMS_BINNAME) $(4)bin/$(AWSKMS_BINNAME)
|
2020-04-08 21:06:50 +00:00
|
|
|
endef
|
|
|
|
|
2018-10-05 21:48:36 +00:00
|
|
|
binary-linux:
|
2020-04-08 21:06:50 +00:00
|
|
|
$(call BUNDLE_MAKE,linux,amd64,,$(BINARY_OUTPUT)linux/)
|
|
|
|
|
|
|
|
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/)
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
binary-darwin:
|
2020-04-08 21:06:50 +00:00
|
|
|
$(call BUNDLE_MAKE,darwin,amd64,,$(BINARY_OUTPUT)darwin/)
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
define BUNDLE
|
2020-04-08 21:06:50 +00:00
|
|
|
# $(1) -- Binary Output Dir Name
|
|
|
|
# $(2) -- Step Platform Name
|
|
|
|
# $(3) -- Step Binary Architecture
|
|
|
|
# $(4) -- Step Binary Name (For Windows Comaptibility)
|
2020-08-19 20:21:14 +00:00
|
|
|
$(q) ./make/bundle.sh "$(BINARY_OUTPUT)$(1)" "$(RELEASE)" "$(VERSION)" "$(2)" "$(3)" "$(4)" "$(5)" "$(6)"
|
2018-10-05 21:48:36 +00:00
|
|
|
endef
|
|
|
|
|
2020-04-08 21:06:50 +00:00
|
|
|
bundle-linux: binary-linux binary-linux-arm64 binary-linux-armv7
|
2020-08-19 20:21:14 +00:00
|
|
|
$(call BUNDLE,linux,linux,amd64,$(BINNAME),$(CLOUDKMS_BINNAME),$(AWSKMS_BINNAME))
|
|
|
|
$(call BUNDLE,linux.arm64,linux,arm64,$(BINNAME),$(CLOUDKMS_BINNAME),$(AWSKMS_BINNAME))
|
|
|
|
$(call BUNDLE,linux.armv7,linux,armv7,$(BINNAME),$(CLOUDKMS_BINNAME),$(AWSKMS_BINNAME))
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
bundle-darwin: binary-darwin
|
2020-08-19 20:21:14 +00:00
|
|
|
$(call BUNDLE,darwin,darwin,amd64,$(BINNAME),$(CLOUDKMS_BINNAME),$(AWSKMS_BINNAME))
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
.PHONY: binary-linux binary-darwin bundle-linux bundle-darwin
|
|
|
|
|
|
|
|
#################################################
|
2019-03-29 19:37:58 +00:00
|
|
|
# Targets for creating OS specific artifacts and archives
|
2018-10-05 21:48:36 +00:00
|
|
|
#################################################
|
|
|
|
|
|
|
|
artifacts-linux-tag: bundle-linux debian
|
|
|
|
|
|
|
|
artifacts-darwin-tag: bundle-darwin
|
|
|
|
|
2019-03-29 19:37:58 +00:00
|
|
|
artifacts-archive-tag:
|
|
|
|
$Q mkdir -p $(RELEASE)
|
2019-04-05 18:38:43 +00:00
|
|
|
$Q git archive v$(VERSION) | gzip > $(RELEASE)/step-certificates_$(VERSION).tar.gz
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2019-03-29 19:53:09 +00:00
|
|
|
artifacts-tag: artifacts-linux-tag artifacts-darwin-tag artifacts-archive-tag
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2019-03-29 19:37:58 +00:00
|
|
|
.PHONY: artifacts-linux-tag artifacts-darwin-tag artifacts-archive-tag artifacts-tag
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
#################################################
|
|
|
|
# Targets for creating step artifacts
|
|
|
|
#################################################
|
|
|
|
|
2020-08-02 20:25:21 +00:00
|
|
|
# For all builds that are not tagged and not on the master branch
|
|
|
|
artifacts-branch:
|
|
|
|
|
2018-10-05 21:48:36 +00:00
|
|
|
# For all builds that are not tagged
|
|
|
|
artifacts-master:
|
|
|
|
|
2019-03-29 19:37:58 +00:00
|
|
|
# For all builds with a release-candidate (-rc) tag
|
2019-03-27 18:35:17 +00:00
|
|
|
artifacts-release-candidate: artifacts-tag
|
|
|
|
|
2018-10-05 21:48:36 +00:00
|
|
|
# For all builds with a release tag
|
|
|
|
artifacts-release: artifacts-tag
|
|
|
|
|
|
|
|
# This command is called by travis directly *after* a successful build
|
2018-11-15 01:53:17 +00:00
|
|
|
artifacts: artifacts-$(PUSHTYPE) docker-$(PUSHTYPE)
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2019-03-27 18:35:17 +00:00
|
|
|
.PHONY: artifacts-master artifacts-release-candidate artifacts-release artifacts
|