Release Prepare #2
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 | |
| 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 actual publish)' | |
| type: boolean | |
| default: true | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.value }} | |
| 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 }}" | |
| # Python | |
| sed -i "s/version = \".*\"/version = \"${VER}\"/" python/pyproject.toml | |
| # Node.js | |
| sed -i "s/\"version\": \".*\"/\"version\": \"${VER}\"/" nodejs/package.json | |
| echo "Updated package versions to ${VER}" | |
| - name: Prepare release commit | |
| 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 | |
| echo "=== Changes to be committed ===" | |
| git diff --cached --stat | |
| - name: Commit, tag and push | |
| if: ${{ !inputs.dry_run }} | |
| run: | | |
| cd nacos-sdk-proto | |
| VER="${{ steps.version.outputs.value }}" | |
| if ! git diff --cached --quiet; then | |
| git commit -m "release: v${VER} (nacos ${{ inputs.nacos_tag }})" | |
| fi | |
| git tag "v${VER}" | |
| git tag "go/v${VER}" | |
| git push origin main --tags | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: nacos-sdk-proto | |
| path: nacos-sdk-proto/ | |
| release-go: | |
| needs: generate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: echo "Go release done via git tag go/v${{ needs.generate.outputs.version }}" | |
| release-python: | |
| needs: generate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: nacos-sdk-proto | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Build package | |
| run: | | |
| pip install build twine | |
| cd python | |
| python -m build | |
| - name: Publish | |
| if: ${{ !inputs.dry_run }} | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| run: cd python && twine upload dist/* | |
| - name: Dry-run report | |
| if: ${{ inputs.dry_run }} | |
| run: ls -la python/dist/ | |
| release-nodejs: | |
| needs: generate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: nacos-sdk-proto | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Build package | |
| run: cd nodejs && npm pack | |
| - name: Publish | |
| if: ${{ !inputs.dry_run }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: cd nodejs && npm publish | |
| - name: Dry-run report | |
| if: ${{ inputs.dry_run }} | |
| run: ls -la nodejs/*.tgz | |
| github-release: | |
| needs: [generate, release-go, release-python, release-nodejs] | |
| if: ${{ !inputs.dry_run }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| VER: ${{ needs.generate.outputs.version }} | |
| NACOS_TAG: ${{ inputs.nacos_tag }} | |
| run: | | |
| cat > /tmp/release-notes.md << EOF | |
| ## nacos-sdk-proto v${VER} | |
| Generated from [alibaba/nacos@${NACOS_TAG}](https://github.com/alibaba/nacos/tree/${NACOS_TAG}) | |
| ### Packages | |
| | Language | Package | Version | | |
| |----------|---------|---------| | |
| | Go | \`github.com/nacos-group/nacos-sdk-proto/go\` | \`go/v${VER}\` | | |
| | Python | [nacos-sdk-proto](https://pypi.org/project/nacos-sdk-proto/${VER}/) | ${VER} | | |
| | Node.js | [@nacos-group/sdk-proto](https://www.npmjs.com/package/@nacos-group/sdk-proto/v/${VER}) | ${VER} | | |
| EOF | |
| gh release create "v${VER}" --title "v${VER}" --notes-file /tmp/release-notes.md |