Skip to content

Commit

Permalink
ci(binaries): add workflow and config to create mock binaries on rele…
Browse files Browse the repository at this point in the history
…ase (#134)
  • Loading branch information
artemijspavlovs authored Sep 20, 2024
1 parent a34bc94 commit 794042b
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release_binary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Release Binary

on:
release:
types: [created]

permissions: write-all

# This workflow creates a release using goreleaser
# via the 'make release' command.

jobs:
release:
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: go.mod

- name: Setup release environment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |-
echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env
- name: Extract TM_VERSION
run: echo "TM_VERSION=$(go list -m github.com/tendermint/tendermint | sed 's:.* ::')" >> $GITHUB_ENV

- name: Extract BECH32_PREFIX
run: echo BECH32_PREFIX=mock >> $GITHUB_ENV

- name: Release publish
run: make release
152 changes: 152 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
version: 2
before:
hooks:
- go mod download
- go mod verify

env:
- GO111MODULE=on
- BECH32_PREFIX=mock
- BUILD_TAGS=cgo,netgo,ledger

builds:
- id: "rollappd-darwin"
main: ./rollappd
binary: rollappd
env:
- CGO_ENABLED=1
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
flags:
- -tags={{.Env.BUILD_TAGS}}
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=dymension-rdk
- -X github.com/cosmos/cosmos-sdk/version.AppName=rollapp-wasm
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
- -X github.com/tendermint/tendermint/version.TMCoreSemVer={{.Env.TM_VERSION}}
- -X github.com/dymensionxyz/rollapp-wasm/app.AccountAddressPrefix={{.Env.BECH32_PREFIX}}
- -X github.com/dymensionxyz/dymension-rdk/x/rollappparams/types.Version={{.Commit}}
- -X github.com/dymensionxyz/dymint/version.Commit={{.Commit}}
- id: "rollappd-darwin-arm64"
main: ./rollappd
binary: rollappd
env:
- CGO_ENABLED=1
- CC=oa64-clang
- CXX=oa64-clang++
goos:
- darwin
goarch:
- arm64
flags:
- -tags={{.Env.BUILD_TAGS}}
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=dymension-rdk
- -X github.com/cosmos/cosmos-sdk/version.AppName=rollapp-wasm
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
- -X github.com/tendermint/tendermint/version.TMCoreSemVer={{.Env.TM_VERSION}}
- -X github.com/dymensionxyz/rollapp-wasm/app.AccountAddressPrefix={{.Env.BECH32_PREFIX}}
- -X github.com/dymensionxyz/dymension-rdk/x/rollappparams/types.Version={{.Commit}}
- -X github.com/dymensionxyz/dymint/version.Commit={{.Commit}}
- id: "rollappd-linux"
main: ./rollappd
binary: rollappd
env:
- CGO_ENABLED=1
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
goos:
- linux
goarch:
- amd64
flags:
- -tags={{.Env.BUILD_TAGS}}
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=dymension-rdk
- -X github.com/cosmos/cosmos-sdk/version.AppName=rollapp-wasm
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
- -X github.com/tendermint/tendermint/version.TMCoreSemVer={{.Env.TM_VERSION}}
- -X github.com/dymensionxyz/rollapp-wasm/app.AccountAddressPrefix={{.Env.BECH32_PREFIX}}
- -X github.com/dymensionxyz/dymension-rdk/x/rollappparams/types.Version={{.Commit}}
- -X github.com/dymensionxyz/dymint/version.Commit={{.Commit}}
- id: "rollappd-linux-arm64"
main: ./rollappd
binary: rollappd
env:
- CGO_ENABLED=1
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
goos:
- linux
goarch:
- arm64
flags:
- -tags={{.Env.BUILD_TAGS}}
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=dymension-rdk
- -X github.com/cosmos/cosmos-sdk/version.AppName=rollapp-wasm
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
- -X github.com/tendermint/tendermint/version.TMCoreSemVer={{.Env.TM_VERSION}}
- -X github.com/dymensionxyz/rollapp-wasm/app.AccountAddressPrefix={{.Env.BECH32_PREFIX}}
- -X github.com/dymensionxyz/dymension-rdk/x/rollappparams/types.Version={{.Commit}}
- -X github.com/dymensionxyz/dymint/version.Commit={{.Commit}}
# - id: "rollappd-windows"
# main: ./rollappd
# binary: rollappd
# env:
# - CGO_ENABLED=1
# - CC=x86_64-w64-mingw32-gcc
# - CXX=x86_64-w64-mingw32-g++
# goos:
# - windows
# goarch:
# - amd64
# flags:
# - -tags={{.Env.BUILD_TAGS}}
# - -buildmode=exe
# ldflags:
# - -s -w
# - -X github.com/cosmos/cosmos-sdk/version.Name=dymension-rdk
# - -X github.com/cosmos/cosmos-sdk/version.AppName=rollapp-wasm
# - -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
# - -X github.com/cosmos/cosmos-sdk/version.BuildTags={{.Env.BUILD_TAGS}}
# - -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
# - -X github.com/tendermint/tendermint/version.TMCoreSemVer={{.Env.TM_VERSION}}
# - -X github.com/dymensionxyz/rollapp-wasm/app.AccountAddressPrefix={{.Env.BECH32_PREFIX}}
# - -X github.com/dymensionxyz/dymension-rdk/x/rollappparams/types.Version={{.Commit}}
# - -X github.com/dymensionxyz/dymint/version.Commit={{.Commit}}

archives:
- name_template: '{{ .ProjectName }}_{{- title .Os }}_{{ .Arch }}'
format_overrides:
- goos: windows
format: zip
builds:
- rollappd-darwin
- rollappd-darwin-arm64
# - rollappd-windows
- rollappd-linux
- rollappd-linux-arm64

checksum:
name_template: 'checksums.txt'
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
snapshot:
name_template: "{{ .Tag }}-next"
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,44 @@ proto-gen:
proto-clean:
@echo "Cleaning proto generating docker container"
@docker rm $(containerProtoGen) || true

###############################################################################
### Releasing ###
###############################################################################

PACKAGE_NAME:=github.com/dymensionxyz/rollapp-wasm
GOLANG_CROSS_VERSION = v1.22
GOPATH ?= '$(HOME)/go'
release-dry-run:
podman run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-e TM_VERSION=$(TM_VERSION) \
-e BECH32_PREFIX=$(BECH32_PREFIX) \
-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/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip=validate --skip=publish --snapshot

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 \
-e TM_VERSION=$(TM_VERSION) \
-e BECH32_PREFIX=$(BECH32_PREFIX) \
--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/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean --skip=validate

.PHONY: release-dry-run release

0 comments on commit 794042b

Please sign in to comment.