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
|
|
|
|
|
|
|
|
# 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 ?=
|
|
|
|
|
2020-07-21 01:57:19 +00:00
|
|
|
all: lint test build
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2021-04-13 22:31:33 +00:00
|
|
|
ci: testcgo build
|
2021-02-12 21:18:30 +00:00
|
|
|
|
2021-02-23 05:25:40 +00:00
|
|
|
.PHONY: all ci
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Bootstrapping
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
bootstra%:
|
2022-09-20 22:46:59 +00:00
|
|
|
$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
|
2023-03-21 04:03:37 +00:00
|
|
|
$Q go install github.com/goreleaser/goreleaser@latest
|
|
|
|
$Q go install github.com/sigstore/cosign/v2/cmd/cosign@latest
|
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`
|
|
|
|
#################################################
|
|
|
|
|
2021-02-23 05:25:40 +00:00
|
|
|
# GITHUB Actions
|
2023-03-21 04:03:37 +00:00
|
|
|
ifdef GITHUB_REF
|
2021-04-15 22:16:32 +00:00
|
|
|
VERSION ?= $(shell echo $(GITHUB_REF) | sed 's/^refs\/tags\///')
|
2020-04-10 03:36:54 +00:00
|
|
|
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
|
|
|
PUSHTYPE := branch
|
2020-04-10 03:36:54 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
VERSION := $(shell echo $(VERSION) | sed 's/^v//')
|
|
|
|
|
|
|
|
ifdef V
|
2021-02-23 05:25:40 +00:00
|
|
|
$(info GITHUB_REF is $(GITHUB_REF))
|
2020-04-10 03:36:54 +00:00
|
|
|
$(info VERSION is $(VERSION))
|
|
|
|
$(info PUSHTYPE is $(PUSHTYPE))
|
2018-10-05 21:48:36 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Build
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
DATE := $(shell date -u '+%Y-%m-%d %H:%M UTC')
|
|
|
|
LDFLAGS := -ldflags='-w -X "main.Version=$(VERSION)" -X "main.BuildTime=$(DATE)"'
|
2023-06-21 21:16:29 +00:00
|
|
|
GOFLAGS ?=
|
|
|
|
GO_ENVS := CGO_ENABLED=0
|
2023-06-21 20:09:58 +00:00
|
|
|
|
2019-10-22 01:52:01 +00:00
|
|
|
download:
|
|
|
|
$Q go mod download
|
|
|
|
|
2023-01-24 00:30:55 +00:00
|
|
|
build: $(PREFIX)bin/$(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)
|
2023-06-21 21:16:29 +00:00
|
|
|
$Q $(GOOS_OVERRIDE) $(GO_ENVS) go build -v -o $(PREFIX)bin/$(BINNAME) $(LDFLAGS) $(PKG)
|
2018-10-05 21:48:36 +00:00
|
|
|
|
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
|
|
|
|
#########################################
|
2023-03-30 09:39:24 +00:00
|
|
|
test: testdefault testtpmsimulator combinecoverage
|
|
|
|
|
|
|
|
testdefault:
|
2023-06-21 21:16:29 +00:00
|
|
|
$Q $(GO_ENVS) gotestsum -- -coverprofile=defaultcoverage.out -short -covermode=atomic ./...
|
2023-03-30 09:39:24 +00:00
|
|
|
|
|
|
|
testtpmsimulator:
|
|
|
|
$Q CGO_ENALBED=1 gotestsum -- -coverprofile=tpmsimulatorcoverage.out -short -covermode=atomic -tags tpmsimulator ./acme
|
2022-09-21 04:48:04 +00:00
|
|
|
|
2021-02-12 21:18:30 +00:00
|
|
|
testcgo:
|
2022-09-21 04:48:04 +00:00
|
|
|
$Q gotestsum -- -coverprofile=coverage.out -short -covermode=atomic ./...
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2023-03-30 09:39:24 +00:00
|
|
|
combinecoverage:
|
|
|
|
cat defaultcoverage.out tpmsimulatorcoverage.out > coverage.out
|
|
|
|
|
|
|
|
.PHONY: test testdefault testtpmsimulator testcgo combinecoverage
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
integrate: integration
|
|
|
|
|
|
|
|
integration: bin/$(BINNAME)
|
2023-06-21 21:16:29 +00:00
|
|
|
$Q $(GO_ENVS) gotestsum -- -tags=integration ./integration/...
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
.PHONY: integrate integration
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Linting
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
fmt:
|
2022-09-20 22:46:59 +00:00
|
|
|
$Q goimports -l -w $(SRC)
|
2018-10-05 21:48:36 +00:00
|
|
|
|
2022-09-20 22:46:59 +00:00
|
|
|
lint: SHELL:=/bin/bash
|
2019-08-27 23:39:48 +00:00
|
|
|
lint:
|
2022-09-20 22:46:59 +00:00
|
|
|
$Q LOG_LEVEL=error golangci-lint run --config <(curl -s https://raw.githubusercontent.com/smallstep/workflows/master/.golangci.yml) --timeout=30m
|
|
|
|
$Q govulncheck ./...
|
2021-02-12 21:18:30 +00:00
|
|
|
|
2022-09-20 22:46:59 +00:00
|
|
|
.PHONY: fmt lint
|
2018-10-05 21:48:36 +00:00
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Install
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
INSTALL_PREFIX?=/usr/
|
|
|
|
|
2023-01-24 00:30:55 +00:00
|
|
|
install: $(PREFIX)bin/$(BINNAME)
|
2018-10-05 21:48:36 +00:00
|
|
|
$Q install -D $(PREFIX)bin/$(BINNAME) $(DESTDIR)$(INSTALL_PREFIX)bin/$(BINNAME)
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
$Q rm -f $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BINNAME)
|
|
|
|
|
|
|
|
.PHONY: install uninstall
|
|
|
|
|
2019-02-20 20:45:10 +00:00
|
|
|
#########################################
|
|
|
|
# Clean
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
clean:
|
|
|
|
ifneq ($(BINNAME),"")
|
|
|
|
$Q rm -f bin/$(BINNAME)
|
|
|
|
endif
|
|
|
|
|
|
|
|
.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
|
|
|
|
|