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

Add goreleaser commands to Makefile and create a Github Action to run goreleaser #5908

Merged
merged 9 commits into from
Jul 30, 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
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow creates a release using goreleaser
# via the 'make release' command.

name: Create release

on:
workflow_dispatch:
inputs:
release_tag:
description: 'The desired tag for the release (e.g. v0.1.0).'
required: true

permissions:
contents: write

jobs:
release:
name: Create release
runs-on: self-hosted
steps:
-
name: Check out repository code
uses: actions/checkout@v3
with:
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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ blocks.db
# Ignore binary created from localosmosis scripts
tests/cl-genesis-positions/script
tests/cl-genesis-positions/*.json

# Release folder
dist/
69 changes: 21 additions & 48 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ project_name: osmosisd

env:
- CGO_ENABLED=1
- COSMWASM_VERSION=1.2.3

builds:
- id: osmosisd-darwin-amd64
main: ./cmd/osmosisd/main.go
binary: osmosisd
hooks:
pre:
- wget https://github.com/CosmWasm/wasmvm/releases/download/v{{ .Env.COSMWASM_VERSION }}/libwasmvmstatic_darwin.a -O /lib/libwasmvmstatic_darwin.a
- 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
Expand Down Expand Up @@ -39,7 +38,7 @@ builds:
binary: osmosisd
hooks:
pre:
- wget https://github.com/CosmWasm/wasmvm/releases/download/v{{ .Env.COSMWASM_VERSION }}/libwasmvmstatic_darwin.a -O /lib/libwasmvmstatic_darwin.a
- wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvmstatic_darwin.a -O /lib/libwasmvmstatic_darwin.a
env:
- CC=oa64-clang
- CGO_LDFLAGS=-L/lib
Expand Down Expand Up @@ -68,7 +67,7 @@ builds:
binary: osmosisd
hooks:
pre:
- wget https://github.com/CosmWasm/wasmvm/releases/download/v{{ .Env.COSMWASM_VERSION }}/libwasmvm_muslc.x86_64.a -O /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.a
- 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
goos:
- linux
goarch:
Expand Down Expand Up @@ -97,7 +96,7 @@ builds:
binary: osmosisd
hooks:
pre:
- wget https://github.com/CosmWasm/wasmvm/releases/download/v{{ .Env.COSMWASM_VERSION }}/libwasmvm_muslc.aarch64.a -O /usr/lib/aarch64-linux-gnu/libwasmvm_muslc.a
- 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:
Expand Down Expand Up @@ -126,61 +125,36 @@ universal_binaries:
ids:
- osmosisd-darwin-amd64
- osmosisd-darwin-arm64
replace: true
name_template: "{{.ProjectName}}"
replace: false

archives:
- id: zipped
builds:
- osmosisd-darwin-universal
- osmosisd-linux-amd64
- osmosisd-linux-arm64
name_template: "{{.ProjectName}}-{{ .Os }}-{{ .Arch }}"
- osmosisd-darwin-amd64
- osmosisd-darwin-arm64
name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
format: tar.gz
files:
- none*
- id: binaries
builds:
- osmosisd-darwin-universal
- osmosisd-linux-amd64
- osmosisd-linux-arm64
name_template: "{{.ProjectName}}-{{ .Os }}-{{ .Arch }}"
- osmosisd-linux-amd64
- osmosisd-darwin-amd64
- osmosisd-darwin-arm64
name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
format: binary
files:
- none*

checksum:
name_template: "checksums.txt"
name_template: "sha256sum.txt"
algorithm: sha256

# Docs: https://goreleaser.com/customization/homebrew/
brews:
- name: osmosisd
folder: Formula
ids:
- binaries
homepage: "https://gihub.com/osmosis-labs/osmosis"
description: "osmosisd binary to interact with the Osmosis network"
conflicts:
- osmosisd
test: |
system "#{bin}/osmosisd version"
install: |
bin.install 'osmosisd'
skip_upload: true
# # Uncomment line below if you want to try to commit the updated formula
# skip_upload: false
# repository:
# owner: osmosis-labs
# name: homebrew-osmosis
# branch: main
# pull_request:
# enabled: true
# commit_author:
# name: osmo-bot
# email: [email protected]
# commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"

# Docs: https://goreleaser.com/customization/changelog/
changelog:
skip: true
Expand All @@ -200,8 +174,8 @@ release:

## ⚡️ Binaries

Binaries for Linux (amd64 and arm64) are available below.
Darwin users can use the same universal binary for both amd64 and arm64.
Binaries for Linux and Darwin (amd64 and arm64) are available below.
Darwin users can also use the same universal binary `osmosisd-{{ .Version }}-darwin-all` for both amd64 and arm64.

#### 🔨 Build from source

Expand All @@ -218,12 +192,12 @@ release:
As an alternative to installing and running osmosisd on your system, you may run osmosisd in a Docker container.
The following Docker images are available in our registry:

| Image Name | Base | Description |
|------------|------|---------|
| `osmolabs/osmosis:{{ .Version }}` | `distroless/static-debian11` | Default image based on Distroless |
| `osmolabs/osmosis:{{ .Version }}-distroless` | `distroless/static-debian11` | Distroless image (same as above) |
| `osmolabs/osmosis:{{ .Version }}-nonroot` | `distroless/static-debian11:nonroot` | Distroless non-root image | |
| `osmolabs/osmosis:{{ .Version }}-alpine` | `alpine` | Alpine image |
| Image Name | Base | Description |
|----------------------------------------------|--------------------------------------|-----------------------------------|
| `osmolabs/osmosis:{{ .Version }}` | `distroless/static-debian11` | Default image based on Distroless |
| `osmolabs/osmosis:{{ .Version }}-distroless` | `distroless/static-debian11` | Distroless image (same as above) |
| `osmolabs/osmosis:{{ .Version }}-nonroot` | `distroless/static-debian11:nonroot` | Distroless non-root image |
| `osmolabs/osmosis:{{ .Version }}-alpine` | `alpine` | Alpine image |

Example run:

Expand All @@ -239,7 +213,6 @@ release:
draft: true

# Docs: https://goreleaser.com/customization/announce/
#
# We could automatically announce the release in
# - discord
# - slack
Expand Down
59 changes: 55 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')

LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
GO_MODULE := $(shell cat go.mod | grep "module " | cut -d ' ' -f 2)
BUILDDIR ?= $(CURDIR)/build
DOCKER := $(shell which docker)
E2E_UPGRADE_VERSION := "v17"


GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
GO_MODULE := $(shell cat go.mod | grep "module " | cut -d ' ' -f 2)
GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)

Expand Down Expand Up @@ -551,6 +551,57 @@ go-mock-update:
mockgen -source=x/gamm/types/pool.go -destination=tests/mocks/cfmm_pool.go -package=mocks
mockgen -source=x/concentrated-liquidity/types/cl_pool_extensionI.go -destination=tests/mocks/cl_pool.go -package=mocks

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

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/osmosisd \
-w /go/src/osmosisd \
$(GORELEASER_IMAGE) \
release \
--clean
else
release:
@echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'."
endif

release-dry-run:
docker run \
--rm \
-e COSMWASM_VERSION=$(COSMWASM_VERSION) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/osmosisd \
-w /go/src/osmosisd \
$(GORELEASER_IMAGE) \
release \
--clean \
--skip-publish

release-snapshot:
docker run \
--rm \
-e COSMWASM_VERSION=$(COSMWASM_VERSION) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/osmosisd \
-w /go/src/osmosisd \
$(GORELEASER_IMAGE) \
release \
--clean \
--snapshot \
--skip-validate \
--skip-publish

.PHONY: all build-linux install format lint \
go-mod-cache draw-deps clean build build-contract-tests-hooks \
test test-all test-build test-cover test-unit test-race benchmark
test test-all test-build test-cover test-unit test-race benchmark \
release release-dry-run release-snapshot