From b2a01871d63e87c9766b11f93e482c954c2d6494 Mon Sep 17 00:00:00 2001 From: CHAMI Rachid Date: Mon, 7 Oct 2024 21:10:24 +0200 Subject: [PATCH] fix(ci): update the Buf CI to push tags to the Buf Schema Registry (#280) This PR fixes the push of a new tag to BSR. Tested in my fork in here: https://buf.build/chamirachid/nmt/labels ## Summary by CodeRabbit - **New Features** - Introduced a new GitHub Actions workflow for continuous integration of Buf-related changes. - Added a workflow for automating the release of protobuf definitions to the Buf Schema Registry. - New script for downloading the specified version of the `buf` binary. - **Bug Fixes** - Removed the outdated `buf-ci` workflow to streamline processes. --- .github/workflows/buf-ci.yaml | 29 ----------------------------- .github/workflows/buf-ci.yml | 22 ++++++++++++++++++++++ .github/workflows/buf-release.yml | 23 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 29 deletions(-) delete mode 100644 .github/workflows/buf-ci.yaml create mode 100644 .github/workflows/buf-ci.yml create mode 100644 .github/workflows/buf-release.yml diff --git a/.github/workflows/buf-ci.yaml b/.github/workflows/buf-ci.yaml deleted file mode 100644 index 6d22c7f2..00000000 --- a/.github/workflows/buf-ci.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: buf-ci -on: - push: - branches: - - main - tags: - - "v[0-9]+.[0-9]+.[0-9]+" - - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" - - "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" - - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" - pull_request: -permissions: - contents: read - pull-requests: write -jobs: - buf: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: bufbuild/buf-action@v1 - with: - token: ${{ secrets.BUF_TOKEN }} - input: "pb" - breaking-against: 'https://github.com/celestiaorg/nmt.git#branch=main,ref=HEAD~1,subdir=pb' - # Run breaking change, lint, and format checks for Protobuf sources against all branches, - # 'pb' subdirectory, then push to the Buf Schema Registry once validated - lint: true - format: true - breaking: true diff --git a/.github/workflows/buf-ci.yml b/.github/workflows/buf-ci.yml new file mode 100644 index 00000000..7d3a62d7 --- /dev/null +++ b/.github/workflows/buf-ci.yml @@ -0,0 +1,22 @@ +name: buf-ci +on: + push: + branches: + - main + pull_request: +permissions: + contents: read + pull-requests: write +jobs: + buf: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: bufbuild/buf-setup-action@v1 + - uses: bufbuild/buf-breaking-action@v1 + with: + input: pb + against: 'https://github.com/celestiaorg/nmt.git#branch=main,subdir=pb' + - uses: bufbuild/buf-lint-action@v1 + with: + input: pb diff --git a/.github/workflows/buf-release.yml b/.github/workflows/buf-release.yml new file mode 100644 index 00000000..98832465 --- /dev/null +++ b/.github/workflows/buf-release.yml @@ -0,0 +1,23 @@ +name: buf-release +on: + push: + tags: + - "v*" +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: bufbuild/buf-setup-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + version: "1.44.0" + # Push the protobuf definitions to the BSR + - uses: bufbuild/buf-push-action@v1 + with: + buf_token: ${{ secrets.BUF_TOKEN }} + - name: "push the tag label to BSR" + run: | + set -euo pipefail + echo ${{ secrets.BUF_TOKEN }} | buf registry login --token-stdin + buf push --label ${{ github.ref_name }}