forked from TrueCloudLab/certificates
39f46d31b9
This commit removes the following deprecated binaries: - step-awskms-init - step-cloudkms-init - step-pkcs11-init - step-yubikey-init From now on step and step-kms-plugin should be used to initialize the PKI in AWS KMS, GCP KMS, PKCS#11 modules or YubiKeys. A future commit will add step-kms-plugin to the docker images of step-ca. Fixes #1046
191 lines
4.7 KiB
Makefile
191 lines
4.7 KiB
Makefile
PKG?=github.com/smallstep/certificates/cmd/step-ca
|
|
BINNAME?=step-ca
|
|
|
|
# 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 ?=
|
|
OUTPUT_ROOT=output/
|
|
RELEASE=./.releases
|
|
|
|
all: lint test build
|
|
|
|
ci: testcgo build
|
|
|
|
.PHONY: all ci
|
|
|
|
#########################################
|
|
# Bootstrapping
|
|
#########################################
|
|
|
|
bootstra%:
|
|
$Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin latest
|
|
$Q go install golang.org/x/vuln/cmd/govulncheck@latest
|
|
$Q go install gotest.tools/gotestsum@latest
|
|
|
|
.PHONY: bootstra%
|
|
|
|
#################################################
|
|
# 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//')
|
|
DEB_VERSION := $(shell echo $(VERSION) | sed 's/-/./g')
|
|
|
|
ifdef V
|
|
$(info TRAVIS_TAG is $(TRAVIS_TAG))
|
|
$(info GITHUB_REF is $(GITHUB_REF))
|
|
$(info VERSION is $(VERSION))
|
|
$(info DEB_VERSION is $(DEB_VERSION))
|
|
$(info PUSHTYPE is $(PUSHTYPE))
|
|
endif
|
|
|
|
#########################################
|
|
# 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
|
|
|
|
download:
|
|
$Q go mod download
|
|
|
|
build: $(PREFIX)bin/$(BINNAME)
|
|
@echo "Build Complete!"
|
|
|
|
$(PREFIX)bin/$(BINNAME): download $(call rwildcard,*.go)
|
|
$Q mkdir -p $(@D)
|
|
$Q $(GOOS_OVERRIDE) $(GOFLAGS) go build -v -o $(PREFIX)bin/$(BINNAME) $(LDFLAGS) $(PKG)
|
|
|
|
# Target to force a build of step-ca without running tests
|
|
simple: build
|
|
|
|
.PHONY: download build simple
|
|
|
|
#########################################
|
|
# Go generate
|
|
#########################################
|
|
|
|
generate:
|
|
$Q go generate ./...
|
|
|
|
.PHONY: generate
|
|
|
|
#########################################
|
|
# Test
|
|
#########################################
|
|
test:
|
|
$Q $(GOFLAGS) gotestsum -- -coverprofile=coverage.out -short -covermode=atomic ./...
|
|
|
|
testcgo:
|
|
$Q gotestsum -- -coverprofile=coverage.out -short -covermode=atomic ./...
|
|
|
|
.PHONY: test testcgo
|
|
|
|
integrate: integration
|
|
|
|
integration: bin/$(BINNAME)
|
|
$Q $(GOFLAGS) gotestsum -- -tags=integration ./integration/...
|
|
|
|
.PHONY: integrate integration
|
|
|
|
#########################################
|
|
# Linting
|
|
#########################################
|
|
|
|
fmt:
|
|
$Q goimports -l -w $(SRC)
|
|
|
|
lint: SHELL:=/bin/bash
|
|
lint:
|
|
$Q LOG_LEVEL=error golangci-lint run --config <(curl -s https://raw.githubusercontent.com/smallstep/workflows/master/.golangci.yml) --timeout=30m
|
|
$Q govulncheck ./...
|
|
|
|
.PHONY: fmt lint
|
|
|
|
#########################################
|
|
# Install
|
|
#########################################
|
|
|
|
INSTALL_PREFIX?=/usr/
|
|
|
|
install: $(PREFIX)bin/$(BINNAME)
|
|
$Q install -D $(PREFIX)bin/$(BINNAME) $(DESTDIR)$(INSTALL_PREFIX)bin/$(BINNAME)
|
|
|
|
uninstall:
|
|
$Q rm -f $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BINNAME)
|
|
|
|
.PHONY: install uninstall
|
|
|
|
#########################################
|
|
# Clean
|
|
#########################################
|
|
|
|
clean:
|
|
ifneq ($(BINNAME),"")
|
|
$Q rm -f bin/$(BINNAME)
|
|
endif
|
|
|
|
.PHONY: clean
|
|
|
|
#########################################
|
|
# Dev
|
|
#########################################
|
|
|
|
run:
|
|
$Q go run cmd/step-ca/main.go $(shell step path)/config/ca.json
|
|
|
|
.PHONY: run
|
|
|
|
#########################################
|
|
# Debian
|
|
#########################################
|
|
|
|
changelog:
|
|
$Q echo "step-ca ($(DEB_VERSION)) unstable; urgency=medium" > debian/changelog
|
|
$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
|
|
$Q mkdir -p $(RELEASE); \
|
|
OUTPUT=../step-ca*.deb; \
|
|
rm $$OUTPUT; \
|
|
dpkg-buildpackage -b -rfakeroot -us -uc && cp $$OUTPUT $(RELEASE)/
|
|
|
|
distclean: clean
|
|
|
|
.PHONY: changelog debian distclean
|