gulp2 #11
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: Multi-Platform Build | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main] | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| name: Build for ${{ matrix.os }} | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: windows | |
| runs-on: windows-latest | |
| arch: amd64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.21" | |
| - name: Install dependencies (Ubuntu) | |
| if: matrix.os == 'linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libsqlite3-dev build-essential | |
| - name: Build SQLite (Unix) | |
| if: matrix.os != 'windows' | |
| run: | | |
| cd sqlite | |
| if [ ! -d "sqlite-latest" ]; then | |
| # Download and extract SQLite source if not present | |
| curl -O https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz | |
| tar xzf sqlite-autoconf-3450100.tar.gz | |
| mv sqlite-autoconf-3450100 sqlite-latest | |
| fi | |
| cd sqlite-latest | |
| ./configure --prefix=$(pwd)/../install --enable-static --disable-shared "CFLAGS=-DSQLITE_ENABLE_DBPAGE_VTAB=1 -O2" | |
| make | |
| make install | |
| - name: Setup MSVC (Windows) | |
| if: matrix.os == 'windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Build SQLite (Windows) | |
| if: matrix.os == 'windows' | |
| run: | | |
| cd sqlite | |
| if (!(Test-Path "sqlite-latest")) { | |
| Invoke-WebRequest -Uri "https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz" -OutFile "sqlite-autoconf-3450100.tar.gz" | |
| tar -xzf sqlite-autoconf-3450100.tar.gz | |
| Rename-Item sqlite-autoconf-3450100 sqlite-latest | |
| } | |
| cd sqlite-latest | |
| # Use Visual Studio tools for Windows build as recommended by SQLite docs | |
| nmake /f Makefile.msc clean | |
| nmake /f Makefile.msc sqlite3.c | |
| nmake /f Makefile.msc sqlite3.exe | |
| # Create install directory structure | |
| New-Item -ItemType Directory -Force -Path "../install/bin" | |
| New-Item -ItemType Directory -Force -Path "../install/include" | |
| New-Item -ItemType Directory -Force -Path "../install/lib" | |
| # Copy built files to install directory | |
| Copy-Item "sqlite3.exe" "../install/bin/" | |
| Copy-Item "sqlite3.h" "../install/include/" | |
| Copy-Item "sqlite3ext.h" "../install/include/" | |
| if (Test-Path "sqlite3.lib") { Copy-Item "sqlite3.lib" "../install/lib/" } | |
| - name: Build Bridge | |
| run: | | |
| cd bridge | |
| make | |
| - name: Set build environment (Darwin ARM64) | |
| if: matrix.os == 'darwin' && matrix.arch == 'arm64' | |
| run: | | |
| echo "GOOS=darwin" >> $GITHUB_ENV | |
| echo "GOARCH=arm64" >> $GITHUB_ENV | |
| echo "CGO_ENABLED=1" >> $GITHUB_ENV | |
| - name: Set build environment (Darwin AMD64) | |
| if: matrix.os == 'darwin' && matrix.arch == 'amd64' | |
| run: | | |
| echo "GOOS=darwin" >> $GITHUB_ENV | |
| echo "GOARCH=amd64" >> $GITHUB_ENV | |
| echo "CGO_ENABLED=1" >> $GITHUB_ENV | |
| - name: Set build environment (Linux) | |
| if: matrix.os == 'linux' | |
| run: | | |
| echo "GOOS=linux" >> $GITHUB_ENV | |
| echo "GOARCH=amd64" >> $GITHUB_ENV | |
| echo "CGO_ENABLED=1" >> $GITHUB_ENV | |
| - name: Set build environment (Windows) | |
| if: matrix.os == 'windows' | |
| run: | | |
| echo "GOOS=windows" >> $env:GITHUB_ENV | |
| echo "GOARCH=amd64" >> $env:GITHUB_ENV | |
| echo "CGO_ENABLED=1" >> $env:GITHUB_ENV | |
| - name: Build Client (Unix) | |
| if: matrix.os != 'windows' | |
| run: | | |
| cd client | |
| make build | |
| - name: Build Client (Windows) | |
| if: matrix.os == 'windows' | |
| run: | | |
| cd client | |
| # MSVC environment is already set up from previous step | |
| make build | |
| - name: Create release directory | |
| run: | | |
| mkdir -p release | |
| - name: Package binary (Unix) | |
| if: matrix.os != 'windows' | |
| run: | | |
| if [ "${{ matrix.os }}" = "darwin" ] && [ "${{ matrix.arch }}" = "arm64" ]; then | |
| BINARY_NAME="sqlrsync-${{ matrix.os }}-${{ matrix.arch }}" | |
| else | |
| BINARY_NAME="sqlrsync-${{ matrix.os }}-${{ matrix.arch }}" | |
| fi | |
| cp client/bin/sqlrsync release/${BINARY_NAME} | |
| - name: Package binary (Windows) | |
| if: matrix.os == 'windows' | |
| run: | | |
| $BINARY_NAME = "sqlrsync-${{ matrix.os }}-${{ matrix.arch }}.exe" | |
| Copy-Item "client/bin/sqlrsync.exe" "release/$BINARY_NAME" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sqlrsync-${{ matrix.os }}-${{ matrix.arch }} | |
| path: release/* | |
| release: | |
| if: github.event_name == 'release' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Upload to release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| sqlrsync-linux-amd64/sqlrsync-linux-amd64 | |
| sqlrsync-darwin-amd64/sqlrsync-darwin-amd64 | |
| sqlrsync-darwin-arm64/sqlrsync-darwin-arm64 | |
| sqlrsync-windows-amd64/sqlrsync-windows-amd64.exe | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN_GITHUB }} |