Skip to content

Commit

Permalink
Merge pull request #46 from rootulp/rp/goreleaser-cross
Browse files Browse the repository at this point in the history
Try goreleaser-cross
  • Loading branch information
rootulp authored Nov 27, 2023
2 parents be3acf0 + 8af0ac5 commit 3c23a70
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ run.sh
testing/e2e/networks/*/
square/testdata
**/*.html
.release-env
**/*.DS_Store
101 changes: 71 additions & 30 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,80 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# NOTE: CGO is required for ledger support to work, however goreleaser
# technically doesn't support CGO. But it seems to work so that's cool. This
# only seems to work because we are building for a single binary. Cross
# compiling binaries for multiple distributions doesn't work and a proper
# workaround will be needed.
#
# REF: https://goreleaser.com/limitations/cgo/

# Ledger support is only available if the binary is built with CGO enabled.
# Since GoReleaser doesn't support CGO natively, our GoReleaser process builds
# binaries in a Docker image maintained by goreleaser-cross that has CGO support
# for multiple platforms. See https://github.com/goreleaser/goreleaser-cross
before:
hooks:
- go mod tidy
builds:
- main: ./cmd/celestia-appd
- id: darwin-amd64
main: ./cmd/celestia-appd
binary: celestia-appd
env:
- SDKPath={{ "github.com/cosmos/cosmos-sdk/version" }}
- CGO_ENABLED=1
# CC and CXX are required for CGO to work. See
# https://github.com/goreleaser/goreleaser-cross#supported-toolchainsplatforms
- CC=o64-clang
- CXX=o64-clang++
goarch:
- amd64
- arm64
goos:
- darwin
- linux
tags:
- ledger
ldflags:
# Ref: https://goreleaser.com/customization/templates/#common-fields
#
# .Version is the version being released
# .FullCommit is git commit hash goreleaser is using for the release
#
- -X "{{ .Env.SDKPath }}.Name=celestia-app"
- -X "{{ .Env.SDKPath }}.AppName=celestia-appd"
- -X "{{ .Env.SDKPath }}.Version={{ .Version }}"
- -X "{{ .Env.SDKPath }}.Commit={{ .FullCommit }}"
- id: darwin-arm64
main: ./cmd/celestia-appd
binary: celestia-appd
env:
- SDKPath={{ "github.com/cosmos/cosmos-sdk/version" }}
- CGO_ENABLED=1
# CC and CXX are required for CGO to work. See
# https://github.com/goreleaser/goreleaser-cross#supported-toolchainsplatforms
- CC=oa64-clang
- CXX=oa64-clang++
goarch:
- arm64
goos:
- darwin
tags:
- ledger
ldflags:
# Ref: https://goreleaser.com/customization/templates/#common-fields
# .Version is the version being released
# .FullCommit is git commit hash goreleaser is using for the release
- -X "{{ .Env.SDKPath }}.Name=celestia-app"
- -X "{{ .Env.SDKPath }}.AppName=celestia-appd"
- -X "{{ .Env.SDKPath }}.Version={{ .Version }}"
- -X "{{ .Env.SDKPath }}.Commit={{ .FullCommit }}"

# - main: ./cmd/celestia-appd
# binary: celestia-appd
# env:
# - SDKPath={{ "github.com/cosmos/cosmos-sdk/version" }}
# goarch:
# - amd64
# - arm64
# goos:
# - darwin
# - linux
# tags:
# - ledger
# ldflags:
# # Ref: https://goreleaser.com/customization/templates/#common-fields
# # .Version is the version being released
# # .FullCommit is git commit hash goreleaser is using for the release
# - -X "{{ .Env.SDKPath }}.Name=celestia-app"
# - -X "{{ .Env.SDKPath }}.AppName=celestia-appd"
# - -X "{{ .Env.SDKPath }}.Version={{ .Version }}"
# - -X "{{ .Env.SDKPath }}.Commit={{ .FullCommit }}"
dist: ./build/goreleaser
archives:
- format: tar.gz
Expand All @@ -47,20 +87,21 @@ archives:
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
checksum:
name_template: "checksums.txt"
signs:
- artifacts: checksum
args:
[
"--batch",
"-u",
"{{ .Env.GPG_FINGERPRINT }}",
"--output",
"${signature}",
"--detach-sign",
"${artifact}",
]
# Disable checksum and signing for now
# checksum:
# name_template: "checksums.txt"
# signs:
# - artifacts: checksum
# args:
# [
# "--batch",
# "-u",
# "{{ .Env.GPG_FINGERPRINT }}",
# "--output",
# "${signature}",
# "--detach-sign",
# "${artifact}",
# ]
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
Expand Down
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,33 @@ goreleaser-build:
goreleaser-release:
goreleaser release --clean --fail-fast --skip-publish
.PHONY: goreleaser-release

PACKAGE_NAME := github.com/rootulp/celestia-app
GOLANG_CROSS_VERSION ?= v1.21.4

release-dry-run:
@docker run \
--rm \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip=validate --skip=publish
.PHONY: release-dry-run

release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
docker run \
--rm \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean
.PHONY: release

0 comments on commit 3c23a70

Please sign in to comment.