Skip to content

Commit

Permalink
Attempting to use goreleaser-cross (#1061)
Browse files Browse the repository at this point in the history
* Attempting to use goreleaser-cross

* Removing linux amd64 env

* binary is rly

* Ignore the .release-env and dist/ directory

* Removing dry-run before release
  • Loading branch information
joeabbey authored Dec 14, 2022
1 parent 10e855c commit c29e632
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 14 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ 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: setup release environment
run: |-
echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env
- name: release publish
run: make release
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
/vendor
65 changes: 59 additions & 6 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,73 @@
project_name: Cosmos Relayer

env:
# Require use of Go modules.
- GO111MODULE=on

builds:
- id: "relayer"
- id: darwin-amd64
main: ./main.go
binary: rly
goos:
- darwin
goarch:
- amd64
env:
- 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: rly
goos:
- darwin
goarch:
- arm64
env:
- 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: 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: rly
goos:
- linux
goarch:
- arm64
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
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
Expand Down
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c29e632

Please sign in to comment.