diff --git a/.bufversion b/.bufversion new file mode 100644 index 0000000..de72421 --- /dev/null +++ b/.bufversion @@ -0,0 +1 @@ +v1.32.0-beta.1 \ No newline at end of file diff --git a/.github/workflows/buf-pr.yaml b/.github/workflows/buf-pr.yaml new file mode 100644 index 0000000..58c528d --- /dev/null +++ b/.github/workflows/buf-pr.yaml @@ -0,0 +1,23 @@ +name: buf (Pull Request) +on: + - pull_request +jobs: + buf: + runs-on: ubuntu-latest + if: ${{ ! contains(github.event.pull_request.labels.*.name, 'Skip Buf Breaking') }} + steps: + - name: Checkout PR head + uses: actions/checkout@v4 + - name: Checkout PR base + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.base.sha }} + path: .base + - name: Install buf cli + uses: bufbuild/buf-setup-action@v1 + with: + version: 1.32.0-beta.1 # remove this flag when 1.32.0 is released so we go back to always tracking latest. + # todo: use .bufversion or the env variable? + github_token: ${{ github.token }} # is this necessary? + - name: buf breaking against PR base + run: buf breaking --against .base --error-format github-actions diff --git a/.github/workflows/buf-push.yaml b/.github/workflows/buf-push.yaml new file mode 100644 index 0000000..66b7deb --- /dev/null +++ b/.github/workflows/buf-push.yaml @@ -0,0 +1,24 @@ +name: buf (Push) +on: + - push +jobs: + buf: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install buf cli + uses: bufbuild/buf-setup-action@v1 + with: + version: 1.32.0-beta.1 # remove this flag when 1.32.0 is released so we go back to always tracking latest. + # todo: use .bufversion or the env variable? + github_token: ${{ github.token }} # is this necessary? + - name: buf build + run: buf build --error-format github-actions + - name: buf format + run: buf format --diff --exit-code --error-format github-actions + - name: buf lint + run: buf lint --error-format github-actions + - name: buf push + run: buf push --label ${{ github.ref }} --git-metadata --error-format github-actions + with: + buf_token: ${{ secrets.BUF_TOKEN }} diff --git a/.github/workflows/buf.yaml b/.github/workflows/buf.yaml deleted file mode 100644 index c4ce827..0000000 --- a/.github/workflows/buf.yaml +++ /dev/null @@ -1,45 +0,0 @@ -name: buf -on: - push: -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: install - uses: actions/setup-go@v5 - with: - go-version: 1.21.x - - name: cache - uses: actions/cache@v4 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-registry-proto-ci-${{ hashFiles('**/Makefile') }} - restore-keys: ${{ runner.os }}-registry-proto-ci- - - name: Lint - run: | - make lint - breaking: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1 - - uses: bufbuild/buf-breaking-action@v1 - with: - against: buf.build/bufbuild/registry - push: - environment: production - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - needs: - - lint - - breaking - steps: - - uses: actions/checkout@v4 - - name: Install buf cli - uses: bufbuild/buf-setup-action@v1 - with: - github_token: ${{ github.token }} - - uses: bufbuild/buf-push-action@v1 - with: - buf_token: ${{ secrets.BUF_TOKEN }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dac58cc..81a8942 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: - name: install uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x - name: cache uses: actions/cache@v4 with: diff --git a/Makefile b/Makefile index ca9b775..457cf1a 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ BIN := .tmp/bin export PATH := $(BIN):$(PATH) export GOBIN := $(abspath $(BIN)) -BUF_VERSION := v1.29.0 +BUF_VERSION_FILE := .bufversion +BUF_VERSION := $(shell cat ${BUF_VERSION_FILE}) COPYRIGHT_YEARS := 2023-2024 .PHONY: help @@ -35,7 +36,7 @@ build: $(BIN)/buf ## Build all APIs .PHONY: lint lint: $(BIN)/buf ## Lint all APIs buf lint - buf format -d --exit-code + buf format --diff --exit-code .PHONY: upgrade upgrade: $(BIN)/buf ## Upgrade dependencies