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

Improve our release process with goreleaser #5813

Merged
merged 4 commits into from
Jul 24, 2023
Merged

Conversation

niccoloraspa
Copy link
Member

@niccoloraspa niccoloraspa commented Jul 11, 2023

What is the purpose of the change

This PR introduces the .goreleaser.yaml configuration file and sets up the release process for the project osmosisd.

Goreleaser is a popular tool used in the Go ecosystem to automate the build and release workflow for Go projects. It simplifies the process of building binaries, creating archives, generating checksums, and publishing releases across multiple platforms and architectures.

The goreleaser.yaml file included in this PR defines the configuration for the release process of osmosisd.
Let's summarize the key elements of the configuration:

  1. Project Information:

    • project_name: Specifies the name of the project as osmosisd.
  2. Environment Variables:

    • Specifies the needed environment variables
  3. Builds:
    The configuration defines four build targets, each specifying different operating systems and architectures:

    • osmosisd-darwin-amd64: Builds the osmosisd binary for macOS (darwin) on AMD64 architecture.
    • osmosisd-darwin-arm64: Builds the osmosisd binary for macOS (darwin) on ARM64 architecture.
    • osmosisd-linux-amd64: Builds the osmosisd binary for Linux on AMD64 architecture.
    • osmosisd-linux-arm64: Builds the osmosisd binary for Linux on ARM64 architecture.

    For each build, the configuration specifies the necessary build commands, hooks, environment variables, Go compiler options, flags, and linker flags.

  4. Universal Binaries:

    • osmosisd-darwin-universal: Creates a universal binary that includes both the macOS (darwin) AMD64 and ARM64 builds.
  5. Archives:
    The configuration defines an archive configuration named zipped that generates zip archives for the universal darwin binary and Linux AMD64/ARM64 binaries.

  6. Checksums:

    • Generates a checksum file named osmosisd-{{ .Version }}-checksums.txt using the SHA256 algorithm.
  7. Brew Formula:

    • Defines a brew formula for osmosisd called osmosisd. The formula installs the osmosisd binary and includes tests and installation instructions. This would allow user to install osmosisd with brew install osmosisd
  8. Release Configuration:

    • Create a draft release following the template
    • Upload the necessary binaries

There a lot of options that we could customize in this file.
For example we could automatically announce on Discord, Slack, Twitter, etc.. once the release is done: https://goreleaser.com/customization/announce/

Testing and Verifying

I have used this .goreleaser.yaml to create the following release in my local fork: Link to Release

To replicate the release process, execute the following command:

  1. Fork the osmosis repo with all the tags

  2. Clone the repo and select the tag

git clone https://github.com/<YOUR_GITHUB_USER>/osmosis
git checkout v16.0.0
  1. Copy this .goreleaser.yaml

  2. Edit the .goreleaser.yaml to avoid creating a release in the real repository.

release:
  github:
    #owner: osmosis-labs  
    owner: <YOUR_GITHUB_USER>
    name: osmosis
  1. Run goreleaser-cross:
docker run -e GITHUB_TOKEN=<GITHUB_TOKEN_WITH_REPO_ACCESS> -v /var/run/docker.sock:/var/run/docker.sock -v pwd:/go/src/osmosisd -w /go/src/osmosisd ghcr.io/goreleaser/goreleaser-cross:v1.20.5 release --clean

Replace <GITHUB_TOKEN_WITH_REPO_ACCESS> with an actual GitHub token that has access to the repository.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

@niccoloraspa niccoloraspa added A:no-changelog V:state/compatible/backport State machine compatible PR, should be backported A:backport/v16.x backport patches to v16.x branch labels Jul 11, 2023
@niccoloraspa
Copy link
Member Author

If you are curious these are the logs:

docker run     -e GITHUB_TOKEN=<TOKEN>     -v /var/run/docker.sock:/var/run/docker.sock     -v `pwd`:/go/src/osmosisd     -w /go/src/osmosisd ghcr.io/goreleaser/goreleaser-cross:v1.20.5 release --clean --skip-validate 

