Release waxmcp npm package #4
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 waxmcp npm package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Version bump (patch/minor/major) or semver (for manual release) | |
| required: false | |
| default: patch | |
| push: | |
| tags: | |
| - "waxmcp-v*" | |
| jobs: | |
| build: | |
| name: Build WaxCLI (${{ matrix.platform }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runs-on: macos-14 | |
| platform: darwin-x64 | |
| triple: "" | |
| run-tests: false | |
| source-build: false | |
| - runs-on: macos-14 | |
| platform: darwin-arm64 | |
| triple: arm64-apple-macosx14.0 | |
| run-tests: true | |
| source-build: true | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: swift-actions/setup-swift@v2 | |
| with: | |
| swift-version: "6.2" | |
| - name: Verify SwiftPM trait support | |
| if: ${{ matrix.run-tests }} | |
| run: | | |
| set -euo pipefail | |
| swift --version | |
| swift test --help | grep -q -- "--traits <traits>" | |
| - name: Run MCP trait tests | |
| if: ${{ matrix.run-tests }} | |
| run: | | |
| set -euo pipefail | |
| SKIP_REGEX="(RAGBenchmarks|RAGBenchmarksMiniLM|WALCompactionBenchmarks|LongMemoryBenchmarkHarness|BatchEmbeddingBenchmark|MetalVectorEngineBenchmark|OptimizationComparisonBenchmark|TokenizerBenchmark|BufferSerializationBenchmark)" | |
| swift test --parallel --traits MCPServer --skip "$SKIP_REGEX" | |
| - name: Build WaxCLI | |
| if: ${{ matrix.source-build }} | |
| run: | | |
| set -euo pipefail | |
| swift build --product WaxCLI --traits MCPServer --configuration release --triple "${{ matrix.triple }}" | |
| BIN_PATH="$(swift build --product WaxCLI --traits MCPServer --configuration release --triple "${{ matrix.triple }}" --show-bin-path)" | |
| mkdir -p npm/waxmcp/dist/${{ matrix.platform }} | |
| cp "$BIN_PATH/WaxCLI" npm/waxmcp/dist/${{ matrix.platform }}/WaxCLI | |
| chmod +x npm/waxmcp/dist/${{ matrix.platform }}/WaxCLI | |
| - name: Reuse checked-in x64 binary | |
| if: ${{ !matrix.source-build }} | |
| run: | | |
| set -euo pipefail | |
| test -f npm/waxmcp/dist/${{ matrix.platform }}/WaxCLI | |
| chmod +x npm/waxmcp/dist/${{ matrix.platform }}/WaxCLI | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: waxmcp-${{ matrix.platform }} | |
| path: npm/waxmcp/dist/${{ matrix.platform }}/WaxCLI | |
| if-no-files-found: error | |
| publish: | |
| name: Publish waxmcp to npm | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref_name, 'waxmcp-v') }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Restore darwin-x64 binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: waxmcp-darwin-x64 | |
| path: npm/waxmcp/dist/darwin-x64 | |
| - name: Restore darwin-arm64 binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: waxmcp-darwin-arm64 | |
| path: npm/waxmcp/dist/darwin-arm64 | |
| - name: Set package version | |
| working-directory: npm/waxmcp | |
| run: | | |
| set -euo pipefail | |
| if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then | |
| npm version "${VERSION}" --no-git-tag-version --allow-same-version | |
| else | |
| VERSION="${GITHUB_REF_NAME#waxmcp-v}" | |
| npm version "${VERSION}" --no-git-tag-version --allow-same-version | |
| fi | |
| env: | |
| VERSION: ${{ inputs.version }} | |
| - name: Verify packaged binaries | |
| run: | | |
| chmod +x npm/waxmcp/dist/darwin-arm64/WaxCLI | |
| test -x npm/waxmcp/dist/darwin-arm64/WaxCLI | |
| chmod +x npm/waxmcp/dist/darwin-x64/WaxCLI | |
| test -x npm/waxmcp/dist/darwin-x64/WaxCLI | |
| - name: Verify version consistency | |
| run: | | |
| set -euo pipefail | |
| NPM_VERSION=$(node -p "require('./npm/waxmcp/package.json').version") | |
| echo "npm package version: $NPM_VERSION" | |
| # Extract the hardcoded version from main.swift and compare | |
| SWIFT_VERSION=$(grep -E 'let serverVersion = "[0-9]+\.[0-9]+\.[0-9]+"' Sources/WaxMCPServer/main.swift | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') | |
| echo "Swift server version: $SWIFT_VERSION" | |
| if [ "$NPM_VERSION" != "$SWIFT_VERSION" ]; then | |
| echo "ERROR: version mismatch — npm=$NPM_VERSION swift=$SWIFT_VERSION" | |
| echo "Update 'serverVersion' in Sources/WaxMCPServer/main.swift to match npm/waxmcp/package.json" | |
| exit 1 | |
| fi | |
| echo "Version consistency check passed: $NPM_VERSION" | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Authenticate to npm | |
| run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > "${HOME}/.npmrc" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish package | |
| working-directory: npm/waxmcp | |
| run: npm publish --access public |