diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000000..70365ef179 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,26 @@ +name: Release +# This workflow helps with creating releases. +# This job will only be triggered when a tag (vX.X.x) is pushed +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16 + - name: Unshallow + run: git fetch --prune --unshallow + - name: Create release + uses: goreleaser/goreleaser-action@v2.6.1 + with: + args: release --rm-dist --release-notes ./RELEASE_CHANGELOG.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000000..1cab42f1dd --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,111 @@ +before: + hooks: + - go mod download + +builds: + - id: "ethermintd-darwin" + main: ./cmd/ethermintd + binary: bin/ethermintd + env: + - CGO_ENABLED=1 + - CC=o64-clang + - CXX=o64-clang++ + goos: + - darwin + goarch: + - amd64 + flags: + - -tags=cgo + ldflags: + - -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}} + - id: "ethermintd-darwin-arm64" + main: ./cmd/ethermintd + binary: bin/ethermintd + env: + - CGO_ENABLED=1 + - CC=oa64-clang + - CXX=oa64-clang++ + goos: + - darwin + goarch: + - arm64 + flags: + - -tags=cgo + ldflags: + - -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}} + - id: "ethermintd-linux" + main: ./cmd/ethermintd + binary: bin/ethermintd + env: + - CGO_ENABLED=1 + - CC=gcc + - CXX=g++ + goos: + - linux + goarch: + - amd64 + flags: + - -tags=cgo + ldflags: + - -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}} + # FIXME: panicwrap 1.3.2 don't support linux-arm64 + # - id: "ethermintd-linux-arm64" + # main: ./cmd/ethermintd + # binary: bin/ethermintd + # env: + # - CGO_ENABLED=1 + # - CC=aarch64-linux-gnu-gcc + # - CXX=aarch64-linux-gnu-g++ + # goos: + # - linux + # goarch: + # - arm64 + # flags: + # - -tags=cgo + # ldflags: + # - -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}} + - id: "ethermintd-windows" + main: ./cmd/ethermintd + binary: bin/ethermintd + env: + - CGO_ENABLED=1 + - CC=x86_64-w64-mingw32-gcc + - CXX=x86_64-w64-mingw32-g++ + goos: + - windows + goarch: + - amd64 + flags: + - -tags=cgo + - -buildmode=exe + ldflags: + - -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}} + +archives: +- name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + replacements: + darwin: Darwin + linux: Linux + windows: Windows + amd64: x86_64 + format_overrides: + - goos: windows + format: zip + builds: + - ethermintd-darwin + - ethermintd-darwin-arm64 + - ethermintd-windows + - ethermintd-linux + # FIXME panicwrap 1.3.2 don't support linux-arm64 + # - ethermintd-linux-arm64 + +checksum: + name_template: 'checksums.txt' +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +snapshot: + name_template: "{{ .Tag }}-next" diff --git a/Makefile b/Makefile index b1a58a2859..47d496012d 100755 --- a/Makefile +++ b/Makefile @@ -519,3 +519,36 @@ else endif .PHONY: build-docker-local-ethermint localnet-start localnet-stop + +# release +PACKAGE_NAME:=github.com/tharsis/ethermint +GOLANG_CROSS_VERSION = v1.16.4 +release-dry-run: + docker run \ + --rm \ + --privileged \ + -e CGO_ENABLED=1 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -v ${GOPATH}/pkg:/go/pkg \ + -w /go/src/$(PACKAGE_NAME) \ + troian/golang-cross:${GOLANG_CROSS_VERSION} \ + --rm-dist --skip-validate --skip-publish + +release: + @if [ ! -f ".release-env" ]; then \ + echo "\033[91m.release-env is required for release\033[0m";\ + exit 1;\ + fi + docker run \ + --rm \ + --privileged \ + -e CGO_ENABLED=1 \ + --env-file .release-env \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -w /go/src/$(PACKAGE_NAME) \ + troian/golang-cross:${GOLANG_CROSS_VERSION} \ + release --rm-dist --skip-validate + +.PHONY: release-dry-run release