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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Official Buf Plugin #573

Merged
merged 3 commits into from
May 27, 2022
Merged

feat: Official Buf Plugin #573

merged 3 commits into from
May 27, 2022

Conversation

Jake-RoundrockIO
Copy link
Collaborator

@Jake-RoundrockIO Jake-RoundrockIO commented May 26, 2022

Per Buf's website:

Buf is building a modern Protobuf ecosystem

Our tools address many of the problems above, ultimately allowing you to redirect much of your time and energy from managing Protobuf files to implementing your core features and infrastructure.

The buf CLI

The buf CLI enables you to create consistent Protobuf APIs that preserve compatibility and comply with best practices. The tool is currently available on an open-source basis. The buf CLI incorporates these components to help you create consistent Protobuf APIs:

The Buf Schema Registry (BSR)

The Buf Schema Registry (BSR) is a hosted SaaS platform that serves as your organization鈥檚 source of truth for your Protobuf APIs. The BSR enables you to centrally maintain compatibility and manage dependencies, while enabling your clients to consume APIs reliably and efficiently. Similar to npm for JavaScript, pip for Python, or cargo for Rust, the BSR finally brings dependency management to your Protobuf APIs.

The goal of this PR is to support further adoption of the Buf ecosystem of tooling by making this library available through the BSR Plugin system.

This will allow library users greater flexibility when utilizing ts-proto as it allows them:

  1. The ability to generate code using the library without needing to install it from NPM, which may be useful depending on project workflow and at a bare minimum reduces node_module size.
  2. To take advantage of the BSR Remote Generation feature. This feature creates NPM modules on the fly containing the code generated using ts-proto and a user's .proto files that can be used to standardize proto generation accross a project and/or team.

To meet this end, this PR introduces a new GitHub Actions workflow that, on tagged release, builds and pushes the latest version of ts-proto to the BSR Plugin registry.

In addition to the changes made in this PR, @stephenh it is necessary that you create an account with buf.build (I have checked and stephenh is available at the time of submission 馃槉) and perform the following steps.

  1. Navigate to https://buf.build/settings/user and create an API Token.
  2. Navigate to the Plugins tab of your account and click the Create Plugin button
    • Name the plugin ts-proto
    • Ensure it is Public
  3. Create the secrets BUF_USERNAME and BUF_PASSWORD in this repository's settings tab and set them equal to your account name (presumably stephenh) and your API token, respectively.

With these steps completed, GitHub Actions should be able to automatically push to the BSR Plugin registry on tagged release.

Relates to issue #569

Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

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

Amazing set of instructions @Jake-RoundrockIO , thank you! Going to merge and see what happens!

@stephenh stephenh merged commit e6272c4 into stephenh:main May 27, 2022
stephenh pushed a commit that referenced this pull request May 27, 2022
# [1.114.0](v1.113.0...v1.114.0) (2022-05-27)

### Features

* Official Buf Plugin ([#573](#573)) ([e6272c4](e6272c4))
@stephenh
Copy link
Owner

馃帀 This PR is included in version 1.114.0 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

@Jake-RoundrockIO
Copy link
Collaborator Author

Jake-RoundrockIO commented May 27, 2022

The tag triggered by the build.yml files does not appear to have triggered the buf.yml workflow

@Jake-RoundrockIO
Copy link
Collaborator Author

According to here it looks like it may be because I didn't use the ADMIN_TOKEN like you did in build.yml, which may allow the workflow to be triggered by the push resulting from the build.yml workflow.

@stephenh should I do another full PR or is that something you wish to edit on your end?

@stephenh
Copy link
Owner

Hey @Jake-RoundrockIO , I'm thinking it's because of this:

https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/

I.e. the way ts-proto is using semantic-release out-of-the-box, their scripts are creating a net-new commit with the changelog and tagging that one, but with a "skip ci" in it...

So, dunno, kinda looks like the Buf workflow will basically have to run on the pre-tagged commit, so on like pushes to main:

    if: github.event_name == 'push' && github.ref == 'refs/heads/main'

...but then also either a) run as part of the existing main build to get the semantic-release determined version number, b) run in parallel to the main build and also invoke semantic-release but solely to determine the version number, c) ...something else?

@Jake-RoundrockIO
Copy link
Collaborator Author

I think option a should work fine as long as you can get the version number from sematic release. That's really the only thing it needs to know so that it can push that version tag to the registry.

@stephenh
Copy link
Owner

@Jake-RoundrockIO okay! It took a few tries but looks like it worked:

image

Thanks!

@Jake-RoundrockIO
Copy link
Collaborator Author

You're amazing! Thanks for the help getting this worked out!

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.

None yet

2 participants