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

Commit

Permalink
Build binaries via goreleaser (#977)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
adam-stokes authored Mar 31, 2021
1 parent 83ace74 commit 0babb20
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin
outputs
dist/
37 changes: 37 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
env:
- GO111MODULE=on

before:
hooks:
- go mod download
- go install github.com/gobuffalo/packr/v2/packr2
- cd cli && packr2

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
main: ./cli/main.go
binary: op
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Get current directory of a Makefile: https://stackoverflow.com/a/23324703

# Builds cli for all supported platforms
.PHONY: build
build:
goreleaser --snapshot --skip-publish --rm-dist

.PHONY: clean
clean: clean-workspace clean-docker

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ This repository contains:
- Redis
- vSphere

## Building

This project utilizes `goreleaser` to build the cli binaries for all supported
platforms. Please see [goreleaser installation](https://goreleaser.com/install/)
for instructions on making that available to you.

Once `goreleaser` is installed building the cli is as follows:

```
$ make build
```

This will put the built distribution inside of `dist` in the current working directory.

## Contributing

### pre-commit
Expand Down
1 change: 1 addition & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
op
.github
packrd
10 changes: 0 additions & 10 deletions cli/Building.md

This file was deleted.

15 changes: 0 additions & 15 deletions cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,8 @@ ROOT_DIR:=$(CURDIR)
include ../commons.mk

TEST_TIMEOUT?=5m

GO_IMAGE?='golang'
GO_VERSION='$(shell cat ../.go-version )'
GO_IMAGE_TAG?='stretch'
GOOS?='linux'
GOARCH?='amd64'
LOG_LEVEL?=INFO

.PHONY: build
build:
docker run --rm \
-v $(ROOT_DIR):/go/src/github.com/elastic/e2e-testing/cli \
-w /go/src/github.com/elastic/e2e-testing/cli \
-e TARGET_OS=$(GOOS) -e TARGET_ARCH=$(GOARCH) -e GO111MODULE=on \
$(GO_IMAGE):$(GO_VERSION)-$(GO_IMAGE_TAG) \
scripts/build-cli.sh

.PHONY: install
install:
go get -v -t ./...
Expand Down
64 changes: 0 additions & 64 deletions cli/scripts/build-cli.sh

This file was deleted.

0 comments on commit 0babb20

Please sign in to comment.