chore(main): release 0.2.7 #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test and Release | |
| # This workflow runs on every push to the main branch. | |
| # It always runs tests. A release is only triggered if the commit message | |
| # contains the string "[release]". | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| actions: read | |
| checks: write | |
| env: | |
| PROTOC_VERSION: "33.0" | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '^1.23.0' | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read # 明确赋予读取权限 | |
| actions: read # 明确赋予读取 Actions 的权限 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '^1.23.0' # The Go version to download (if necessary) and use. | |
| - name: Install unzip (Linux) | |
| if: runner.os == 'Linux' | |
| run: sudo apt-get update && sudo apt-get install -y unzip | |
| - name: Download protoc (Linux example) | |
| if: runner.os == 'Linux' | |
| run: | | |
| PROTOC_ZIP=protoc-${{ env.PROTOC_VERSION }}-linux-x86_64.zip | |
| curl -sSL -o /tmp/$PROTOC_ZIP https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.PROTOC_VERSION }}/$PROTOC_ZIP | |
| sudo unzip -o /tmp/$PROTOC_ZIP -d /usr/local | |
| sudo chmod +x /usr/local/bin/protoc | |
| - name: Download protoc (macOS example) | |
| if: runner.os == 'macOS' | |
| run: | | |
| PROTOC_ZIP=protoc-${{ env.PROTOC_VERSION }}-osx-x86_64.zip | |
| curl -sSL -o /tmp/$PROTOC_ZIP https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.PROTOC_VERSION }}/$PROTOC_ZIP | |
| sudo unzip -o /tmp/$PROTOC_ZIP -d /usr/local | |
| sudo chmod +x /usr/local/bin/protoc | |
| - name: Download protoc (Windows example) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $ver = "${{ env.PROTOC_VERSION }}" | |
| $zip = "protoc-$ver-win64.zip" | |
| Invoke-WebRequest -Uri "https://github.com/protocolbuffers/protobuf/releases/download/v$ver/$zip" -OutFile "$env:TEMP\$zip" | |
| Expand-Archive -Path "$env:TEMP\$zip" -DestinationPath "$env:ProgramFiles" | |
| $env:PATH += ";" + "$env:ProgramFiles\bin" | |
| - name: Verify protoc version | |
| run: protoc --version | |
| - name: Install Tools and Protoc Plugins via Makefile | |
| run: make init | |
| - name: Run tests | |
| run: make test | |
| release: | |
| # The release job depends on the test job succeeding. | |
| needs: [ test ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '^1.23.0' | |
| - name: Create Release and Changelog | |
| id: release | |
| uses: googleapis/release-please-action@v4 | |
| with: | |
| config-file: release-please-config.json | |
| manifest-file: .github/.release-please-manifest.json # 已更新路径 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install Tools and Protoc Plugins via Makefile | |
| run: make init | |
| - name: Push to Buf Schema Registry | |
| if: ${{ steps.release.outputs.release_created }} | |
| env: | |
| BUF_TOKEN: ${{ secrets.BUF_TOKEN }} | |
| run: buf push --label ${{ steps.release.outputs.tag_name }} | |
| - name: Notify on new release | |
| if: ${{ steps.release.outputs.release_created }} | |
| run: | | |
| echo "New release created: ${{ steps.release.outputs.tag_name }}" | |
| echo "Release notes: ${{ steps.release.outputs.release_notes }}" |