diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a700865e12..e083601e8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,25 +1,52 @@ -name: Release +# name: Release -on: - release: - types: - - published +# on: +# release: +# types: +# - published + +# jobs: +# dispatch: +# runs-on: ubuntu-latest +# steps: +# - name: Get the tag +# id: release_tag +# run: echo ::set-output name=name::${GITHUB_REF/refs\/tags\//} + +# - uses: convictional/trigger-workflow-and-wait@v1.6.1 +# with: +# owner: sifchain +# repo: sifchain-chainops +# github_token: ${{ secrets.GIT_PAT }} +# workflow_file_name: sifnode-release.yml +# client_payload: '{ "release_tag": "${{ steps.release_tag.outputs.name }}" }' +# propagate_failure: false +# trigger_workflow: true +# wait_workflow: true +# This workflow creates a release using goreleaser +# via the 'make release' command. + +name: Create release +on: + push: + tags: + - v* +permissions: + contents: write jobs: - dispatch: + release: + name: Create release runs-on: ubuntu-latest steps: - - name: Get the tag - id: release_tag - run: echo ::set-output name=name::${GITHUB_REF/refs\/tags\//} - - - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Check out repository code + uses: actions/checkout@v3 with: - owner: sifchain - repo: sifchain-chainops - github_token: ${{ secrets.GIT_PAT }} - workflow_file_name: sifnode-release.yml - client_payload: '{ "release_tag": "${{ steps.release_tag.outputs.name }}" }' - propagate_failure: false - trigger_workflow: true - wait_workflow: true + fetch-depth: 0 + ref: ${{ github.event.inputs.release_tag }} + - name: Make release + run: | + sudo rm -rf dist + make release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 573cafffc8..9c1a9f73b8 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ smart-contracts/yarn-error.log test/integration/output.json test/integration/sifchainrelayerdb/* *.log + +dist \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000000..49758a9ff3 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,169 @@ +project_name: sifnoded +env: + - CGO_ENABLED=1 +builds: + - id: sifnoded-darwin-amd64 + main: ./cmd/sifnoded/main.go + binary: sifnoded + env: + - CC=o64-clang + - CGO_LDFLAGS=-L/lib + goos: + - darwin + goarch: + - amd64 + flags: + - -mod=readonly + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=sifchain + - -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded + - -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded + - -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=ledger + tags: + - ledger + - id: sifnoded-darwin-arm64 + main: ./cmd/sifnoded/main.go + binary: sifnoded + 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=sifchain + - -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded + - -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded + - -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }} + - -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }} + - -X github.com/cosmos/cosmos-sdk/version.BuildTags=ledger + tags: + - ledger + - id: sifnoded-linux-amd64 + main: ./cmd/sifnoded + binary: sifnoded + goos: + - linux + goarch: + - amd64 + env: + - CC=x86_64-linux-gnu-gcc + flags: + - -mod=readonly + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=sifchain + - -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded + - -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded + - -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }} + - -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }} + - -X github.com/cosmos/cosmos-sdk/version.BuildTags=ledger + tags: + - ledger + - id: sifnoded-linux-arm64 + main: ./cmd/sifnoded + binary: sifnoded + goos: + - linux + goarch: + - arm64 + env: + - CC=aarch64-linux-gnu-gcc + flags: + - -mod=readonly + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=sifchain + - -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded + - -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded + - -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }} + - -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }} + - -X github.com/cosmos/cosmos-sdk/version.BuildTags=ledger + tags: + - ledger +universal_binaries: + - id: sifnoded-darwin-universal + ids: + - sifnoded-darwin-amd64 + - sifnoded-darwin-arm64 + replace: false +archives: + - id: zipped + builds: + - sifnoded-darwin-universal + - sifnoded-linux-amd64 + - sifnoded-linux-arm64 + - sifnoded-darwin-amd64 + - sifnoded-darwin-arm64 + name_template: "{{.ProjectName}}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: tar.gz + files: + - none* + - id: binaries + builds: + - sifnoded-darwin-universal + - sifnoded-linux-amd64 + - sifnoded-linux-arm64 + - sifnoded-darwin-amd64 + - sifnoded-darwin-arm64 + name_template: "{{.ProjectName}}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: binary + files: + - none* +checksum: + name_template: "sha256sum.txt" + algorithm: sha256 +# Docs: https://goreleaser.com/customization/changelog/ +changelog: + skip: true +# Docs: https://goreleaser.com/customization/release/ +release: + github: + owner: sifchain + name: sifnode + replace_existing_draft: true + header: | + ## Overview + + < DETAILS OF THE UPDATE > + + ## 📦 Executable Files + + Available binaries files for both Linux and Darwin (covering amd64 and arm64 architectures) are listed below. For Darwin users, a universal binary named `sifnoded-v{{ .Version }}-darwin-all` can be utilized for both amd64 and arm64. + + #### 🛠 Compile from Source + + If you wish to compile the software from its source, follow these steps: + + ```bash + git clone https://github.com/sifchain/sifnode + cd sifchain && git checkout v{{ .Version }} + make install + ``` + + ## Updates & Enhancements + + For a comprehensive list of modifications, refer to the changelog [here](https://github.com/sifchain/sifnode/blob/v{{ .Version }}/CHANGELOG.md). + name_template: "v{{.Version}}" + mode: replace + draft: true +# Docs: https://goreleaser.com/customization/announce/ +# We could automatically announce the release in +# - discord +# - slack +# - twitter +# - webhooks +# - telegram +# - reddit +# +# announce: +# discord: +# enabled: true +# message_template: 'New {{.Tag}} is out!' diff --git a/Makefile b/Makefile index a2be8d12f6..6668fd8e18 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,30 @@ -CHAINNET?=betanet -BINARY?=sifnoded -GOPATH?=$(shell go env GOPATH) -GOBIN?=$(GOPATH)/bin -NOW=$(shell date +'%Y-%m-%d_%T') -COMMIT:=$(shell git log -1 --format='%H') -VERSION:=$(shell cat version) -IMAGE_TAG?=latest +CHAINNET ?= betanet +BINARY ?= sifnoded +GOPATH ?= $(shell go env GOPATH) +GOBIN ?= $(GOPATH)/bin +NOW = $(shell date +'%Y-%m-%d_%T') +COMMIT := $(shell git log -1 --format='%H') +VERSION := $(shell cat version) +IMAGE_TAG ?= latest HTTPS_GIT := https://github.com/sifchain/sifnode.git DOCKER ?= docker DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf -GOFLAGS:="" -GOTAGS:=ledger +GOFLAGS := "" +GOTAGS := ledger -ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sifchain \ +GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2) + +LDFLAGS = -X github.com/cosmos/cosmos-sdk/version.Name=sifchain \ -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded \ -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded \ -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.Commit=$(COMMIT) \ + -X github.com/cosmos/cosmos-sdk/version.BuildTags=$(GOTAGS) -BUILD_FLAGS := -ldflags '$(ldflags)' -tags '$(GOTAGS)' +BUILD_FLAGS := -ldflags '$(LDFLAGS)' -tags '$(GOTAGS)' -BINARIES=./cmd/sifnoded ./cmd/sifgen ./cmd/ebrelayer ./cmd/siftest +BINARIES = ./cmd/sifnoded ./cmd/sifgen ./cmd/ebrelayer ./cmd/siftest all: lint install @@ -88,8 +91,8 @@ rollback: ### Protobuf ### ############################################################################### -protoVer=v0.3 -protoImageName=tendermintdev/sdk-proto-gen:$(protoVer) +protoVer = v0.3 +protoImageName = tendermintdev/sdk-proto-gen:$(protoVer) proto-all: proto-format proto-lint proto-gen @@ -122,3 +125,56 @@ proto-check-breaking: # we should turn this back on after our first release # $(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master .PHONY: proto-check-breaking + +GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) + +## release: Build binaries for all platforms and generate checksums +ifdef GITHUB_TOKEN +release: + docker run \ + --rm \ + -e GITHUB_TOKEN=$(GITHUB_TOKEN) \ + -e LDFLAGS="$(LDFLAGS)" \ + -e GOTAGS="$(GOTAGS)" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/sifnoded \ + -w /go/src/sifnoded \ + $(GORELEASER_IMAGE) \ + release \ + --clean +else +release: + @echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'." +endif + +## release-dry-run: Dry-run build process for all platforms and generate checksums +release-dry-run: + docker run \ + --rm \ + -e LDFLAGS="$(LDFLAGS)" \ + -e GOTAGS="$(GOTAGS)" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/sifnoded \ + -w /go/src/sifnoded \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --skip-publish + +## release-snapshot: Build snapshots for all platforms and generate checksums +release-snapshot: + docker run \ + --rm \ + -e LDFLAGS="$(LDFLAGS)" \ + -e GOTAGS="$(GOTAGS)" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/sifnoded \ + -w /go/src/sifnoded \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --snapshot \ + --skip-validate \ + --skip-publish + +.PHONY: release release-dry-run release-snapshot \ No newline at end of file diff --git a/go.mod b/go.mod index c08a4efc04..f6bdb18bb6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Sifchain/sifnode -go 1.18 +go 1.20 require ( github.com/BurntSushi/toml v1.2.1