Skip to content

Commit

Permalink
ci: fix release git workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
arnabghose997 committed Dec 10, 2023
1 parent 9af2271 commit c35d084
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 54 deletions.
32 changes: 9 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,19 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21

- name: Generate Release Files (darwin/arm64)
run: make release-darwin-arm64

- name: Generate Release Files (darwin/amd64)
run: make release-darwin-amd64

- name: Generate Release Files (linux/arm64)
run: make release-linux-arm64
- name: Make release
run: |
make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Release Files (linux/amd64)
run: make release-linux-amd64

- name: Publish to Github
uses: softprops/action-gh-release@v1
with:
files: release/*
prerelease: false
generate_release_notes: true
- name: Clean release folder
run: |
sudo rm -rf dist
publish-docker:
name: Publish Docker Image (linux/amd64)
Expand Down
126 changes: 126 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
project_name: hid-node

env:
- CGO_ENABLED=1

before:
hooks:
- go mod tidy -compat=1.21

builds:
- id: ubuntu-amd64
main: ./cmd/hid-noded
binary: hid-noded
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
env:
- CC=x86_64-linux-gnu-gcc
goos:
- linux
goarch:
- amd64
flags:
- -mod=readonly
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=hid-node
- -X github.com/cosmos/cosmos-sdk/version.AppName=hid-node
- -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,muslc,osusergo
- -linkmode=external
- -extldflags '-Wl,-z,muldefs -static -lm'
tags:
- netgo
- muslc
- osusergo

- id: ubuntu-arm64
main: ./cmd/hid-noded
binary: hid-noded
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
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=hid-node
- -X github.com/cosmos/cosmos-sdk/version.AppName=hid-node
- -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,muslc,osusergo
- -linkmode=external
- -extldflags '-Wl,-z,muldefs -static -lm'
tags:
- netgo
- muslc
- osusergo

- id: darwin-amd64
main: ./cmd/hid-noded
binary: hid-noded
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
flags:
- -mod=readonly
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=hid-node
- -X github.com/cosmos/cosmos-sdk/version.AppName=hid-node
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -linkmode=external
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,static_wasm
tags:
- netgo
- static_wasm

archives:
- id: release-archives
format: tar.gz
wrap_in_directory: true
name_template: "{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
files:
- LICENSE
- README.md

checksum:
name_template: 'checksums.txt'
algorithm: sha256

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

release:
github:
owner: hypersign-protocol
name: hid-node

draft: false
prerelease: false
mode: append
header: |
# Release Notes
62 changes: 31 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,35 +82,35 @@ docker-run:
###############################################################################
### Release ###
###############################################################################
GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
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/hid-noded \
-w /go/src/hid-noded \
$(GORELEASER_IMAGE) \
release \
--clean
else
release:
@echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'."
endif

release-darwin-arm64: go-version-check
@echo "Generating release files for darwin/arm64"
@mkdir -p release
@GOOS=darwin GOARCH=arm64 go build $(BUILD_FLAGS) ./cmd/hid-noded
@tar -czf release/hid_noded_$(VERSION)_darwin_arm64.tar.gz hid-noded
@sha256sum release/hid_noded_$(VERSION)_darwin_arm64.tar.gz >> release/release_darwin_arm64_checksum
@echo "Release files generated!"

release-darwin-amd64: go-version-check
@echo "Generating release files for darwin/amd64"
@mkdir -p release
@GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) ./cmd/hid-noded
@tar -czf release/hid_noded_$(VERSION)_darwin_amd64.tar.gz hid-noded
@sha256sum release/hid_noded_$(VERSION)_darwin_amd64.tar.gz >> release/release_darwin_amd64_checksum
@echo "Release files generated!"

release-linux-arm64: go-version-check
@echo "Generating release files for linux/arm64"
@mkdir -p release
@GOOS=linux GOARCH=arm64 go build $(BUILD_FLAGS) ./cmd/hid-noded
@tar -czf release/hid_noded_$(VERSION)_linux_arm64.tar.gz hid-noded
@sha256sum release/hid_noded_$(VERSION)_linux_arm64.tar.gz >> release/release_linux_arm64_checksum
@echo "Release files generated!"

release-linux-amd64: go-version-check
@echo "Generating release files for linux/amd64"
@mkdir -p release
@GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) ./cmd/hid-noded
@tar -czf release/hid_noded_$(VERSION)_linux_amd64.tar.gz hid-noded
@sha256sum release/hid_noded_$(VERSION)_linux_amd64.tar.gz >> release/release_linux_amd64_checksum
@echo "Release files generated!"
release-dry-run:
docker run \
--rm \
-e COSMWASM_VERSION=$(COSMWASM_VERSION) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/hid-noded \
-w /go/src/hid-noded \
$(GORELEASER_IMAGE) \
release \
--clean \
--skip=publish

0 comments on commit c35d084

Please sign in to comment.