Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: integrate go releaser #3423

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 46 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
# 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/[email protected]
- 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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ smart-contracts/yarn-error.log
test/integration/output.json
test/integration/sifchainrelayerdb/*
*.log

dist
169 changes: 169 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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!'
88 changes: 72 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Sifchain/sifnode

go 1.18
go 1.20

require (
github.com/BurntSushi/toml v1.2.1
Expand Down
Loading