-
Notifications
You must be signed in to change notification settings - Fork 35
/
Makefile
86 lines (62 loc) · 3.39 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
# Note: These commands pertain to the development of ld-find-code-refs.
# They are not intended for use by the end-users of this program.
SHELL=/bin/bash
GORELEASER_VERSION=v1.20.0
build:
go build ./cmd/...
init:
pre-commit install
test: lint
go test ./...
lint:
pre-commit run -a --verbose golangci-lint
# Generate docs about GitHub Action inputs and updates README.md
github-action-docs:
cd build/metadata/github-actions && npx action-docs -u --no-banner
# Strip debug informatino from production builds
BUILD_FLAGS = -ldflags="-s -w"
compile-macos-binary:
GOOS=darwin GOARCH=amd64 go build ${BUILD_FLAGS} -o out/ld-find-code-refs ./cmd/ld-find-code-refs
compile-windows-binary:
GOOS=windows GOARCH=amd64 go build ${BUILD_FLAGS} -o out/ld-find-code-refs.exe ./cmd/ld-find-code-refs
compile-linux-binary:
GOOS=linux GOARCH=amd64 go build ${BUILD_FLAGS} -o build/package/cmd/ld-find-code-refs ./cmd/ld-find-code-refs
compile-github-actions-binary:
GOOS=linux GOARCH=amd64 go build ${BUILD_FLAGS} -o build/package/github-actions/ld-find-code-refs-github-action ./build/package/github-actions
compile-bitbucket-pipelines-binary:
GOOS=linux GOARCH=amd64 go build ${BUILD_FLAGS} -o build/package/bitbucket-pipelines/ld-find-code-refs-bitbucket-pipeline ./build/package/bitbucket-pipelines
# Get the lines added to the most recent changelog update (minus the first 2 lines)
RELEASE_NOTES=<(GIT_EXTERNAL_DIFF='bash -c "diff --unchanged-line-format=\"\" $$2 $$5" || true' git log --ext-diff -1 --pretty= -p CHANGELOG.md)
echo-release-notes:
@cat $(RELEASE_NOTES)
define publish_docker
test $(1) || (echo "Please provide tag"; exit 1)
docker build -t launchdarkly/$(3):$(1) build/package/$(4)
docker push launchdarkly/$(3):$(1)
# test $(2) && (echo "Not pushing latest tag for prerelease")
test $(2) || docker tag launchdarkly/$(3):$(1) launchdarkly/$(3):latest
test $(2) || docker push launchdarkly/$(3):latest
endef
# TODO: Remove all circleci publishing targets when we have a github owner token setup.
# Use ./ldrelease/publish-circleci.sh to publish to circleci orbs registry.
validate-circle-orb:
test $(TAG) || (echo "Please provide tag"; exit 1)
circleci orb validate build/package/circleci/orb.yml || (echo "Unable to validate orb"; exit 1)
publish-dev-circle-orb: validate-circle-orb
circleci orb publish build/package/circleci/orb.yml launchdarkly/ld-find-code-refs@dev:$(TAG)
publish-release-circle-orb: validate-circle-orb
circleci orb publish build/package/circleci/orb.yml launchdarkly/ld-find-code-refs@$(TAG)
publish-all: publish-release-circle-orb
clean:
rm -rf out/
rm -f build/pacakge/cmd/ld-find-code-refs
rm -f build/package/github-actions/ld-find-code-refs-github-action
rm -f build/package/bitbucket-pipelines/ld-find-code-refs-bitbucket-pipeline
RELEASE_CMD=curl -sL https://git.io/goreleaser | GOPATH=$(mktemp -d) VERSION=$(GORELEASER_VERSION) GITHUB_TOKEN=$(GITHUB_TOKEN) bash -s -- --clean --release-notes $(RELEASE_NOTES)
publish:
$(RELEASE_CMD)
test-publish:
curl -sL https://git.io/goreleaser | VERSION=$(GORELEASER_VERSION) bash -s -- --clean --skip-publish --skip-validate
products-for-release:
$(RELEASE_CMD) --skip-publish --skip-validate
.PHONY: init test lint compile-github-actions-binary compile-macos-binary compile-linux-binary compile-windows-binary compile-bitbucket-pipelines-binary echo-release-notes publish-dev-circle-orb publish-release-circle-orb publish-all clean build