Skip to content

Commit

Permalink
Merge pull request #65 from immutability-io/goreleaser_cross_compile
Browse files Browse the repository at this point in the history
WIP: Goreleaser cross compile and resolve #2
  • Loading branch information
cypherhat committed Aug 6, 2019
2 parents d10457b + 9bb9896 commit b8ba0d6
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ scripts/**
**/.DS_Store
**/helper/*.txt
**/helper/SHA256SUM
**/vault-ethereum
**/vault-ethereum
dist
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM vault:latest as build
RUN apk add --update alpine-sdk
RUN apk update && apk add go git
WORKDIR /app
ENV GOPATH /app
ADD . /app/src
RUN GO111MODULE=on go get github.com/immutability-io/vault-ethereum
RUN GO111MODULE=on CGO_ENABLED=1 GOOS=linux go install -a github.com/immutability-io/vault-ethereum

FROM vault:latest
WORKDIR /app
RUN cd /app
COPY --from=build /app/bin/vault-ethereum /app/bin/vault-ethereum
# Prove the binary is now an executable
CMD /app/bin/vault-ethereum
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![Immutability](/docs/tagline.png?raw=true "Changes Everything")


Ethereum plugin for Vault
-----------------

Expand Down Expand Up @@ -656,6 +657,38 @@ transaction_hash 0x2ff5dd013e5a4d00cf007a7fb689c4ebf50541c2e7ddfaf16212e7ed1b

There are many more uses cases to be explored; but, I will leave that to you. If you brave enough...

## Releasing

We use goreleaser to release cross-compiled versions. The steps to release are:

```
export GITHUB_TOKEN="A_GITHUB_TOKEN_THAT_HAS_CORRECT_ACCESS_ENTITLEMENTS"
VERSION="0.0.30"
rm -rf dist
git tag -a $VERSION -m "Some description of the release"
docker run --rm --privileged \
-v $(pwd):/go/src/github.com/immutability-io/vault-ethereum \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/immutability-io/vault-ethereum \
mailchain/goreleaser-xcgo goreleaser --rm-dist
sha256sum dist/*.zip > dist/SHA256SUMS
gpg --detach-sign dist/SHA256SUMS
```

If you wish to run goreleaser locally, the following will give you a snapshot build for darwin, linux, and windows.

```bash
docker run --rm --privileged \
-v $(pwd):/go/src/github.com/immutability-io/vault-ethereum \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/immutability-io/vault-ethereum \
mailchain/goreleaser-xcgo goreleaser --snapshot --rm-dist
```

You can read more about goreleaser here:

https://goreleaser.com/

## Credits

None of this would have been possible without the fantastic [tutorial](https://www.hashicorp.com/blog/building-a-vault-secure-plugin) on Vault Plugins by Seth Vargo. Seth is one of those rare individuals who can communicate the simple essence of a complex technology in practical terms.
Expand Down
44 changes: 44 additions & 0 deletions goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
env:
- GO111MODULE=on
before:
hooks:
- go mod download
builds:
- id: vault-ethereum-darwin-amd64
ldflags: -s -w -X github.com/immutability-io/vault-ethereum.Version={{.Version}} -X github.com/immutability-io/vault-ethereum.BuildDate={{.Date}} -X github.com/immutability-io/vault-ethereum.CommitHash={{ .ShortCommit }}
binary: vault-ethereum_{{.Version}}
env:
- CGO_ENABLED=1
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
- id: vault-ethereum-linux-amd64
ldflags: -s -w -X github.com/immutability-io/vault-ethereum/pkg/version.Version={{.Version}} -X github.com/immutability-io/vault-ethereum/pkg/version.BuildDate={{.Date}} -X github.com/immutability-io/vault-ethereum/pkg/version.CommitHash={{ .ShortCommit }}
binary: vault-ethereum_{{.Version}}
env:
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64
- id: vault-ethereum-windows-amd64
ldflags: -s -w -X github.com/immutability-io/vault-ethereum/pkg/version.Version={{.Version}} -X github.com/immutability-io/vault-ethereum/pkg/version.BuildDate={{.Date}} -X github.com/immutability-io/vault-ethereum/pkg/version.CommitHash={{ .ShortCommit }}
binary: vault-ethereum_{{.Version}}
env:
- CGO_ENABLED=1
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
archives:
- format: zip
name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}_{{.Arch}}"
files:
- README.md
- LICENSE

0 comments on commit b8ba0d6

Please sign in to comment.