Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 1f692a7

Browse files
adam-stokesmdelapenya
authored andcommitted
Build binaries via goreleaser (#977)
This handles building for all supported architectures including running packr for embedding the binary files. This allows us to easily extend our release process for tagging official cli releases, building in various package formats and publishing to different package registries Signed-off-by: Adam Stokes <51892+adam-stokes@users.noreply.github.com>
1 parent 74dad36 commit 1f692a7

8 files changed

Lines changed: 60 additions & 89 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
bin
22
outputs
3+
dist/

.goreleaser.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This is an example .goreleaser.yml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
env:
4+
- GO111MODULE=on
5+
6+
before:
7+
hooks:
8+
- go mod download
9+
- go install github.com/gobuffalo/packr/v2/packr2
10+
- cd cli && packr2
11+
12+
builds:
13+
- env:
14+
- CGO_ENABLED=0
15+
goos:
16+
- linux
17+
- windows
18+
- darwin
19+
main: ./cli/main.go
20+
binary: op
21+
archives:
22+
- replacements:
23+
darwin: Darwin
24+
linux: Linux
25+
windows: Windows
26+
386: i386
27+
amd64: x86_64
28+
checksum:
29+
name_template: 'checksums.txt'
30+
snapshot:
31+
name_template: "{{ .Tag }}-next"
32+
changelog:
33+
sort: asc
34+
filters:
35+
exclude:
36+
- '^docs:'
37+
- '^test:'

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Get current directory of a Makefile: https://stackoverflow.com/a/23324703
2+
3+
# Builds cli for all supported platforms
4+
.PHONY: build
5+
build:
6+
goreleaser --snapshot --skip-publish --rm-dist
7+
18
.PHONY: clean
29
clean: clean-workspace clean-docker
310

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ This repository contains:
1919
- Redis
2020
- vSphere
2121

22+
## Building
23+
24+
This project utilizes `goreleaser` to build the cli binaries for all supported
25+
platforms. Please see [goreleaser installation](https://goreleaser.com/install/)
26+
for instructions on making that available to you.
27+
28+
Once `goreleaser` is installed building the cli is as follows:
29+
30+
```
31+
$ make build
32+
```
33+
34+
This will put the built distribution inside of `dist` in the current working directory.
35+
2236
## Contributing
2337

2438
### pre-commit

cli/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
op
22
.github
3+
packrd

cli/Building.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

cli/Makefile

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,8 @@ ROOT_DIR:=$(CURDIR)
44
include ../commons.mk
55

66
TEST_TIMEOUT?=5m
7-
8-
GO_IMAGE?='golang'
9-
GO_VERSION='$(shell cat ../.go-version )'
10-
GO_IMAGE_TAG?='stretch'
11-
GOOS?='linux'
12-
GOARCH?='amd64'
137
LOG_LEVEL?=INFO
148

15-
.PHONY: build
16-
build:
17-
docker run --rm \
18-
-v $(ROOT_DIR):/go/src/github.com/elastic/e2e-testing/cli \
19-
-w /go/src/github.com/elastic/e2e-testing/cli \
20-
-e TARGET_OS=$(GOOS) -e TARGET_ARCH=$(GOARCH) -e GO111MODULE=on \
21-
$(GO_IMAGE):$(GO_VERSION)-$(GO_IMAGE_TAG) \
22-
scripts/build-cli.sh
23-
249
.PHONY: install
2510
install:
2611
go get -v -t ./...

cli/scripts/build-cli.sh

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)