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

build: Add release pipeline #206

Merged
merged 6 commits into from
Jul 3, 2024
Merged

build: Add release pipeline #206

merged 6 commits into from
Jul 3, 2024

Conversation

bgins
Copy link
Contributor

@bgins bgins commented Jun 27, 2024

Review Type Requested (choose one):

  • Glance - superficial check (from domain experts)

Summary

This pull request adds a release workflow that:

  • Automatically generates release pull requests and merges them immediately
  • Automatically creates releases when the release pull request it merged
  • Extends generated release notes with custom notes
  • Builds binaries and uploads them to the release

It also makes a few associated changes:

  • Update testnet_deploy_services.yml to deploy only on releases
  • Update release_docker.yml to publish only on releases. Removed. We also want to publish on push to main.
  • Update resource provider updater script to expect -gpu suffix in release name (and rename script to lilypad-updater-gpu.sh)
  • Remove CirclCI build and existing GH actions build and release workflows
  • Naming clean up to use Go conventions (https://go.dev/doc/effective_go#mixed-caps)

Task/Issue reference

Closes: #91, closes #168

Details

Goals

Our goals for the release pipeline:

  • Release features and fixes on merge to main
  • Support trunk-based development
  • Automate everything as much as possible

release-please

This PR uses release-please to generate release pull requests and create releases when new features or fixes are introduced. release-please checks for conventional commit prefixes to determine a semantic version and to decide when to create a release. From their documentation:

The most important prefixes you should have in mind are:

  • fix: which represents bug fixes, and correlates to a SemVer patch.
  • feat: which represents a new feature, and correlates to a SemVer minor.
  • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.

release-please does not create release PRs or releases for tasks without user facing (prefixes like chore:, build:, etc).

Automate it more please

A typical release-please setup creates a release pull request that a human approves and merges. Once the PR is merged, release-please runs a second time and creates a release when it observes its release commit.

We take this a step further by automatically merging the release pull request. After we merge, release-please runs a second time to create the release.

Here is a diagram showing an example flow on commits coming into main and how the releases workflow responds to each. The diagram assumes we have started at version 1.0.0:

release-pipeline

We have created a lilypad-releases bot (implemented as a GitHub app) to run release-please actions. The custom bot is needed to trigger further actions, such as running the workflow a second time on merge.

In addition, our branch protection rules for main require one PR approval and will require passing tests in the near future. The lilypad-releases bot cannot approve it's own pull request, so we have the default github-actions bot step in for approval.

Customization

release-please automatically maintains a CHANGELOG, generates pull request text, and generates release notes.

We can customize the pull request text by updating release-please-config.json.

We extend the generated release notes with an extend-notes job. This job reads a release_notes.md file and appends it to the generated release notes. We can customize the release notes by updating this file, but note that the changes will persist in the next release unless they are changed again.

How to test this code?

This pull request is challenging to test in this repository because we need to merge it to see it in action.

I have created a Lilypad-Tech/test-gh-action-releases repo to demonstrate the release workflow with a few test PRs ready to approve and merge: https://github.com/Lilypad-Tech/test-gh-action-releases/pulls

Anything else?

Our internal version to capture the design can be found here: https://www.notion.so/lilypadnetwork/Release-Pipeline-70ecc09bed8b406ba33e7e1e4c4e93b3

@github-actions github-actions bot added the build label Jun 27, 2024
@bgins bgins force-pushed the bgins/build-add-release-pipeline branch 2 times, most recently from 53cd108 to 3a36afb Compare July 1, 2024 16:51
@bgins bgins marked this pull request as ready for review July 1, 2024 21:00
@bgins bgins force-pushed the bgins/build-add-release-pipeline branch from f7d8c5d to 581aeb1 Compare July 1, 2024 21:01
Comment on lines +112 to +117
NOTES=$(cat << EOF
$BODY

$EXTENSION
EOF
)
Copy link
Contributor

@AquiGorka AquiGorka Jul 1, 2024

Choose a reason for hiding this comment

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

NOTES=$(cat << EOF
          $BODY
          $EXTENSION
          EOF
)

The spacing threw me off, thought there was a missing parenthesis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, admittedly this is an esoteric technique for adding the newlines. But it was the only one that worked out for me implementing it. 😄

goarch: arm64
gpu: false
runner: macos-latest # uses M1
runs-on: ${{ matrix.runner }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! 😍

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we not doing linux non gpu? Those would be for people running the binary in docker? (assuming most docker images use some flavor of linux)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do a CPU-only build for every OS and architecture. The gpu flag indicates whether we should also do a GPU build.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for clarifying, I misread the matrix

Copy link
Contributor

@AquiGorka AquiGorka left a comment

Choose a reason for hiding this comment

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

We take this a step further by automatically merging the release pull request. After we merge, release-please runs a second time to create the release.

😍

Thank you @bgins 🎉

Copy link
Collaborator

@walkah walkah left a comment

Choose a reason for hiding this comment

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

One small Q, but looking forward to having this in place! Great work, @bgins 👏 🚀

@@ -2,8 +2,6 @@ name: Publish Docker Image

on:
push:
branches:
- "main"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't want a latest docker image that tracks main (for testing, etc)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah, good point. Two questions about it.

Are there changes that are not user facing that should trigger a new Docker image? With the current setup, we will create a new image for every feat:, fix:, and breaking change. Are there cases where we would want them for chore:, build:, etc?

Second, does ghcr have a mechanism for listing images by git tag? They don't list our existing tags ((https://github.com/Lilypad-Tech/lilypad/pkgs/container/resource-provider/versions), but maybe it's because of the way we have been formatting them. The concern here is whether or not resource providers can find the latest released version vs the latest published version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there changes that are not user facing that should trigger a new Docker image? With the current setup, we will create a new image for every feat:, fix:, and breaking change. Are there cases where we would want them for chore:, build:, etc?

Maybe not? I think I don't know the answer yet.

Second, does ghcr have a mechanism for listing images by git tag? They don't list our existing tags ((https://github.com/Lilypad-Tech/lilypad/pkgs/container/resource-provider/versions), but maybe it's because of the way we have been formatting them. The concern here is whether or not resource providers can find the latest released version vs the latest published version.

It will publish on git tags - I think we just haven't done one since the docker build step was added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright yeah, if the tagged versions will be distinct on ghcr, let's publish images on push to main and tags. Will drop the change.

Can imagine a scenario where we are updating the Dockerfile, it's a build: task not a fix/feature, and we want the team to have easy access to an image.

@bgins bgins force-pushed the bgins/build-add-release-pipeline branch from 581aeb1 to a9eac7c Compare July 2, 2024 21:26
@bgins bgins force-pushed the bgins/build-add-release-pipeline branch from a9eac7c to 26e6d05 Compare July 3, 2024 15:37
@bgins bgins merged commit 14b23da into main Jul 3, 2024
1 check passed
@bgins bgins deleted the bgins/build-add-release-pipeline branch July 3, 2024 15:41
@bgins bgins restored the bgins/build-add-release-pipeline branch July 3, 2024 16:20
@bgins bgins mentioned this pull request Jul 8, 2024
1 task
@bgins bgins self-assigned this Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Bring back releases [core] Define release strategy
3 participants