static.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. name: Build binary releases
  2. on:
  3. pull_request:
  4. branches:
  5. - main
  6. push:
  7. branches:
  8. - main
  9. tags:
  10. - v*
  11. workflow_dispatch:
  12. inputs: {}
  13. jobs:
  14. build-linux:
  15. name: Build Linux x86_64 binary
  16. runs-on: ubuntu-latest
  17. steps:
  18. - uses: actions/checkout@v4
  19. - name: Set up Docker Buildx
  20. uses: docker/setup-buildx-action@v2
  21. with:
  22. version: latest
  23. - name: Build
  24. id: build
  25. uses: docker/bake-action@v3
  26. with:
  27. pull: true
  28. load: true
  29. targets: static-builder
  30. set: |
  31. *.cache-from=type=gha,scope=${{github.ref}}-static-builder
  32. *.cache-from=type=gha,scope=refs/heads/main-static-builder
  33. *.cache-to=type=gha,scope=${{github.ref}}-static-builder
  34. env:
  35. VERSION: ${{ github.sha }}
  36. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  37. - name: Copy binary
  38. run: docker cp $(docker create --name static-builder dunglas/frankenphp:static-builder):/go/src/app/caddy/frankenphp/frankenphp frankenphp ; docker rm static-builder
  39. - name: Upload binary
  40. uses: actions/upload-artifact@v3
  41. with:
  42. name: frankenphp-linux-x86_64-${{ github.sha }}
  43. path: frankenphp
  44. build-mac:
  45. name: Build macOS x86_64 binaries
  46. runs-on: macos-latest
  47. env:
  48. HOMEBREW_NO_AUTO_UPDATE: 1
  49. steps:
  50. - uses: actions/checkout@v4
  51. - uses: actions/checkout@v4
  52. with:
  53. repository: crazywhalecc/static-php-cli
  54. path: static-php-cli
  55. - name: Install missing system dependencies
  56. run: brew install automake
  57. working-directory: static-php-cli/
  58. - uses: actions/setup-go@v4
  59. with:
  60. go-version: '1.21'
  61. - name: Install static-php-cli dependencies
  62. working-directory: static-php-cli/
  63. run: composer install --no-dev -a
  64. - name: Fetch libraries sources
  65. working-directory: static-php-cli/
  66. run: ./bin/spc fetch --with-php=8.2 -A
  67. env:
  68. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. - name: Build libphp.a
  70. working-directory: static-php-cli/
  71. 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"
  72. - name: Set CGO flags
  73. working-directory: static-php-cli/
  74. run: |
  75. echo "CGO_CFLAGS=$(./buildroot/bin/php-config --includes | sed s#-I/#-I$PWD/buildroot/#g)" >> "$GITHUB_ENV"
  76. echo "CGO_LDFLAGS=-framework CoreFoundation -framework SystemConfiguration $(./buildroot/bin/php-config --ldflags) $(./buildroot/bin/php-config --libs)" >> "$GITHUB_ENV"
  77. echo "PHP_VERSION=$(./buildroot/bin/php-config --version)" >> "$GITHUB_ENV"
  78. - name: Build FrankenPHP
  79. working-directory: caddy/frankenphp/
  80. run: |
  81. 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'"
  82. ./frankenphp version
  83. - name: Upload binary
  84. uses: actions/upload-artifact@v3
  85. with:
  86. name: frankenphp-mac-x86_64-${{ github.sha }}
  87. path: caddy/frankenphp/frankenphp