Skip to content

Commit 3bf1c76

Browse files
committed
Use GoReleaser Pro for Makefile builds
1 parent eb4dfeb commit 3bf1c76

File tree

2 files changed

+19
-48
lines changed

2 files changed

+19
-48
lines changed

.goreleaser.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ project_name: step
44

55
before:
66
hooks:
7-
# You may remove this if you don't use go modules.
87
- go mod download
9-
# - go generate ./...
108

119
builds:
1210
- &COMMON
@@ -36,8 +34,10 @@ builds:
3634
- windows_amd64
3735
- windows_arm64
3836
binary: bin/step
39-
ldflags:
40-
- -w -X main.Version={{.Version}} -X main.BuildTime={{.Date}}
37+
-
38+
<< : *COMMON
39+
id: debug
40+
gcflags: all=-N -l
4141
-
4242
# This build is for S3 binaries that follow our naming convention there.
4343
<< : *COMMON

Makefile

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,18 @@ ci: test build
88
# Determine the type of `push` and `version`
99
#################################################
1010

11-
ifdef GITHUB_REF
12-
VERSION ?= $(shell echo $(GITHUB_REF) | sed 's/^refs\/tags\///')
13-
NOT_RC := $(shell echo $(VERSION) | grep -v -e -rc)
14-
ifeq ($(NOT_RC),)
15-
PUSHTYPE := release-candidate
16-
else
17-
PUSHTYPE := release
18-
endif
19-
else
20-
VERSION ?= $(shell [ -d .git ] && git describe --tags --always --dirty="-dev")
21-
# If we are not in an active git dir then try reading the version from .VERSION.
22-
# .VERSION contains a slug populated by `git archive`.
23-
VERSION := $(or $(VERSION),$(shell make/version.sh .VERSION))
24-
PUSHTYPE := branch
25-
endif
26-
27-
VERSION := $(shell echo $(VERSION) | sed 's/^v//')
28-
29-
ifdef V
30-
$(info GITHUB_REF is $(GITHUB_REF))
31-
$(info VERSION is $(VERSION))
32-
$(info PUSHTYPE is $(PUSHTYPE))
33-
endif
34-
35-
PKG?=github.com/smallstep/cli/cmd/step
36-
BINNAME?=step
37-
3811
# Set V to 1 for verbose output from the Makefile
3912
Q=$(if $V,,@)
4013
PREFIX?=
4114
SRC=$(shell find . -type f -name '*.go')
4215
GOOS_OVERRIDE ?=
4316
CGO_OVERRIDE ?= CGO_ENABLED=0
4417
OUTPUT_ROOT=output/
18+
BUILDID?=default
19+
ifdef DEBUG
20+
BUILDID=debug
21+
endif
22+
4523

4624
.PHONY: all
4725

@@ -62,26 +40,19 @@ bootstra%:
6240
# Build
6341
#########################################
6442

65-
DATE := $(shell date -u '+%Y-%m-%d %H:%M UTC')
66-
ifdef DEBUG
67-
LDFLAGS := -ldflags='-X "main.Version=$(VERSION)" -X "main.BuildTime=$(DATE)"'
68-
GCFLAGS := -gcflags "all=-N -l"
69-
else
70-
LDFLAGS := -ldflags='-w -X "main.Version=$(VERSION)" -X "main.BuildTime=$(DATE)"'
71-
GCFLAGS :=
72-
endif
73-
74-
download:
75-
$Q go mod download
76-
77-
build: $(PREFIX)bin/$(BINNAME)
43+
build: $(PREFIX)bin/step
7844
@echo "Build Complete!"
7945

80-
$(PREFIX)bin/$(BINNAME): download $(call rwildcard,*.go)
46+
$(PREFIX)bin/step:
8147
$Q mkdir -p $(@D)
82-
$Q $(GOOS_OVERRIDE) $(CGO_OVERRIDE) go build -v -o $@ $(GCFLAGS) $(LDFLAGS) $(PKG)
48+
$Q $(GOOS_OVERRIDE) $(CGO_OVERRIDE) goreleaser build \
49+
--id $(BUILDID) \
50+
--snapshot \
51+
--single-target \
52+
--clean \
53+
--output $(PREFIX)bin/step
8354

84-
.PHONY: build simple
55+
.PHONY: build
8556

8657
#########################################
8758
# Test
@@ -157,7 +128,7 @@ define BUNDLE_MAKE
157128
# $(2) -- Go Architecture (e.g. amd64, arm, arm64, etc.)
158129
# $(3) -- Go ARM architectural family (e.g. 7, 8, etc.)
159130
# $(4) -- Parent directory for executables generated by 'make'.
160-
$(q) GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2) GOARM=$(3)' PREFIX=$(4) make $(4)bin/step
131+
$(q) GOOS=$(1) GOARCH=$(2) GOARM=$(3) PREFIX=$(4) make $(4)bin/step
161132
endef
162133

163134
binary-linux-amd64:

0 commit comments

Comments
 (0)