Logs:

  • starting release...
  • loading config file                              file=.goreleaser.yaml
  • loading environment variables
    • using token from "$GITHUB_TOKEN"
  • getting and validating git state
    • building...                                    commit=d72fe81b5ed9fdf5ed6a4d41ad309592b2858a1e latest tag=v16.0.0
    • pipe skipped                                   reason=validation is disabled
  • parsing tag
  • setting defaults
  • checking distribution directory
    • cleaning dist
  • loading go mod information
  • build prerequisites
  • writing effective config file
    • writing                                        config=dist/config.yaml
  • building binaries
    • building                                       binary=dist/osmosisd-linux-arm64_linux_arm64/osmosisd
    • building                                       binary=dist/osmosisd-darwin-amd64_darwin_amd64_v1/osmosisd
    • building                                       binary=dist/osmosisd-linux-amd64_linux_amd64_v1/osmosisd
    • building                                       binary=dist/osmosisd-darwin-arm64_darwin_arm64/osmosisd
    • running hook                                   hook=wget https://github.com/CosmWasm/wasmvm/releases/download/v1.2.3/libwasmvm_muslc.aarch64.a -O /usr/lib/aarch64-linux-gnu/libwasmvm_muslc.a
    • running hook                                   hook=wget https://github.com/CosmWasm/wasmvm/releases/download/v1.2.3/libwasmvmstatic_darwin.a -O /lib/libwasmvmstatic_darwin.a
    • running hook                                   hook=wget https://github.com/CosmWasm/wasmvm/releases/download/v1.2.3/libwasmvm_muslc.x86_64.a -O /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.a
    • running hook                                   hook=wget https://github.com/CosmWasm/wasmvm/releases/download/v1.2.3/libwasmvmstatic_darwin.a -O /lib/libwasmvmstatic_darwin.a    • took: 1m17sibwasmvmstatic_dar
  • universal binaries
    • creating from 2 binaries                       id=osmosisd-darwin-universal binary=dist/osmosisd-darwin-universal_darwin_all/osmosisd
  • archives
    • skip archiving                                 binary=osmosisd name=osmosisd-16.0.0-darwin-all
    • skip archiving                                 binary=osmosisd name=osmosisd-16.0.0-linux-amd64
    • skip archiving                                 binary=osmosisd name=osmosisd-16.0.0-linux-arm64
    • creating                                       archive=dist/osmosisd-16.0.0-darwin-all.zip
    • creating                                       archive=dist/osmosisd-16.0.0-linux-amd64.zip
    • creating                                       archive=dist/osmosisd-16.0.0-linux-arm64.zip
    • no files matched                               glob=none*
    • no files matched                               glob=none*
    • no files matched                               glob=none*
    • took: 11s
  • calculating checksums
  • homebrew tap formula
    • pipe skipped                                   reason=brew.repository.name is not set
  • publishing
    • scm releases
      • creating or updating release                 tag=v16.0.0 repo=niccoloraspa/osmosis
      • refreshing checksums                         file=osmosisd-16.0.0-checksums.txt
      • deleted previous draft release               commit=main tag=v16.0.0 name=Osmosis v16.0.0 🧪
      • release created                              name=Osmosis v16.0.0 🧪 release-id=111803515 request-id=CE0E:13EF3:3CBAFF9:3D44B31:64AD63D0
      • uploading to release                         file=dist/osmosisd-16.0.0-checksums.txt name=osmosisd-16.0.0-checksums.txt
      • uploading to release                         file=dist/osmosisd-linux-arm64_linux_arm64/osmosisd name=osmosisd-16.0.0-linux-arm64
      • uploading to release                         file=dist/osmosisd-darwin-universal_darwin_all/osmosisd name=osmosisd-16.0.0-darwin-all
      • uploading to release                         file=dist/osmosisd-16.0.0-linux-arm64.zip name=osmosisd-16.0.0-linux-arm64.zip
      • uploading to release                         file=dist/osmosisd-16.0.0-linux-amd64.zip name=osmosisd-16.0.0-linux-amd64.zip
      • uploading to release                         file=dist/osmosisd-linux-amd64_linux_amd64_v1/osmosisd name=osmosisd-16.0.0-linux-amd64
      • uploading to release                         file=dist/osmosisd-16.0.0-darwin-all.zip name=osmosisd-16.0.0-darwin-all.zip
      • published                                    url=https://github.com/niccoloraspa/osmosis/releases/tag/v16.0.0
      • took: 17s
    • homebrew tap formula
  • took: 17s
  • storing release metadata
    • writing                                        file=dist/artifacts.json
    • writing                                        file=dist/metadata.json
  • announcing
  • release succeeded after 1m45s
  • thanks for using goreleaser!

name_template: "checksums.txt"
algorithm: sha256

# Docs: https://goreleaser.com/customization/homebrew/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sweet we have an osmosis brew??

Comment on lines +241 to +254
# Docs: https://goreleaser.com/customization/announce/
#
# We could automatically announce the release in
# - discord
# - slack
# - twitter
# - webhooks
# - telegram
# - reddit
#
# announce:
# discord:
# enabled: true
# message_template: 'New {{.Tag}} is out!'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we track this in an issue, seems like it would be super useful.

Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACKing with minimal context, but no issues stand out

@czarcas7ic czarcas7ic merged commit ccd779d into main Jul 24, 2023
@czarcas7ic czarcas7ic deleted the feat/add-goreleaser branch July 24, 2023 16:47
mergify bot pushed a commit that referenced this pull request Jul 24, 2023
* Add .goreleaser.yaml

* Add complete .goreleaser.yaml

* use tar.gz as a format

* Update docker description

(cherry picked from commit ccd779d)
mattverse pushed a commit that referenced this pull request Jul 24, 2023
* Add .goreleaser.yaml

* Add complete .goreleaser.yaml

* use tar.gz as a format

* Update docker description

(cherry picked from commit ccd779d)

Co-authored-by: Niccolo Raspa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v16.x backport patches to v16.x branch A:no-changelog V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants