From 51c4c141e8e242002286c5ef21902ae6f49e9d73 Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 11 Oct 2024 14:39:16 +1100 Subject: [PATCH 1/7] init --- .goreleaser.yml | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 51 +++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 .goreleaser.yml diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..4d33683f8 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,94 @@ +project_name: babylon + +builds: + - id: babylond-darwin-amd64 + main: ./cmd/babylond/main.go + binary: babylond + 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 + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=osmosis + - -X github.com/cosmos/cosmos-sdk/version.AppName=babylond + - -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,static_wasm + - -w -s + - -linkmode=external + tags: + - netgo + - ledger + - static_wasm + + - id: babylond-linux-amd64 + main: ./cmd/babylond/main.go + binary: babylond + 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 + goos: + - linux + goarch: + - amd64 + env: + - CC=x86_64-linux-gnu-gcc + flags: + - -mod=readonly + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=osmosis + - -X github.com/cosmos/cosmos-sdk/version.AppName=babylond + - -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,muslc,osusergo + - -w -s + - -linkmode=external + - -extldflags '-Wl,-z,muldefs -static -lm' + tags: + - netgo + - ledger + - muslc + - osusergo + +archives: + - id: zipped + builds: + - babylond-darwin-amd64 + - babylond-linux-amd64 + name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: tar.gz + files: + - none* + - id: binaries + builds: + - babylond-darwin-amd64 + - babylond-linux-amd64 + name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: binary + files: + - none* + +checksum: + name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt" + algorithm: sha256 + +release: + github: + owner: babylonlabs-io + name: babylon + +# Docs: https://goreleaser.com/customization/changelog/ +changelog: + disable: true + +dist: dist diff --git a/Makefile b/Makefile index a82addd1c..9aa98f922 100644 --- a/Makefile +++ b/Makefile @@ -491,3 +491,54 @@ diagrams: ## Generate diagrams for documentation update-changelog: ## Update the project changelog @echo ./scripts/update_changelog.sh $(since_tag) $(upcoming_tag) ./scripts/update_changelog.sh $(since_tag) $(upcoming_tag) + +############################################################################### +### Release ### +############################################################################### + +GO_VERSION := $(shell grep -E '^go [0-9]+\.[0-9]+' go.mod | awk '{print $$2}') +GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) +COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') + +release-dry-run: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/babylon \ + -w /go/src/babylon \ + $(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/babylon \ + -w /go/src/babylon \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --snapshot \ + --skip-validate \ + --skip-publish + +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/babylon \ + -w /go/src/babylon \ + $(GORELEASER_IMAGE) \ + release \ + --clean +else +release: + @echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'." +endif \ No newline at end of file From 25279c328c7437c8f4c381fe66997a1f99b3c976 Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 11 Oct 2024 15:35:15 +1100 Subject: [PATCH 2/7] init --- .github/workflows/ci.yml | 1 + .gitignore | 3 ++- .goreleaser.yml | 38 +++----------------------------------- CHANGELOG.md | 1 + Makefile | 3 +++ 5 files changed, 10 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20e7e5c14..611d99028 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: changelog_reminder: uses: babylonlabs-io/.github/.github/workflows/reusable_changelog_reminder.yml@v0.7.0 secrets: inherit + if: github.ref != 'refs/heads/main' docker_pipeline: uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.7.0 diff --git a/.gitignore b/.gitignore index 1919b38b7..ad778be8e 100644 --- a/.gitignore +++ b/.gitignore @@ -214,4 +214,5 @@ docs/diagrams/plantuml.jar .testnets/ .testnet/ mytestnet/ -output/ \ No newline at end of file +output/ +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml index 4d33683f8..b03e3ffd8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,59 +1,29 @@ project_name: babylon builds: - - id: babylond-darwin-amd64 - main: ./cmd/babylond/main.go - binary: babylond - 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 - - -trimpath - ldflags: - - -X github.com/cosmos/cosmos-sdk/version.Name=osmosis - - -X github.com/cosmos/cosmos-sdk/version.AppName=babylond - - -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,static_wasm - - -w -s - - -linkmode=external - tags: - - netgo - - ledger - - static_wasm - - id: babylond-linux-amd64 main: ./cmd/babylond/main.go binary: babylond 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 + - wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvm.x86_64.so -O /lib/libwasmvm_muslc.x86_64.so goos: - linux goarch: - amd64 env: - - CC=x86_64-linux-gnu-gcc + - GO111MODULE=on flags: - -mod=readonly - -trimpath ldflags: - - -X github.com/cosmos/cosmos-sdk/version.Name=osmosis + - -X github.com/cosmos/cosmos-sdk/version.Name=babylon - -X github.com/cosmos/cosmos-sdk/version.AppName=babylond - -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,muslc,osusergo - -w -s - -linkmode=external - - -extldflags '-Wl,-z,muldefs -static -lm' tags: - netgo - ledger @@ -63,7 +33,6 @@ builds: archives: - id: zipped builds: - - babylond-darwin-amd64 - babylond-linux-amd64 name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" format: tar.gz @@ -71,7 +40,6 @@ archives: - none* - id: binaries builds: - - babylond-darwin-amd64 - babylond-linux-amd64 name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" format: binary diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ba629a33..2d9603be6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Misc Improvements +* [#170](https://github.com/babylonlabs-io/babylon/pull/170) Go releaser setup * [#168](https://github.com/babylonlabs-io/babylon/pull/168) Remove devdoc from Makefile and remove unnecessary gin replace. diff --git a/Makefile b/Makefile index 9aa98f922..fccb72453 100644 --- a/Makefile +++ b/Makefile @@ -496,6 +496,7 @@ update-changelog: ## Update the project changelog ### Release ### ############################################################################### +# Below is adapted from https://github.com/osmosis-labs/osmosis/blob/main/Makefile GO_VERSION := $(shell grep -E '^go [0-9]+\.[0-9]+' go.mod | awk '{print $$2}') GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') @@ -526,6 +527,8 @@ release-snapshot: --skip-validate \ --skip-publish +# NOTE: By default, the CI will handle the release process. +# this is for manually releasing. ifdef GITHUB_TOKEN release: docker run \ From 86b66614d588bfbf49f3f3d2d5da9068c6a17cea Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 11 Oct 2024 15:38:18 +1100 Subject: [PATCH 3/7] fix --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fccb72453..3d141e776 100644 --- a/Makefile +++ b/Makefile @@ -496,7 +496,7 @@ update-changelog: ## Update the project changelog ### Release ### ############################################################################### -# Below is adapted from https://github.com/osmosis-labs/osmosis/blob/main/Makefile +# The below is adapted from https://github.com/osmosis-labs/osmosis/blob/main/Makefile GO_VERSION := $(shell grep -E '^go [0-9]+\.[0-9]+' go.mod | awk '{print $$2}') GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') From 0ed21031ea8fa044d673da562ddd85f8dd3432af Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 11 Oct 2024 15:56:36 +1100 Subject: [PATCH 4/7] phony --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 3d141e776..2c3cb41c1 100644 --- a/Makefile +++ b/Makefile @@ -501,6 +501,7 @@ GO_VERSION := $(shell grep -E '^go [0-9]+\.[0-9]+' go.mod | awk '{print $$2}') GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') +.PHONY: release-dry-run release-snapshot release release-dry-run: docker run \ --rm \ From d2a6c70ae3eedd95e48695ab75a7cb7db5a9ff14 Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 11 Oct 2024 16:07:03 +1100 Subject: [PATCH 5/7] move out changelog reminder --- .github/workflows/changelog-reminder.yml | 11 +++++++++++ .github/workflows/ci.yml | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/changelog-reminder.yml diff --git a/.github/workflows/changelog-reminder.yml b/.github/workflows/changelog-reminder.yml new file mode 100644 index 000000000..ebe2a5538 --- /dev/null +++ b/.github/workflows/changelog-reminder.yml @@ -0,0 +1,11 @@ +name: Changelog Reminder +on: + pull_request: + types: [assigned, opened, synchronize, reopened, labeled, unlabeled] + branches: + - main + +jobs: + changelog_reminder: + uses: babylonlabs-io/.github/.github/workflows/reusable_changelog_reminder.yml@v0.7.0 + secrets: inherit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 611d99028..2416f140f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,6 @@ jobs: run-integration-tests: false run-lint: true - changelog_reminder: - uses: babylonlabs-io/.github/.github/workflows/reusable_changelog_reminder.yml@v0.7.0 - secrets: inherit - if: github.ref != 'refs/heads/main' - docker_pipeline: uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.7.0 secrets: inherit From 88e92469d75001c6cf73a3042e32693ba0370fb2 Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 11 Oct 2024 16:22:45 +1100 Subject: [PATCH 6/7] change deprecated usage --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2c3cb41c1..43c3d780a 100644 --- a/Makefile +++ b/Makefile @@ -512,7 +512,7 @@ release-dry-run: $(GORELEASER_IMAGE) \ release \ --clean \ - --skip-publish + --skip=publish release-snapshot: docker run \ @@ -525,8 +525,7 @@ release-snapshot: release \ --clean \ --snapshot \ - --skip-validate \ - --skip-publish + --skip=publish,validate # NOTE: By default, the CI will handle the release process. # this is for manually releasing. From c9e8d23f68b5b6e79336356326f42a8293643cad Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 11 Oct 2024 17:37:34 +1100 Subject: [PATCH 7/7] mention goreleaser in release process --- RELEASE_PROCESS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index a1a846d09..d5c61b57c 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -110,6 +110,10 @@ git pull --tags git tag -s -a v0.10.0-rc.0 -m "Version v0.10.0-rc.0" ``` + +With every tag, the Github action will use the `goreleaser` tool to create a +release, including artifacts and their checksums. + ## Patch Release Procedure A _patch release_ is an increment of the patch number (eg: `v10.0.0` → `v10.0.1`).