frankenphp/.github/workflows/static.yml
Kévin Dunglas 1f3007337d
feat: create a static build of FrankenPHP (#198)
* ci: create a static build of FrankenPHP

* try to use alpine

* path mapping

* cache and fixes

* fix

* fix include path

* fix include path

* fix include path

* switch to Docker

* fix github token

* cleanup

* various improvements

* macOS instructions

* fix GHA

* docs

* feat: mac static builds

* minor fix

* fix wd

* Apple silicon build

* Revert "Apple silicon build"

This reverts commit 7a2997e092.

* add opcache

* update builder

* upgrade to PHP 8.2

* switch to upstream static-php-cli, add intl
2023-09-12 22:08:19 +02:00

98 lines
3.2 KiB
YAML

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.ref_name}}
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-dev
path: frankenphp
build-mac:
name: Build macOS binaries
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: crazywhalecc/static-php-cli
path: 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: Install missing system dependencies
run: ./bin/spc doctor --auto-fix
working-directory: static-php-cli/
- 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 static libphp
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"
- 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"
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: frankenphp-mac-x86_64-dev
path: caddy/frankenphp/frankenphp