name: Build binary releases on: pull_request: branches: - main push: branches: - main tags: - v* workflow_dispatch: inputs: {} jobs: build-linux: name: Build Linux x86_64 binary runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: version: latest - name: Build id: build uses: docker/bake-action@v3 with: pull: true load: true targets: static-builder set: | *.cache-from=type=gha,scope=${{github.ref}}-static-builder *.cache-from=type=gha,scope=refs/heads/main-static-builder *.cache-to=type=gha,scope=${{github.ref}}-static-builder env: VERSION: ${{ github.sha }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Copy binary run: docker cp $(docker create --name static-builder dunglas/frankenphp:static-builder):/go/src/app/caddy/frankenphp/frankenphp frankenphp ; docker rm static-builder - name: Upload binary uses: actions/upload-artifact@v3 with: name: frankenphp-linux-x86_64-${{ github.sha }} path: frankenphp build-mac: name: Build macOS x86_64 binaries runs-on: macos-latest env: HOMEBREW_NO_AUTO_UPDATE: 1 steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: repository: crazywhalecc/static-php-cli path: static-php-cli - name: Install missing system dependencies run: brew install automake working-directory: static-php-cli/ - uses: actions/setup-go@v4 with: go-version: '1.21' - name: Install static-php-cli dependencies working-directory: static-php-cli/ run: composer install --no-dev -a - name: Fetch libraries sources working-directory: static-php-cli/ run: ./bin/spc fetch --with-php=8.2 -A env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build libphp.a working-directory: static-php-cli/ run: ./bin/spc build --enable-zts --build-embed --debug "bcmath,calendar,ctype,curl,dba,dom,exif,filter,fileinfo,gd,iconv,intl,mbstring,mbregex,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib,apcu" - name: Set CGO flags working-directory: static-php-cli/ run: | echo "CGO_CFLAGS=$(./buildroot/bin/php-config --includes | sed s#-I/#-I$PWD/buildroot/#g)" >> "$GITHUB_ENV" echo "CGO_LDFLAGS=-framework CoreFoundation -framework SystemConfiguration $(./buildroot/bin/php-config --ldflags) $(./buildroot/bin/php-config --libs)" >> "$GITHUB_ENV" echo "PHP_VERSION=$(./buildroot/bin/php-config --version)" >> "$GITHUB_ENV" - name: Build FrankenPHP working-directory: caddy/frankenphp/ run: | go build -buildmode=pie -tags "cgo netgo osusergo static_build" -ldflags "-linkmode=external -extldflags -static-pie -w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ${{ github.sha }} PHP $PHP_VERSION Caddy'" ./frankenphp version - name: Upload binary uses: actions/upload-artifact@v3 with: name: frankenphp-mac-x86_64-${{ github.sha }} path: caddy/frankenphp/frankenphp