Skip to content

Commit

Permalink
ci(build): migrate goreleaser setup to use goreleaser-cross (#1733)
Browse files Browse the repository at this point in the history
Co-authored-by: ryanchristo <12519942+ryanchristo@users.noreply.github.com>
  • Loading branch information
aleem1314 and ryanchristo authored Jan 11, 2023
1 parent 873fd1c commit fdd4424
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 120 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/build-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
permissions:
contents: read

defaults:
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -26,10 +30,13 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run release setup
run: ./scripts/release-setup.sh
shell: bash
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: build --skip-validate --rm-dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build release
run: |
sudo rm -rf dist
make release
env:
GORELEASER_DEBUG: true
23 changes: 15 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,31 @@ on:
permissions:
contents: read

defaults:
run:
shell: bash

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # for goreleaser/goreleaser-action to create a GitHub release
contents: write # for docker/setup-buildx-action to create a GitHub release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run release setup
run: ./scripts/release-setup.sh
shell: bash
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and publish release
run: |
sudo rm -rf dist
make release
env:
GORELEASER_RELEASE: true
IS_STABLE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161 changes: 73 additions & 88 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,27 @@ before:

env:
- GO111MODULE=on
- CGO_ENABLED=1

builds:
# Can be added back in when https://github.com/regen-network/regen-ledger/issues/1698 is resolved
#
# - id: regen-darwin-amd64
# binary: regen
# main: ./cmd/regen
# goarch:
# - amd64
# goos:
# - darwin
# env:
# - CGO_ENABLED=1
# - CC=/home/runner/work/osxcross/target/target/bin/o64-clang
# - CXX=/home/runner/work/osxcross/target/target/bin/o64-clang++
# - LD_LIBRARY_PATH=/home/runner/work/osxcross/target/binaries/lib
# flags:
# - -mod=readonly
# - -tags="netgo ledger"
# - -trimpath
# ldflags:
# - -s -w
# - -X github.com/cosmos/cosmos-sdk/version.Name=regen
# - -X github.com/cosmos/cosmos-sdk/version.AppName=regen
# - -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,ledger
- id: regen-darwin-amd64
binary: regen
main: ./cmd/regen
goarch:
- amd64
goos:
- darwin
env:
- CC=o64-clang
- CXX=o64-clang++
flags:
- "-mod={{ .Env.MOD }}"
- "-tags={{ .Env.BUILD_TAGS }}"
- -trimpath
ldflags:
- "{{ .Env.BUILD_VARS }}"
- "{{ .Env.STRIP_FLAGS }}"
- "-linkmode={{ .Env.LINKMODE }}"

- id: regen-darwin-arm64
binary: regen
Expand All @@ -42,41 +36,36 @@ builds:
goos:
- darwin
env:
- LD_LIBRARY_PATH=/home/runner/work/osxcross/target/binaries/lib
- CC=oa64-clang
- CXX=oa64-clang++
flags:
- -mod=readonly
- -tags="netgo ledger"
- "-mod={{ .Env.MOD }}"
- "-tags={{ .Env.BUILD_TAGS }}"
- -trimpath
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=regen
- -X github.com/cosmos/cosmos-sdk/version.AppName=regen
- -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,ledger
- "{{ .Env.BUILD_VARS }}"
- "{{ .Env.STRIP_FLAGS }}"
- "-linkmode={{ .Env.LINKMODE }}"

- id: regen-linux-amd64
binary: regen
main: ./cmd/regen
env:
- CGO_ENABLED=1
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
goarch:
- amd64
goos:
- linux
flags:
- -mod=readonly
- -tags="netgo ledger"
- "-mod={{ .Env.MOD }}"
- "-tags={{ .Env.BUILD_TAGS }}"
- -trimpath
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=regen
- -X github.com/cosmos/cosmos-sdk/version.AppName=regen
- -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,ledger
- "{{ .Env.BUILD_VARS }}"
- "{{ .Env.STRIP_FLAGS }}"
- "-linkmode={{ .Env.LINKMODE }}"
- -extldflags "-lc -lrt -lpthread --static"

- id: regen-linux-arm64
binary: regen
Expand All @@ -85,82 +74,78 @@ builds:
- arm64
goos:
- linux
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
flags:
- -mod=readonly
- -tags="netgo ledger"
- "-mod={{ .Env.MOD }}"
- "-tags={{ .Env.BUILD_TAGS }}"
- -trimpath
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=regen
- -X github.com/cosmos/cosmos-sdk/version.AppName=regen
- -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,ledger
- "{{ .Env.BUILD_VARS }}"
- "{{ .Env.STRIP_FLAGS }}"
- "-linkmode={{ .Env.LINKMODE }}"
- -extldflags "-lc -lrt -lpthread --static"

- id: regen-windows-amd64
binary: regen
main: ./cmd/regen
env:
- CGO_ENABLED=1
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goarch:
- amd64
goos:
- windows
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
flags:
- -mod=readonly
- -tags="netgo ledger"
- "-mod={{ .Env.MOD }}"
- "-tags={{ .Env.BUILD_TAGS }}"
- -trimpath
- -buildmode=exe
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=regen
- -X github.com/cosmos/cosmos-sdk/version.AppName=regen
- -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,ledger
- "{{ .Env.BUILD_VARS }}"
- "{{ .Env.STRIP_FLAGS }}"
- "-linkmode={{ .Env.LINKMODE }}"

archives:
- id: regen
builds:
- regen-darwin-amd64
- regen-darwin-arm64
- regen-darwin-universal
- regen-linux-amd64
- regen-linux-arm64
- regen-windows-amd64
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
wrap_in_directory: true
format: zip
files:
- completions*
- README.md
- LICENSE
- completions/*
# Can be added back in when https://github.com/regen-network/regen-ledger/issues/1698 is resolved
#
# brews:
# - name: regen-ledger
# ids:
# - regen
# tap:
# owner: regen-network
# name: regen-ledger
# branch: homebrew-taps
# folder: "{{ .Tag }}"
# homepage: "https://www.regen.network/"
# description: "Blockchain-powered marketplace for climate solutions and planetary regenerations"
# test: |
# system "#{bin}/regen --version"
# install: |
# bin.install "regen"
# bash_completion.install "completions/regen.bash" => "regen"
# zsh_completion.install "completions/regen.zsh" => "_regen"
# fish_completion.install "completions/regen.fish"

brews:
- name: regen-ledger
ids:
- regen
tap:
owner: regen-network
name: regen-ledger
branch: homebrew-taps
folder: ${{ .Tag }}
homepage: "https://www.regen.network/"
description: "Blockchain-powered marketplace for climate solutions and planetary regenerations"
test: |
system "#{bin}/regen --version"
install: |
bin.install "regen"
bash_completion.install "completions/regen.bash" => "regen"
zsh_completion.install "completions/regen.zsh" => "_regen"
fish_completion.install "completions/regen.fish"
nfpms:
- maintainer: regen-network
description: "Blockchain-powered marketplace for climate solutions and planetary regenerations"
homepage: "https://www.regen.network/"
license: Apache2.0
license: Apache 2.0
formats:
- deb
- rpm
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

export GO111MODULE=on

BUILD_DIR ?= $(CURDIR)/build
REGEN_CMD := $(CURDIR)/cmd/regen

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
BUILD_DIR ?= $(CURDIR)/build
REGEN_CMD := $(CURDIR)/cmd/regen
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
GORELEASER_CONFIG ?= ./.goreleaser.yml
GIT_HEAD_COMMIT_LONG := $(shell git log -1 --format='%H')

ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
Expand Down Expand Up @@ -261,6 +262,12 @@ include make/tests.mk

include make/sims.mk

###############################################################################
### Release ###
###############################################################################

include make/release.mk

###############################################################################
### Documentation ###
###############################################################################
Expand Down
Loading

0 comments on commit fdd4424

Please sign in to comment.