Skip to content

Commit

Permalink
chore: add goreleaser, cleanup release process (#2549)
Browse files Browse the repository at this point in the history
* chore: add goreleaser, cleanup release process

* chore: update RELEASING.md

* chore: add RELEASE_NOTES.md; add make create-release

* chore: rm old release file

* update release process

* fix: apply review comments

* chore: update RELEASE_PROCESS.md with PR comments

* chore: add install step for goreleaser dry-run

---------

Co-authored-by: mpoke <marius.poke@posteo.de>
  • Loading branch information
2 people authored and glnro committed Jun 30, 2023
1 parent 3ded498 commit ec2323c
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 311 deletions.
126 changes: 30 additions & 96 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,34 @@
name: create release
name: "Release"

on:
push:
tags:
- "v[0-9]+\\.[0-9]+\\.[0-9]+"
- "v[0-9]+\\.[0-9]+\\.[0-9]+-rc[0-9]+"
# can be used to re-release an existing tag
workflow_dispatch:

push:
tags:
- "v[0-9]+\\.[0-9]+\\.[0-9]+"
- "v[0-9]+\\.[0-9]+\\.[0-9]+-rc[0-9]+"

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3.5.2
- name: set tag env
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: install go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
check-latest: true
- name: Build Artifacts
run: make distclean build-reproducible
- name: generate release note
run: go run ./contrib/generate_release_note/main.go ${{ env.VERSION }} ./artifacts/build_report ./CHANGELOG.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: ./releasenote
draft: true
prerelease: false
- name: Upload build_report
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/build_report
asset_name: build_report
asset_content_type: application/file
- name: Upload darwin-amd64 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/gaiad-${{ env.VERSION }}-darwin-amd64
asset_name: gaiad-${{ env.VERSION }}-darwin-amd64
asset_content_type: application/binary
- name: Upload darwin-arm64 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/gaiad-${{ env.VERSION }}-darwin-arm64
asset_name: gaiad-${{ env.VERSION }}-darwin-arm64
asset_content_type: application/binary
- name: Upload linux-amd64 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/gaiad-${{ env.VERSION }}-linux-amd64
asset_name: gaiad-${{ env.VERSION }}-linux-amd64
asset_content_type: application/binary
- name: Upload linux-arm64 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/gaiad-${{ env.VERSION }}-linux-arm64
asset_name: gaiad-${{ env.VERSION }}-linux-arm64
asset_content_type: application/binary
- name: Upload windows-amd64 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/gaiad-${{ env.VERSION }}-windows-amd64.exe
asset_name: gaiad-${{ env.VERSION }}-windows-amd64.exe
asset_content_type: application/binary
- name: Upload compression
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/gaiad-${{ env.VERSION }}.tar.gz
asset_name: gaiad-${{ env.RELEASE_VERSION }}.tar.gz
asset_content_type: application/gzip
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v4
with:
go-version: "1.20"

- name: Set Env
run: echo "TM_VERSION=$(go list -m github.com/tendermint/tendermint | sed 's:.* ::')" >> $GITHUB_ENV

- name: Release
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean --release-notes ./RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 16 additions & 16 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ project_name: gaia
env:
- GO111MODULE=on

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

builds:
- main: ./cmd/gaiad
id: "gaiad"
Expand All @@ -19,6 +15,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
# .Env.TM_VERSION is provided in the workflow runner environment -> see .github/workflows/release.yml
- -s -w -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X github.com/cosmos/cosmos-sdk/version.Name=gaia -X github.com/cosmos/cosmos-sdk/version.AppName=gaiad -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 -X github.com/tendermint/tendermint/version.TMCoreSemVer={{ .Env.TM_VERSION }}
goos:
- darwin
Expand All @@ -29,20 +26,23 @@ builds:
- arm64

archives:
- format: tar.gz
wrap_in_directory: "true"
format_overrides:
- goos: windows
format: zip
# disables archiving; to enable use commented lines below
- format: binary
name_template: "{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
files:
- LICENSE
- README.md

# - format: tar.gz
# wrap_in_directory: "true"
# format_overrides:
# - goos: windows
# format: zip
# name_template: "{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
# files:
# - LICENSE
# - README.md
# rlcp: true

release:
github:
owner: cosmos
name: gaia
prerelease: true
name_template: "v{{.Version}}"

checksum:
Expand All @@ -53,4 +53,4 @@ snapshot:
name_template: SNAPSHOT-{{ .Commit }}

changelog:
skip: true
skip: false
8 changes: 2 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- [Contributing](#contributing)
- [Overview](#overview)
- [Stewarding team responsibility](#stewarding-team-responsibility)
- [Responsibilities of the stewarding team](#responsibilities-of-the-stewarding-team)
- [Ease of reviewing](#ease-of-reviewing)
- [Workflow](#workflow)
- [Project Board](#project-board)
Expand Down Expand Up @@ -249,11 +249,7 @@ To generate the protobuf stubs, you can run `make proto-gen`.
User-facing repos should adhere to the trunk based development branching model: https://trunkbaseddevelopment.com. User branches should start with a user name, example: `{moniker}/{issue#}-branch-name`.
Gaia follows [semantic versioning](https://semver.org), but with the following deviations to account for state-machine and API breaking changes:
- State-machine breaking changes will result in an increase of the major version X (X.y.z).
- API breaking changes will result in an increase of the minor version Y (x.Y.z | x > 0).
- All other changes will result in an increase of the patch version Z (x.y.Z | x > 0).
Gaia follows [semantic versioning](https://semver.org), but with the some deviations to account for state-machine and API breaking changes. See [RELEASE_PROCESS.md](./RELEASE_PROCESS.md) for details.
### PR Targeting
Expand Down
45 changes: 34 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@ vulncheck: $(BUILDDIR)/
GOBIN=$(BUILDDIR) go install golang.org/x/vuln/cmd/govulncheck@latest
$(BUILDDIR)/govulncheck ./...

build-reproducible: go.sum
$(DOCKER) rm latest-build || true
$(DOCKER) run --volume=$(CURDIR):/sources:ro \
--env TARGET_PLATFORMS='linux/amd64 darwin/amd64 linux/arm64 darwin/arm64 windows/amd64' \
--env APP=gaiad \
--env VERSION=$(VERSION) \
--env COMMIT=$(COMMIT) \
--env LEDGER_ENABLED=$(LEDGER_ENABLED) \
--name latest-build majita/rbuilder:latest
$(DOCKER) cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/

build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

Expand All @@ -148,6 +137,40 @@ clean:
distclean: clean
rm -rf vendor/

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

# create tag and run goreleaser without publishing
create-release-dry-run:
ifneq ($(strip $(TAG)),)
@echo "--> Dry running release for tag: $(TAG)"
@echo "--> Create tag: $(TAG) dry run"
git tag -s $(TAG) -m $(TAG)
git push origin $(TAG) --dry-run
@echo "--> Delete local tag: $(TAG)"
@git tag -d $(TAG)
@echo "--> Running goreleaser"
@go install github.com/goreleaser/goreleaser@latest
TM_VERSION=$(TM_VERSION) goreleaser release --snapshot --clean
@rm -rf dist/
@echo "--> Done create-release-dry-run for tag: $(TAG)"
else
@echo "--> No tag specified, skipping tag release"
endif

# create tag and publish it
create-release:
ifneq ($(strip $(TAG)),)
@echo "--> Running release for tag: $(TAG)"
@echo "--> Create release tag: $(TAG)"
git tag -s $(TAG) -m $(TAG)
git push origin $(TAG)
@echo "--> Done creating release tag: $(TAG)"
else
@echo "--> No tag specified, skipping create-release"
endif

###############################################################################
### Devdoc ###
###############################################################################
Expand Down
32 changes: 32 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
A release notes template that should be adapted for every release
- release: <v*.*.*>
- release branch: <v*.x>
- the last release: <v-last>
- the last release branch: <v-last.x>
-->

# Gaia <v*.*.*> Release Notes

## 📝 Changelog

Check out the [changelog](https://github.com/cosmos/gaia/blob/<v*.*.*>/CHANGELOG.md) for a list of relevant changes or [compare all changes](https://github.com/cosmos/cosmos-sdk/compare/release/<v-last>...<v*.*.*>) from last release.

<!-- Add the following line for major releases -->
Refer to the [upgrading guide](https://github.com/cosmos/cosmos-sdk/blob/release/<v*.x>/UPGRADING.md) when migrating from `<v-last.x>` to `<v*.x>`.

## 🚀 Highlights

<!-- Add any highlights of this release -->

## 🔨 Build from source

```bash
git clone https://github.com/cosmos/gaia
cd gaia && git checkout <v*.*.*>
make install
```

## ⚡️ Download binaries

Binaries for linux, darwin, and windows are available below.
Loading

0 comments on commit ec2323c

Please sign in to comment.