Release Prepare #9
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: Release Prepare | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| nacos_tag: | |
| description: 'Nacos release tag (e.g. 3.2.0)' | |
| required: true | |
| version: | |
| description: 'Package version (defaults to nacos_tag)' | |
| required: false | |
| dry_run: | |
| description: 'Dry run (skip PR creation)' | |
| type: boolean | |
| default: true | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Determine version | |
| id: version | |
| run: | | |
| VER="${{ inputs.version }}" | |
| if [ -z "$VER" ]; then | |
| VER="${{ inputs.nacos_tag }}" | |
| fi | |
| echo "value=$VER" >> "$GITHUB_OUTPUT" | |
| - name: Generate app token | |
| id: app-token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| - uses: actions/checkout@v4 | |
| with: | |
| path: nacos-sdk-proto | |
| token: ${{ steps.app-token.outputs.token }} | |
| # --- Java toolchain --- | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: alibaba/nacos | |
| ref: ${{ inputs.nacos_tag }} | |
| path: nacos | |
| fetch-depth: 1 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| cache: maven | |
| - name: Build nacos-api | |
| run: cd nacos && mvn install -pl api -am -DskipTests -Drat.skip=true -q | |
| - name: Link nacos for Makefile | |
| run: ln -s "$GITHUB_WORKSPACE/nacos" nacos-sdk-proto/.nacos | |
| # --- protoc --- | |
| - name: Install protoc | |
| run: | | |
| PROTOC_VERSION=28.3 | |
| curl -fsSL https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip -o protoc.zip | |
| sudo unzip -o protoc.zip -d /usr/local bin/protoc 'include/*' | |
| rm protoc.zip | |
| protoc --version | |
| # --- Go toolchain --- | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: nacos-sdk-proto/go/go.mod | |
| cache-dependency-path: nacos-sdk-proto/go/go.sum | |
| - name: Install Go protoc plugins | |
| run: | | |
| go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | |
| go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | |
| # --- Python toolchain --- | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install grpcio-tools | |
| run: pip install grpcio-tools | |
| # --- Node.js toolchain --- | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install ts-proto | |
| run: cd nacos-sdk-proto && npm install | |
| # --- Generate and verify --- | |
| - name: Generate and verify | |
| run: | | |
| cd nacos-sdk-proto | |
| make clean | |
| make generate-proto | |
| make generate | |
| make verify-build | |
| - name: Update VERSION | |
| run: | | |
| SHA=$(cd nacos && git rev-parse HEAD) | |
| cat > nacos-sdk-proto/proto/VERSION << VEOF | |
| { | |
| "source": "tag", | |
| "nacos_ref": "${{ inputs.nacos_tag }}", | |
| "nacos_commit": "$SHA", | |
| "generated_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)" | |
| } | |
| VEOF | |
| - name: Update package versions | |
| run: | | |
| cd nacos-sdk-proto | |
| VER="${{ steps.version.outputs.value }}" | |
| sed -i "s/version = \".*\"/version = \"${VER}\"/" python/pyproject.toml | |
| sed -i "s/\"version\": \".*\"/\"version\": \"${VER}\"/" nodejs/package.json | |
| echo "Updated package versions to ${VER}" | |
| - name: Create release PR | |
| if: ${{ !inputs.dry_run }} | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| cd nacos-sdk-proto | |
| git config user.name "nacos-sdk-proto-bot[bot]" | |
| git config user.email "nacos-sdk-proto-bot[bot]@users.noreply.github.com" | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No changes detected, skipping PR." | |
| exit 0 | |
| fi | |
| VER="${{ steps.version.outputs.value }}" | |
| BRANCH="release/v${VER}" | |
| git checkout -b "$BRANCH" | |
| git commit -m "release: v${VER} (nacos ${{ inputs.nacos_tag }})" | |
| git push origin "$BRANCH" | |
| gh pr create \ | |
| --title "release: v${VER} (nacos ${{ inputs.nacos_tag }})" \ | |
| --body "Update VERSION and package versions for v${VER} release. Merging this PR will trigger package publishing." | |
| - name: Dry-run report | |
| if: ${{ inputs.dry_run }} | |
| run: | | |
| cd nacos-sdk-proto | |
| echo "=== Changes that would be committed ===" | |
| git diff --cached --stat |