Skip to content

Commit

Permalink
build: add release-snapshot Make target
Browse files Browse the repository at this point in the history
This allows you to run the release locally, without publishing or
signing, against the current state of the repository.

There are some more improvements I would like to make to the
`Makefile` e.g., the deprecation of `golint` and the introduction of a
`help` target. But they are out of scope for the current things I am
working on.

Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco committed Aug 10, 2023
1 parent 1b4cd38 commit d5a8a3a
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

PROJECT := github.com/getsops/sops/v3
GO := GOPROXY=https://proxy.golang.org go
GOLINT := golint
PROJECT := github.com/getsops/sops/v3
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
GO := GOPROXY=https://proxy.golang.org go
GOLINT := golint

GITHUB_REPOSITORY ?= github.com/getsops/sops

GORELEASER := $(PROJECT_DIR)/bin/goreleaser
GORELEASER_VERSION ?= v1.20.0

.PHONY: all
all: test vet generate install functional-tests

.PHONY: origin-build
origin-build: test vet generate install functional-tests-all

install:
Expand All @@ -18,34 +27,54 @@ tag: all
lint:
$(GOLINT) $(PROJECT)

.PHONY: vendor
vendor:
$(GO) mod tidy
$(GO) mod vendor

vet:
$(GO) vet $(PROJECT)

.PHONY: test
test: vendor
gpg --import pgp/sops_functional_tests_key.asc 2>&1 1>/dev/null || exit 0
./test.sh

showcoverage: test
$(GO) tool cover -html=coverage.out

.PHONY: generate
generate: keyservice/keyservice.pb.go
$(GO) generate

%.pb.go: %.proto
protoc --go_out=plugins=grpc:. $<

.PHONY: functional-tests
functional-tests:
$(GO) build -o functional-tests/sops github.com/getsops/sops/v3/cmd/sops
cd functional-tests && cargo test

# Ignored tests are ones that require external services (e.g. AWS KMS)
# TODO: Once `--include-ignored` lands in rust stable, switch to that.
.PHONY: functional-tests-all
functional-tests-all:
$(GO) build -o functional-tests/sops github.com/getsops/sops/v3/cmd/sops
# Ignored tests are ones that require external services (e.g. AWS KMS)
# TODO: Once `--include-ignored` lands in rust stable, switch to that.
cd functional-tests && cargo test && cargo test -- --ignored

.PHONY: all test generate clean vendor functional-tests
.PHONY: release-snapshot
release-snapshot: install-goreleaser
GITHUB_REPOSITORY=$(GITHUB_REPOSITORY) $(GORELEASER) release --clean --snapshot --skip-sign

.PHONY: install-goreleaser
install-goreleaser:
$(call go-install-tool,$(GORELEASER),github.com/goreleaser/goreleaser@$(GORELEASER_VERSION),$(GORELEASER_VERSION))

# go-install-tool will 'go install' any package $2 and install it to $1.
define go-install-tool
@[ -f $(1)-$(3) ] || { \
set -e ;\
GOBIN=$$(dirname $(1)) go install $(2) ;\
touch $(1)-$(3) ;\
}
endef

0 comments on commit d5a8a3a

Please sign in to comment.