Update BUILD_INSTRUCTIONS.md with comprehensive GitHub Actions workflow #1
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 Libraries | |
| on: | |
| push: | |
| branches: [ feature/gopher-auth-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) | |
| 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: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: linux/arm64 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Make build script executable | |
| run: chmod +x docker/build-linux-${{ matrix.arch }}.sh | |
| - name: Configure version | |
| run: | | |
| # Use version from env variable (which comes from input or default) | |
| echo "Setting version to: ${{ env.LIB_VERSION }}" | |
| sed -i "s/VERSION [0-9.]\+/VERSION ${{ env.LIB_VERSION }}/" src/auth/CMakeLists.txt | |
| VERSION=$(grep "project(gopher-mcp-auth VERSION" src/auth/CMakeLists.txt | sed -n 's/.*VERSION \([0-9.]\+\).*/\1/p') | |
| echo "Building with version: $VERSION" | |
| - name: Build library | |
| run: | | |
| echo "Building for Linux ${{ matrix.arch }}..." | |
| echo "Version: ${{ env.LIB_VERSION }}" | |
| ./docker/build-linux-${{ matrix.arch }}.sh | |
| - name: Verify build output | |
| run: | | |
| echo "Checking build output..." | |
| ls -la build-output/linux-${{ matrix.arch }}/ | |
| if [ ! -f "build-output/linux-${{ matrix.arch }}/libgopher_mcp_auth.so.0.1.0" ]; then | |
| echo "Error: Library 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/build-windows-${{ matrix.arch }}.sh | |
| - name: Configure version | |
| run: | | |
| # Use version from env variable (which comes from input or default) | |
| echo "Setting version to: ${{ env.LIB_VERSION }}" | |
| sed -i "s/VERSION [0-9.]\+/VERSION ${{ env.LIB_VERSION }}/" src/auth/CMakeLists.txt | |
| VERSION=$(grep "project(gopher-mcp-auth VERSION" src/auth/CMakeLists.txt | sed -n 's/.*VERSION \([0-9.]\+\).*/\1/p') | |
| echo "Building with version: $VERSION" | |
| - name: Build library | |
| run: | | |
| echo "Building for Windows ${{ matrix.arch }}..." | |
| echo "Version: ${{ env.LIB_VERSION }}" | |
| ./docker/build-windows-${{ matrix.arch }}.sh | |
| - name: Verify build output | |
| run: | | |
| echo "Checking build output..." | |
| ls -la build-output/windows-${{ matrix.arch }}/ | |
| if [ ! -f "build-output/windows-${{ matrix.arch }}/gopher_mcp_auth.dll" ]; then | |
| echo "Error: DLL 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-15-intel # Intel runner (x86_64) - new macOS 15 Intel runner | |
| - arch: arm64 | |
| runner: macos-15 # Apple Silicon runner (ARM64) - macOS 15 ARM64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install dependencies | |
| run: | | |
| # Always install native cmake for build system | |
| brew install cmake | |
| if [ "${{ matrix.arch }}" == "x64" ]; then | |
| echo "x64 build will use cross-compilation with system libraries" | |
| # No need to install x86_64 Homebrew - we'll use system libraries | |
| else | |
| # For ARM64 builds, install native dependencies | |
| brew install openssl@3 curl | |
| fi | |
| - name: Make build script executable | |
| run: chmod +x docker/build-mac-${{ matrix.arch }}.sh | |
| - name: Configure version | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then | |
| echo "Setting version from workflow input: ${{ github.event.inputs.version }}" | |
| sed -i '' "s/VERSION [0-9.]*/VERSION ${{ github.event.inputs.version }}/" src/auth/CMakeLists.txt | |
| else | |
| echo "Using version from CMakeLists.txt" | |
| fi | |
| VERSION=$(grep "project(gopher-mcp-auth VERSION" src/auth/CMakeLists.txt | sed -n 's/.*VERSION \([0-9.]*\).*/\1/p') | |
| echo "Building with version: $VERSION" | |
| echo "LIB_VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Build library | |
| run: | | |
| echo "Building for macOS ${{ matrix.arch }}..." | |
| echo "Version: ${{ env.LIB_VERSION }}" | |
| ./docker/build-mac-${{ matrix.arch }}.sh | |
| - name: Verify build output | |
| run: | | |
| echo "Checking build output..." | |
| ls -la build-output/mac-${{ matrix.arch }}/ | |
| if [ ! -f "build-output/mac-${{ matrix.arch }}/libgopher_mcp_auth.0.1.0.dylib" ]; then | |
| echo "Error: Library 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: Package All Artifacts | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows, build-macos] | |
| if: | | |
| (github.event_name == 'push' && github.ref == 'refs/heads/feature/gopher-auth-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_auth-linux-x64.tar.gz -C linux-x64-libs . | |
| fi | |
| # Linux ARM64 | |
| if [ -d "linux-arm64-libs" ]; then | |
| tar -czf ../libgopher_mcp_auth-linux-arm64.tar.gz -C linux-arm64-libs . | |
| fi | |
| # Windows x64 | |
| if [ -d "windows-x64-libs" ]; then | |
| zip -r ../libgopher_mcp_auth-windows-x64.zip windows-x64-libs/* | |
| fi | |
| # Windows ARM64 | |
| if [ -d "windows-arm64-libs" ]; then | |
| zip -r ../libgopher_mcp_auth-windows-arm64.zip windows-arm64-libs/* | |
| fi | |
| # macOS x64 | |
| if [ -d "macos-x64-libs" ]; then | |
| tar -czf ../libgopher_mcp_auth-macos-x64.tar.gz -C macos-x64-libs . | |
| fi | |
| # macOS ARM64 | |
| if [ -d "macos-arm64-libs" ]; then | |
| tar -czf ../libgopher_mcp_auth-macos-arm64.tar.gz -C macos-arm64-libs . | |
| fi | |
| cd .. | |
| ls -la *.tar.gz *.zip 2>/dev/null || true | |
| - name: Generate build report | |
| run: | | |
| cat > BUILD_REPORT.md << 'EOF' | |
| # Build Report | |
| ## 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 compatible, GLIBC 2.31+) | |
| - ✅ ARM64 (Ubuntu 20.04 compatible, GLIBC 2.31+) | |
| ### Windows | |
| - ✅ x64 (Windows 7+, using MinGW-w64) | |
| - ✅ ARM64 (Windows 10+, using LLVM-MinGW) | |
| ### macOS | |
| - ✅ x64 (macOS 10.15+) | |
| - ✅ ARM64 (macOS 11.0+) | |
| ## Files Included | |
| Each platform package includes: | |
| - Main library file (`.so`, `.dll`, or `.dylib`) | |
| - Import library (`.lib` for Windows) | |
| - Verification tool | |
| - Symbolic links (for Linux/macOS) | |
| ## Usage | |
| See BUILD_INSTRUCTIONS.md for detailed usage instructions for each platform. | |
| EOF | |
| - name: Upload build archives | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: all-platform-archives | |
| path: | | |
| *.tar.gz | |
| *.zip | |
| BUILD_REPORT.md | |
| retention-days: 30 | |
| - name: Generate release tag | |
| id: tag | |
| run: | | |
| # Use the LIB_VERSION from the global env | |
| 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}" | |
| echo "Version for release: ${VERSION}" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.tag }} | |
| name: libgopher_mcp_auth ${{ steps.tag.outputs.tag }} | |
| body_path: BUILD_REPORT.md | |
| draft: false | |
| prerelease: false | |
| files: | | |
| libgopher_mcp_auth-linux-x64.tar.gz | |
| libgopher_mcp_auth-linux-arm64.tar.gz | |
| libgopher_mcp_auth-windows-x64.zip | |
| libgopher_mcp_auth-windows-arm64.zip | |
| libgopher_mcp_auth-macos-x64.tar.gz | |
| libgopher_mcp_auth-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 "" | |
| # Check each job result | |
| if [ "${{ needs.build-linux.result }}" == "success" ]; then | |
| echo "✅ Linux builds completed successfully" | |
| else | |
| echo "❌ Linux builds failed" | |
| fi | |
| if [ "${{ needs.build-windows.result }}" == "success" ]; then | |
| echo "✅ Windows builds completed successfully" | |
| else | |
| echo "❌ Windows builds failed" | |
| fi | |
| if [ "${{ needs.build-macos.result }}" == "success" ]; then | |
| echo "✅ macOS builds completed successfully" | |
| else | |
| echo "❌ macOS builds failed" | |
| fi | |
| echo "" | |
| echo "### Platform Coverage" | |
| echo "- Linux: x64, ARM64" | |
| echo "- Windows: x64, ARM64" | |
| echo "- macOS: x64, ARM64" | |
| echo "" | |
| echo "Total configurations built: 6" |