From 386517fc367653d5697394006e134e4aba995974 Mon Sep 17 00:00:00 2001 From: Moritz Zimmer Date: Fri, 5 Jul 2024 08:56:25 +0200 Subject: [PATCH] feat: push tapir to Buf schema registry for each new tag (#553) * feat: push tapir to Buf schema registry for each new tag see https://buf.build/stroeer/tapir * use https://buf.build/docs/reference/cli/buf/push#git-metadata for pushes --- .github/workflows/packages.yml | 18 ++++++++++++++++++ .github/workflows/pull-request.yml | 4 ++++ Makefile | 13 ++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index ec53c365..e5b34d13 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -121,3 +121,21 @@ jobs: -H 'Accept: application/vnd.github.everest-preview+json' \ -u ${{ secrets.GO_TAPIR_TOKEN }} \ --data '{"event_type": "publish", "client_payload": { "tag": "'"$RELEASE_TAG"'" }}' + + + bsr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: bufbuild/buf-setup-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: push + env: + BUF_TOKEN: ${{ secrets.BUF_TOKEN }} + run: | + RELEASE_TAG=${GITHUB_REF/refs\/tags\/v/} + echo $RELEASE_TAG + make push diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f06f2904..1fe6d90f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -97,6 +97,8 @@ jobs: - uses: actions/checkout@v4 - uses: bufbuild/buf-setup-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} - uses: bufbuild/buf-lint-action@v1 @@ -106,6 +108,8 @@ jobs: - uses: actions/checkout@v4 - uses: bufbuild/buf-setup-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} - uses: bufbuild/buf-breaking-action@v1 if: always() diff --git a/Makefile b/Makefile index 636f15fb..b18d014a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: generate test fmt lint breaking +all: build generate test fmt lint breaking TEMPLATE ?= buf.gen.yaml .PHONY: generate @@ -21,6 +21,17 @@ fmt: ## Formats all proto files using https://docs.buf.build/format/style @echo "+ $@" @buf format -w +.PHONY: build +build: ## Builds buf image, see https://buf.build/docs/reference/images + @echo "+ $@" + @buf build + +LABEL ?= +.PHONY: push +push: build ## Pushes tapir to the buf schema registry, see https://buf.build/docs/bsr/introduction and https://buf.build/docs/bsr/module/publish#pushing-with-labels + @echo "+ $@" + @buf push --git-metadata + .PHONY: test test: generate ## Runs all tests @echo "+ $@"