From 19bc44a226ea6b7f42034ce65a1d73fb75a76530 Mon Sep 17 00:00:00 2001 From: Guillermo Paoletti Date: Fri, 29 Oct 2021 15:56:09 +0200 Subject: [PATCH] ci: fix goreleaser (#708) * testing goreleaser * removed arm64 building instructions * CGO changed * ci: reverted releaser changes, back to troian/golang-cross * using snapshot to test the release ci * testing ci code removed --- .github/workflows/goreleaser.yml | 43 ++++------ .goreleaser.yml | 135 +++++++++++++++++++++---------- Makefile | 37 +++++++++ 3 files changed, 147 insertions(+), 68 deletions(-) diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index a2b9d343..9daa5f2b 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -1,38 +1,27 @@ -# This workflow helps with creating releases. -# This job will only be triggered when a tag (vX.X.x) is pushed -name: Release +name: goreleaser + 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 - + - "v*.*.*" jobs: - release: + goreleaser: runs-on: ubuntu-latest + environment: release steps: - - uses: actions/checkout@v2.3.5 + - uses: actions/checkout@v2 with: - fetch-depth: 0 - - uses: actions/setup-go@v2.1.4 + submodules: true + - name: Set up Go + uses: actions/setup-go@v2 with: go-version: 1.17 - - name: Set Env - run: echo "TM_VERSION=$(go list -m github.com/tendermint/tendermint | sed 's:.* ::')" >> $GITHUB_ENV - - name: Build - uses: goreleaser/goreleaser-action@v2.8.0 - if: ${{ github.event_name == 'pull_request' }} - with: - version: latest - args: build --rm-dist --skip-validate # skip validate skips initial sanity checks in order to be able to fully run - env: - TM_VERSION: ${{ env.TM_VERSION }} - - name: Release - uses: goreleaser/goreleaser-action@v2.8.0 - if: startsWith(github.ref, 'refs/tags/') - with: - version: latest - args: release --rm-dist --release-notes ./RELEASE_NOTES.md + - name: release dry run + run: make release-dry-run + - name: setup release environment env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TM_VERSION: ${{ env.TM_VERSION }} \ No newline at end of file + run: |- + echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env + - name: release publish + run: make release \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 9a6ff460..081cc583 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,56 +1,109 @@ ---- -project_name: ethermint - -env: - - GO111MODULE=on - before: hooks: - - go mod tidy + - go mod download builds: - - main: ./cmd/ethermintd - id: "ethermintd" - binary: ethermintd - mod_timestamp: "{{ .CommitTimestamp }}" - flags: - - -tags=netgo ledger - - -trimpath + - id: "ethermintd-darwin" + main: ./cmd/ethermintd + binary: bin/ethermintd env: - - CGO_ENABLED=0 - ldflags: - - -s -w -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -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 }} -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger -X github.com/tendermint/tendermint/version.TMCoreSemVer={{ .Env.TM_VERSION }} + - 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 - - arm + 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-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: - - format: tar.gz - wrap_in_directory: true - format_overrides: - - goos: windows - format: zip - name_template: "{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" - files: - - LICENSE - - README.md - -release: - github: - owner: tharsis - name: ethermint - name_template: "v{{.Version}}" - +- 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 + - ethermintd-linux-arm64 + checksum: - name_template: SHA256SUMS-v{{.Version}}.txt - algorithm: sha256 - -snapshot: - name_template: SNAPSHOT-{{ .Commit }} - + name_template: 'checksums.txt' changelog: - skip: true + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +snapshot: + name_template: "{{ .Tag }}-next" \ No newline at end of file diff --git a/Makefile b/Makefile index 2568f4b4..ee820edd 100755 --- a/Makefile +++ b/Makefile @@ -148,6 +148,43 @@ build-all: tools build lint test .PHONY: distclean clean build-all +############################################################################### +### Releasing ### +############################################################################### + +PACKAGE_NAME:=github.com/tharsis/ethermint +GOLANG_CROSS_VERSION = v1.17.1 +GOPATH ?= '$(HOME)/go' +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) \ + ghcr.io/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) \ + ghcr.io/troian/golang-cross:${GOLANG_CROSS_VERSION} \ + release --rm-dist --skip-validate + +.PHONY: release-dry-run release + ############################################################################### ### Tools & Dependencies ### ###############################################################################