From 5cfad44ef6d96326167fd0e1490c57ed7bba5a9e Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 19 Oct 2023 15:52:23 -0400 Subject: [PATCH] feat: add cosmo wasm vm to release --- .github/workflows/release.yml | 26 ++---- .goreleaser.yml | 171 +++++++++++++++++++++++++++++----- Makefile | 52 +++++++++++ 3 files changed, 209 insertions(+), 40 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2accdcad..529cbbc2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,31 +26,21 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.event.inputs.release_tag }} + - uses: actions/setup-go@v4 with: go-version: "1.21" cache: true - - name: Set ENV - run: echo "COMET_VERSION=$(go list -m github.com/cometbft/cometbft | sed 's:.* ::')" >> $GITHUB_ENV - - - name: goreleaser test-build - uses: goreleaser/goreleaser-action@v5 - if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Enable:ReleaseBuild') - with: - version: latest - args: build --clean --skip=validate - env: - COMET_VERSION: ${{ env.COMET_VERSION }} - - name: Release - uses: goreleaser/goreleaser-action@v5 - if: startsWith(github.ref, 'refs/tags/') - with: - version: latest - args: release --clean + - name: Make release and publish + run: | + make release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMET_VERSION: ${{ env.COMET_VERSION }} + - name: Cleanup + run: | + sudo rm -rf dist build_push_node_image: name: Build and Push Docker Image to GHCR diff --git a/.goreleaser.yml b/.goreleaser.yml index d48ca973..b7e0ad23 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,44 +1,171 @@ -project_name: seda +project_name: seda-chain env: - CGO_ENABLED=1 # - GOOS=linux # for local m1 mac run - -before: - hooks: - - go mod download - builds: - - main: ./cmd/seda-chaind - id: "seda-chaind" + - id: seda-chaind-linux-amd64 + main: ./cmd/seda-chaind/main.go binary: seda-chaind - mod_timestamp: "{{ .CommitTimestamp }}" + hooks: + pre: + - wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvm_muslc.x86_64.a -O /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.a + goos: + - linux + goarch: + - amd64 + env: + - CC=x86_64-linux-gnu-gcc flags: - - -tags=badgerdb ledger netgo + - -mod=readonly - -trimpath ldflags: - - -s -w -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X github.com/cosmos/cosmos-sdk/version.Name=seda-chain -X github.com/cosmos/cosmos-sdk/version.AppName=sedad-chain -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/cometbft/cometbft/version.TMCoreSemVer={{ .Env.COMET_VERSION }} + - -X github.com/cosmos/cosmos-sdk/version.Name=seda-chain + - -X github.com/cosmos/cosmos-sdk/version.AppName=seda-chaind + - -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }} + - -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }} + - -X main.date={{ .CommitDate }} + - -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo + - -w -s + - -linkmode=external + - -extldflags '-Wl,-z,muldefs -static -lm' + tags: + - netgo + - ledger + - muslc + - osusergo +# + - id: seda-chaind-linux-arm64 + main: ./cmd/seda-chaind/main.go + binary: seda-chaind + hooks: + pre: + - wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvm_muslc.aarch64.a -O /usr/lib/aarch64-linux-gnu/libwasmvm_muslc.a goos: - linux + goarch: + - arm64 + env: + - CC=aarch64-linux-gnu-gcc + flags: + - -mod=readonly + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=seda-chain + - -X github.com/cosmos/cosmos-sdk/version.AppName=seda-chaind + - -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,muslc,osusergo + - -w -s + - -linkmode=external + - -extldflags '-Wl,-z,muldefs -static -lm' + tags: + - netgo + - ledger + - muslc + - osusergo + + - id: seda-chaind-darwin-amd64 + main: ./cmd/seda-chaind/main.go + binary: seda-chaind + hooks: + pre: + - wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvmstatic_darwin.a -O /lib/libwasmvmstatic_darwin.a + env: + - CC=o64-clang + - CGO_LDFLAGS=-L/lib + goos: + - darwin goarch: - amd64 -# - arm64 # github only supports linux @ amd64 :'( + flags: + - -mod=readonly + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=seda-chain + - -X github.com/cosmos/cosmos-sdk/version.AppName=seda-chaind + - -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,static_wasm + - -w -s + - -linkmode=external + tags: + - netgo + - ledger + - static_wasm + + - id: seda-chaind-chaind-darwin-arm64 + main: ./cmd/seda-chaind/main.go + binary: seda-chaind + hooks: + pre: + - wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvmstatic_darwin.a -O /lib/libwasmvmstatic_darwin.a + env: + - CC=oa64-clang + - CGO_LDFLAGS=-L/lib + goos: + - darwin + goarch: + - arm64 + flags: + - -mod=readonly + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=seda-chain + - -X github.com/cosmos/cosmos-sdk/version.AppName=seda-chaind + - -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,static_wasm + - -w -s + - -linkmode=external + tags: + - netgo + - ledger + - static_wasm + + +universal_binaries: + - id: seda-chaind-darwin-universal + ids: + - seda-chaind-darwin-amd64 + - seda-chaind-darwin-arm64 + replace: false archives: - - id: tarball + - id: zipped + builds: + - seda-chaind-linux-amd64 + - seda-chaind-linux-arm64 + # - seda-chaind-darwin-universal + # - seda-chaind-darwin-amd64 + # - seda-chaind-darwin-arm64 + name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" format: tar.gz - wrap_in_directory: false # must not wrap into directory to support cosmwasm - name_template: "{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" files: - - LICENSE - - README.md - -snapshot: - name_template: SNAPSHOT-{{ .Commit }} + - none* + - id: binaries + builds: + - seda-chaind-linux-amd64 + - seda-chaind-linux-arm64 + # - seda-chaind-darwin-universal + # - seda-chaind-darwin-amd64 + # - seda-chaind-darwin-arm64 + name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: binary + files: + - none* checksum: - name_template: SHA256SUMS-v{{.Version}}.txt + name_template: "sha256sum.txt" algorithm: sha256 +# Docs: https://goreleaser.com/customization/changelog/ changelog: - skip: false \ No newline at end of file + skip: true + +# Docs: https://goreleaser.com/customization/release/ +release: + github: + owner: seda-chain + name: seda-chain + replace_existing_draft: true diff --git a/Makefile b/Makefile index 977a1859..85e5d907 100644 --- a/Makefile +++ b/Makefile @@ -228,3 +228,55 @@ cover-html: test-unit-cover .PHONY: cover-html run-tests $(TEST_TARGETS) +############################################################################### +### Release ### +############################################################################### + +GO_VERSION=1.21 +GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) +COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') +ifdef GITHUB_TOKEN +release: + docker run \ + --rm \ + -e GITHUB_TOKEN=$(GITHUB_TOKEN) \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/seda-chaind \ + -w /go/src/seda-chaind \ + $(GORELEASER_IMAGE) \ + release \ + --clean +else +release: + @echo "Error: GITHUB_TOKEN variable required to 'make release'." + +endif + +release-dry-run: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/seda-chaind \ + -w /go/src/seda-chaind \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --skip=publish + +release-snapshot: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/seda-chaind \ + -w /go/src/seda-chaind \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --snapshot \ + --skip-validate\ + --skip-publish + +.PHONY: release release-dry-run release-snapshot \ No newline at end of file