Add dev_improve_client_fetch_tools_cross_build branch to CI workflow #33
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: Build All Platforms | |
| on: | |
| push: | |
| branches: [ dev_cross_build, dev_improve_client_fetch_tools_cross_build ] | |
| workflow_dispatch: | |
| inputs: | |
| build_type: | |
| description: 'Build type' | |
| required: false | |
| default: 'Release' | |
| type: choice | |
| options: | |
| - Release | |
| - Debug | |
| version: | |
| description: 'Library version (e.g., 0.1.0)' | |
| required: false | |
| default: '0.1.0' | |
| type: string | |
| create_release: | |
| description: 'Create GitHub Release' | |
| required: false | |
| default: true | |
| type: boolean | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| BUILD_TYPE: ${{ github.event.inputs.build_type || 'Release' }} | |
| LIB_VERSION: ${{ github.event.inputs.version || '0.1.0' }} | |
| jobs: | |
| # Linux builds (x64 and ARM64) | |
| # ARM64 uses cross-compilation (no QEMU emulation) for fast builds | |
| build-linux: | |
| name: Build Linux ${{ matrix.arch }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: [x64, arm64] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Make build script executable | |
| run: chmod +x docker-mcp/build-linux-${{ matrix.arch }}-docker.sh | |
| - name: Build library | |
| run: | | |
| echo "Building for Linux ${{ matrix.arch }}..." | |
| ./docker-mcp/build-linux-${{ matrix.arch }}-docker.sh | |
| - name: Verify build output | |
| run: | | |
| echo "Checking build output..." | |
| ls -la build-output/linux-${{ matrix.arch }}/ | |
| # Check for main library | |
| if ls build-output/linux-${{ matrix.arch }}/libgopher-mcp*.so* 1>/dev/null 2>&1; then | |
| echo "✓ Library found" | |
| else | |
| echo "Error: Library not found!" | |
| exit 1 | |
| fi | |
| # Check for headers | |
| if [ -d "build-output/linux-${{ matrix.arch }}/include/mcp" ]; then | |
| echo "✓ Headers found" | |
| ls build-output/linux-${{ matrix.arch }}/include/mcp/ | head -10 | |
| else | |
| echo "Error: Headers not found!" | |
| exit 1 | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-${{ matrix.arch }}-libs | |
| path: build-output/linux-${{ matrix.arch }}/* | |
| retention-days: 7 | |
| # Windows builds (x64 and ARM64) | |
| build-windows: | |
| name: Build Windows ${{ matrix.arch }} | |
| runs-on: ubuntu-latest # Using Linux with Docker for cross-compilation | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: [x64, arm64] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Make build script executable | |
| run: chmod +x docker-mcp/build-windows-${{ matrix.arch }}.sh | |
| - name: Build library | |
| run: | | |
| echo "Building for Windows ${{ matrix.arch }}..." | |
| ./docker-mcp/build-windows-${{ matrix.arch }}.sh | |
| - name: Verify build output | |
| run: | | |
| echo "Checking build output..." | |
| ls -la build-output/windows-${{ matrix.arch }}/ | |
| # Check for main library | |
| if ls build-output/windows-${{ matrix.arch }}/gopher-mcp*.dll 1>/dev/null 2>&1; then | |
| echo "✓ DLL found" | |
| else | |
| echo "Error: DLL not found!" | |
| exit 1 | |
| fi | |
| # Check for headers | |
| if [ -d "build-output/windows-${{ matrix.arch }}/include/mcp" ]; then | |
| echo "✓ Headers found" | |
| ls build-output/windows-${{ matrix.arch }}/include/mcp/ | head -10 | |
| else | |
| echo "Error: Headers not found!" | |
| exit 1 | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-${{ matrix.arch }}-libs | |
| path: build-output/windows-${{ matrix.arch }}/* | |
| retention-days: 7 | |
| # macOS builds (x64 and ARM64) | |
| build-macos: | |
| name: Build macOS ${{ matrix.arch }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: x64 | |
| runner: macos-14 # Apple Silicon runner (cross-compile for x64) | |
| - arch: arm64 | |
| runner: macos-14 # Apple Silicon runner (M1) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install x86_64 dependencies (for cross-compilation) | |
| if: matrix.arch == 'x64' | |
| run: | | |
| echo "Installing x86_64 Homebrew and dependencies for cross-compilation..." | |
| # Install x86_64 Homebrew if not present | |
| if [ ! -f /usr/local/bin/brew ]; then | |
| echo "Installing x86_64 Homebrew..." | |
| arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" </dev/null | |
| fi | |
| # Install x86_64 dependencies | |
| echo "Installing x86_64 OpenSSL, libevent, and nghttp2..." | |
| arch -x86_64 /usr/local/bin/brew install openssl@3 libevent libnghttp2 || true | |
| # Verify installation | |
| echo "x86_64 library locations:" | |
| arch -x86_64 /usr/local/bin/brew --prefix openssl@3 || echo "/usr/local/opt/openssl@3" | |
| arch -x86_64 /usr/local/bin/brew --prefix libevent || echo "/usr/local/opt/libevent" | |
| arch -x86_64 /usr/local/bin/brew --prefix libnghttp2 || echo "/usr/local/opt/libnghttp2" | |
| - name: Make build script executable | |
| run: chmod +x docker-mcp/build-mac-${{ matrix.arch }}.sh | |
| - name: Build library | |
| run: | | |
| echo "Building for macOS ${{ matrix.arch }}..." | |
| ./docker-mcp/build-mac-${{ matrix.arch }}.sh | |
| - name: Verify build output | |
| run: | | |
| echo "Checking build output..." | |
| ls -la build-output/mac-${{ matrix.arch }}/ | |
| # Check for main library | |
| if ls build-output/mac-${{ matrix.arch }}/libgopher-mcp*.dylib 1>/dev/null 2>&1; then | |
| echo "✓ Library found" | |
| else | |
| echo "Error: Library not found!" | |
| exit 1 | |
| fi | |
| # Check for headers | |
| if [ -d "build-output/mac-${{ matrix.arch }}/include/mcp" ]; then | |
| echo "✓ Headers found" | |
| ls build-output/mac-${{ matrix.arch }}/include/mcp/ | head -10 | |
| else | |
| echo "Error: Headers not found!" | |
| exit 1 | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-${{ matrix.arch }}-libs | |
| path: build-output/mac-${{ matrix.arch }}/* | |
| retention-days: 7 | |
| # Create a release with all artifacts | |
| create-release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows, build-macos] | |
| if: | | |
| (github.event_name == 'push' && github.ref == 'refs/heads/dev_cross_build') || | |
| (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts/ | |
| - name: Create archive for each platform | |
| run: | | |
| cd artifacts | |
| # Linux x64 | |
| if [ -d "linux-x64-libs" ]; then | |
| tar -czf ../libgopher-mcp-linux-x64.tar.gz -C linux-x64-libs . | |
| echo "✓ Created libgopher-mcp-linux-x64.tar.gz" | |
| fi | |
| # Linux ARM64 | |
| if [ -d "linux-arm64-libs" ]; then | |
| tar -czf ../libgopher-mcp-linux-arm64.tar.gz -C linux-arm64-libs . | |
| echo "✓ Created libgopher-mcp-linux-arm64.tar.gz" | |
| fi | |
| # Windows x64 | |
| if [ -d "windows-x64-libs" ]; then | |
| zip -r ../libgopher-mcp-windows-x64.zip windows-x64-libs/* | |
| echo "✓ Created libgopher-mcp-windows-x64.zip" | |
| fi | |
| # Windows ARM64 | |
| if [ -d "windows-arm64-libs" ]; then | |
| zip -r ../libgopher-mcp-windows-arm64.zip windows-arm64-libs/* | |
| echo "✓ Created libgopher-mcp-windows-arm64.zip" | |
| fi | |
| # macOS x64 | |
| if [ -d "macos-x64-libs" ]; then | |
| tar -czf ../libgopher-mcp-macos-x64.tar.gz -C macos-x64-libs . | |
| echo "✓ Created libgopher-mcp-macos-x64.tar.gz" | |
| fi | |
| # macOS ARM64 | |
| if [ -d "macos-arm64-libs" ]; then | |
| tar -czf ../libgopher-mcp-macos-arm64.tar.gz -C macos-arm64-libs . | |
| echo "✓ Created libgopher-mcp-macos-arm64.tar.gz" | |
| fi | |
| cd .. | |
| echo "" | |
| echo "=== Release Archives ===" | |
| ls -la *.tar.gz *.zip 2>/dev/null || true | |
| - name: Generate build report | |
| run: | | |
| cat > BUILD_REPORT.md << EOF | |
| # Build Report - libgopher-mcp | |
| ## Build Information | |
| - **Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC") | |
| - **Commit:** ${{ github.sha }} | |
| - **Branch:** ${{ github.ref_name }} | |
| - **Build Type:** ${{ env.BUILD_TYPE }} | |
| - **Library Version:** ${{ env.LIB_VERSION }} | |
| ## Platforms Built | |
| ### Linux | |
| - ✅ x64 (Ubuntu 20.04+, GLIBC 2.31+) | |
| - ✅ ARM64 (Ubuntu 20.04+, GLIBC 2.31+) | |
| ### Windows | |
| - ✅ x64 (Windows 7+, MinGW-w64) | |
| - ✅ ARM64 (Windows 10+, LLVM-MinGW) | |
| ### macOS | |
| - ✅ x64 (macOS 10.15+, Intel) | |
| - ✅ ARM64 (macOS 11.0+, Apple Silicon) | |
| ## Package Contents | |
| Each platform package includes: | |
| - Main library (\`.so\`, \`.dll\`, or \`.dylib\`) | |
| - C API library for FFI bindings | |
| - Import library (\`.lib\` for Windows) | |
| - Header files (\`include/\`) | |
| - Verification tool | |
| ## Usage | |
| ### Linux/macOS | |
| \`\`\`bash | |
| tar -xzf libgopher-mcp-<platform>.tar.gz | |
| ./verify_mcp # Test the library | |
| \`\`\` | |
| ### Windows | |
| \`\`\`powershell | |
| Expand-Archive libgopher-mcp-windows-<arch>.zip | |
| .\verify_mcp.exe # Test the library | |
| \`\`\` | |
| EOF | |
| - name: Generate release tag | |
| id: tag | |
| run: | | |
| VERSION="${{ env.LIB_VERSION }}" | |
| TIMESTAMP=$(date +%Y%m%d-%H%M%S) | |
| TAG="v${VERSION}-${TIMESTAMP}" | |
| echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
| echo "Release tag: ${TAG}" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.tag }} | |
| name: libgopher-mcp ${{ steps.tag.outputs.tag }} | |
| body_path: BUILD_REPORT.md | |
| draft: false | |
| prerelease: false | |
| files: | | |
| libgopher-mcp-linux-x64.tar.gz | |
| libgopher-mcp-linux-arm64.tar.gz | |
| libgopher-mcp-windows-x64.zip | |
| libgopher-mcp-windows-arm64.zip | |
| libgopher-mcp-macos-x64.tar.gz | |
| libgopher-mcp-macos-arm64.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Summary job | |
| summary: | |
| name: Build Summary | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows, build-macos] | |
| if: always() | |
| steps: | |
| - name: Check build results | |
| run: | | |
| echo "## Build Summary" | |
| echo "" | |
| if [ "${{ needs.build-linux.result }}" == "success" ]; then | |
| echo "✅ Linux builds: SUCCESS" | |
| else | |
| echo "❌ Linux builds: FAILED" | |
| fi | |
| if [ "${{ needs.build-windows.result }}" == "success" ]; then | |
| echo "✅ Windows builds: SUCCESS" | |
| else | |
| echo "❌ Windows builds: FAILED" | |
| fi | |
| if [ "${{ needs.build-macos.result }}" == "success" ]; then | |
| echo "✅ macOS builds: SUCCESS" | |
| else | |
| echo "❌ macOS builds: FAILED" | |
| fi | |
| echo "" | |
| echo "### Platform Matrix" | |
| echo "| Platform | x64 | ARM64 |" | |
| echo "|----------|-----|-------|" | |
| echo "| Linux | ✓ | ✓ |" | |
| echo "| Windows | ✓ | ✓ |" | |
| echo "| macOS | ✓ | ✓ |" | |
| echo "" | |
| echo "Total configurations: 6" |