From f27f26a36341dfbc3cfb33b24cbaf08a918e24ca Mon Sep 17 00:00:00 2001 From: Joe Abbey Date: Wed, 14 Dec 2022 03:44:48 -1000 Subject: [PATCH 1/5] Attempting to use goreleaser-cross --- .github/workflows/release.yml | 14 ++++---- .goreleaser.yaml | 66 +++++++++++++++++++++++++++++++---- Makefile | 43 +++++++++++++++++++++++ 3 files changed, 110 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6833feadb..1e8fea0e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,10 +21,10 @@ jobs: - run: echo https://github.com/cosmos/relayer/blob/${GITHUB_REF#refs/tags/}/CHANGELOG.md#${GITHUB_REF#refs/tags/} > ../release_notes.md - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: release dry run + run: make release-dry-run + - name: setup release environment + run: |- + echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env + - name: release publish + run: make release diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 34ead3bca..29ea7b989 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,20 +1,74 @@ project_name: Cosmos Relayer -env: - # Require use of Go modules. - - GO111MODULE=on - builds: - - id: "relayer" + - id: darwin-amd64 main: ./main.go + binary: golang-cross + goos: + - darwin + goarch: + - amd64 + env: + - PKG_CONFIG_SYSROOT_DIR=/sysroot/macos/amd64 + - PKG_CONFIG_PATH=/sysroot/macos/amd64/usr/local/lib/pkgconfig + - CC=o64-clang + - CXX=o64-clang++ + flags: + - -mod=readonly ldflags: - - -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} + - -s -w -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} + - id: darwin-arm64 + main: ./main.go + binary: golang-cross goos: - darwin + goarch: + - arm64 + env: + - PKG_CONFIG_SYSROOT_DIR=/sysroot/macos/arm64 + - PKG_CONFIG_PATH=/sysroot/macos/arm64/usr/local/lib/pkgconfig + - CC=oa64-clang + - CXX=oa64-clang++ + flags: + - -mod=readonly + ldflags: + - -s -w -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} + - id: linux-amd64 + main: ./main.go + binary: golang-cross + goos: - linux goarch: - amd64 + env: + - CC=x86_64-linux-gnu-gcc + - CXX=x86_64-linux-gnu-g++ + - CGO_CFLAGS=--sysroot=/sysroot/linux/ + - CGO_LDFLAGS=--sysroot=/sysroot/linux/x86_64 + - PKG_CONFIG_SYSROOT_DIR=/sysroot/linux/x86_64 + - PKG_CONFIG_PATH=/sysroot/linux/x86_64/opt/vc/lib/pkgconfig:/sysroot/linux/x86_64/usr/lib/x86_64-linux-gnu/pkgconfig:/sysroot/linux/x86_64/usr/lib/pkgconfig:/sysroot/linux/x86_64/usr/local/lib/pkgconfig + flags: + - -mod=readonly + ldflags: + - -s -w -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} + - id: linux-arm64 + main: ./main.go + binary: golang-cross + goos: + - linux + goarch: - arm64 + env: + - CC=aarch64-linux-gnu-gcc + - CXX=aarch64-linux-gnu-g++ + - CGO_CFLAGS=--sysroot=/sysroot/linux/ + - CGO_LDFLAGS=--sysroot=/sysroot/linux/aarch64 + - PKG_CONFIG_SYSROOT_DIR=/sysroot/linux/aarch64 + - PKG_CONFIG_PATH=/sysroot/linux/aarch64/opt/vc/lib/pkgconfig:/sysroot/linux/aarch64/usr/lib/aarch64-linux-gnu/pkgconfig:/sysroot/linux/aarch64/usr/lib/pkgconfig:/sysroot/linux/aarch64/usr/local/lib/pkgconfig + flags: + - -mod=readonly + ldflags: + - -s -w -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} checksum: name_template: SHA256SUMS-{{.Version}}.txt diff --git a/Makefile b/Makefile index 9ebb729f5..013c62c61 100644 --- a/Makefile +++ b/Makefile @@ -108,3 +108,46 @@ build-gaia: @gaiad version --long .PHONY: two-chains test test-integration ibctest install build lint coverage clean + +PACKAGE_NAME := github.com/cosmos/relayer +GOLANG_CROSS_VERSION ?= v1.18.3 + +SYSROOT_DIR ?= sysroots +SYSROOT_ARCHIVE ?= sysroots.tar.bz2 + +.PHONY: sysroot-pack +sysroot-pack: + @tar cf - $(SYSROOT_DIR) -P | pv -s $[$(du -sk $(SYSROOT_DIR) | awk '{print $1}') * 1024] | pbzip2 > $(SYSROOT_ARCHIVE) + +.PHONY: sysroot-unpack +sysroot-unpack: + @pv $(SYSROOT_ARCHIVE) | pbzip2 -cd | tar -xf - + +.PHONY: release-dry-run +release-dry-run: + @docker run \ + --rm \ + -e CGO_ENABLED=1 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -v `pwd`/sysroot:/sysroot \ + -w /go/src/$(PACKAGE_NAME) \ + goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ + --rm-dist --skip-validate --skip-publish + +.PHONY: release +release: + @if [ ! -f ".release-env" ]; then \ + echo "\033[91m.release-env is required for release\033[0m";\ + exit 1;\ + fi + docker run \ + --rm \ + -e CGO_ENABLED=1 \ + --env-file .release-env \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -v `pwd`/sysroot:/sysroot \ + -w /go/src/$(PACKAGE_NAME) \ + goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ + release --rm-dist From edfa8c43e20f6b5e5e1e6f2ad68d890c8ef85a77 Mon Sep 17 00:00:00 2001 From: Joe Abbey Date: Wed, 14 Dec 2022 04:12:22 -1000 Subject: [PATCH 2/5] Removing linux amd64 env --- .goreleaser.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 29ea7b989..b54cfd447 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -40,13 +40,6 @@ builds: - linux goarch: - amd64 - env: - - CC=x86_64-linux-gnu-gcc - - CXX=x86_64-linux-gnu-g++ - - CGO_CFLAGS=--sysroot=/sysroot/linux/ - - CGO_LDFLAGS=--sysroot=/sysroot/linux/x86_64 - - PKG_CONFIG_SYSROOT_DIR=/sysroot/linux/x86_64 - - PKG_CONFIG_PATH=/sysroot/linux/x86_64/opt/vc/lib/pkgconfig:/sysroot/linux/x86_64/usr/lib/x86_64-linux-gnu/pkgconfig:/sysroot/linux/x86_64/usr/lib/pkgconfig:/sysroot/linux/x86_64/usr/local/lib/pkgconfig flags: - -mod=readonly ldflags: From 56989890a417a8d85416e945959be00ca60478b0 Mon Sep 17 00:00:00 2001 From: Joe Abbey Date: Wed, 14 Dec 2022 05:04:51 -1000 Subject: [PATCH 3/5] binary is rly --- .goreleaser.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b54cfd447..b39a7443c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -3,7 +3,7 @@ project_name: Cosmos Relayer builds: - id: darwin-amd64 main: ./main.go - binary: golang-cross + binary: rly goos: - darwin goarch: @@ -19,7 +19,7 @@ builds: - -s -w -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} - id: darwin-arm64 main: ./main.go - binary: golang-cross + binary: rly goos: - darwin goarch: @@ -35,18 +35,21 @@ builds: - -s -w -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} - id: linux-amd64 main: ./main.go - binary: golang-cross + binary: rly goos: - linux goarch: - amd64 + env: + - CC=x86_64-linux-gnu-gcc + - CXX=x86_64-linux-gnu-g++ flags: - -mod=readonly ldflags: - -s -w -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} - id: linux-arm64 main: ./main.go - binary: golang-cross + binary: rly goos: - linux goarch: From d4f425cc35f10845eedf1d92a6f6363ff023b625 Mon Sep 17 00:00:00 2001 From: Joe Abbey Date: Wed, 14 Dec 2022 05:22:45 -1000 Subject: [PATCH 4/5] Ignore the .release-env and dist/ directory --- .gitignore | 4 +++- .goreleaser.yaml | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 05be36dc8..835dd0cc9 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ _test/setup/valkeys/*.json _test/keys/ .DS_Store .vscode/ +dist/ +.release-env # Don't commit the vendor directory if anyone runs 'go mod vendor'. -/vendor \ No newline at end of file +/vendor diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b39a7443c..f976a7dd0 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -9,8 +9,6 @@ builds: goarch: - amd64 env: - - PKG_CONFIG_SYSROOT_DIR=/sysroot/macos/amd64 - - PKG_CONFIG_PATH=/sysroot/macos/amd64/usr/local/lib/pkgconfig - CC=o64-clang - CXX=o64-clang++ flags: @@ -25,8 +23,6 @@ builds: goarch: - arm64 env: - - PKG_CONFIG_SYSROOT_DIR=/sysroot/macos/arm64 - - PKG_CONFIG_PATH=/sysroot/macos/arm64/usr/local/lib/pkgconfig - CC=oa64-clang - CXX=oa64-clang++ flags: @@ -57,15 +53,22 @@ builds: env: - CC=aarch64-linux-gnu-gcc - CXX=aarch64-linux-gnu-g++ - - CGO_CFLAGS=--sysroot=/sysroot/linux/ - - CGO_LDFLAGS=--sysroot=/sysroot/linux/aarch64 - - PKG_CONFIG_SYSROOT_DIR=/sysroot/linux/aarch64 - - PKG_CONFIG_PATH=/sysroot/linux/aarch64/opt/vc/lib/pkgconfig:/sysroot/linux/aarch64/usr/lib/aarch64-linux-gnu/pkgconfig:/sysroot/linux/aarch64/usr/lib/pkgconfig:/sysroot/linux/aarch64/usr/local/lib/pkgconfig flags: - -mod=readonly ldflags: - -s -w -X github.com/cosmos/relayer/v2/cmd.Version={{ .Tag }} +archives: + - id: golang-cross + builds: + - darwin-amd64 + - darwin-arm64 + - linux-amd64 + - linux-arm64 + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + format: tar.gz + wrap_in_directory: true + checksum: name_template: SHA256SUMS-{{.Version}}.txt algorithm: sha256 From 6d2f6cbef38a2f038b451cd024cc7336b9bb7651 Mon Sep 17 00:00:00 2001 From: Joe Abbey Date: Wed, 14 Dec 2022 07:25:13 -1000 Subject: [PATCH 5/5] Removing dry-run before release --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e8fea0e3..e5584214d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,8 +21,6 @@ jobs: - run: echo https://github.com/cosmos/relayer/blob/${GITHUB_REF#refs/tags/}/CHANGELOG.md#${GITHUB_REF#refs/tags/} > ../release_notes.md - - name: release dry run - run: make release-dry-run - name: setup release environment run: |- echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env