Skip to content

Commit

Permalink
ci: integrate go releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
snobbee committed Oct 27, 2023
1 parent 9186387 commit 2d05dad
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 19 deletions.
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 }}
165 changes: 165 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
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.AppName=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.AppName=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.AppName=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.AppName=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!'
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bu
GOFLAGS:=""
GOTAGS:=ledger

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 \
Expand Down Expand Up @@ -122,3 +124,50 @@ 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) \
-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 \
-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 \
-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

0 comments on commit 2d05dad

Please sign in to comment.