build-unix.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. name: "CI on Unix"
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. os:
  6. required: true
  7. description: Build target OS
  8. type: choice
  9. options:
  10. - 'linux-x86_64'
  11. - 'linux-aarch64'
  12. - 'macos-x86_64'
  13. - 'macos-aarch64'
  14. php-version:
  15. required: true
  16. description: PHP version to compile
  17. default: '8.3'
  18. type: choice
  19. options:
  20. - '8.4'
  21. - '8.3'
  22. - '8.2'
  23. - '8.1'
  24. - '8.0'
  25. extensions:
  26. description: Extensions to build (comma separated)
  27. required: true
  28. type: string
  29. extra-libs:
  30. description: Extra libraries to build (optional, comma separated)
  31. type: string
  32. build-cli:
  33. description: Build cli binary
  34. default: true
  35. type: boolean
  36. build-micro:
  37. description: Build phpmicro binary
  38. type: boolean
  39. build-fpm:
  40. description: Build fpm binary
  41. type: boolean
  42. prefer-pre-built:
  43. description: Prefer pre-built binaries (reduce build time)
  44. type: boolean
  45. default: true
  46. debug:
  47. description: Show full build logs
  48. type: boolean
  49. no-strip:
  50. description: Keep debug symbols for debugging
  51. type: boolean
  52. default: false
  53. env:
  54. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  55. jobs:
  56. define-build:
  57. name: "Define Build Scripts"
  58. runs-on: ubuntu-latest
  59. outputs:
  60. run: ${{ steps.gendef.outputs.run }}
  61. download: ${{ steps.gendef.outputs.download }}
  62. build: ${{ steps.gendef.outputs.build }}
  63. steps:
  64. - name: "Checkout"
  65. uses: actions/checkout@v4
  66. - name: "Define"
  67. id: gendef
  68. run: |
  69. case "${{ inputs.os }}" in
  70. linux-x86_64)
  71. DOWN_CMD="./bin/spc-alpine-docker download"
  72. BUILD_CMD="./bin/spc-alpine-docker build"
  73. RUNS_ON="ubuntu-latest"
  74. ;;
  75. linux-aarch64)
  76. DOWN_CMD="SPC_USE_ARCH=aarch64 ./bin/spc-alpine-docker download"
  77. BUILD_CMD="SPC_USE_ARCH=aarch64 ./bin/spc-alpine-docker build"
  78. RUNS_ON="ubuntu-latest"
  79. ;;
  80. macos-x86_64)
  81. DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
  82. BUILD_CMD="./bin/spc build"
  83. RUNS_ON="macos-13"
  84. ;;
  85. macos-aarch64)
  86. DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
  87. BUILD_CMD="./bin/spc build"
  88. RUNS_ON="macos-14"
  89. ;;
  90. esac
  91. DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"
  92. BUILD_CMD="$BUILD_CMD ${{ inputs.extensions }}"
  93. if [ -n "${{ inputs.extra-libs }}" ]; then
  94. DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
  95. BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
  96. fi
  97. if [ ${{ inputs.debug }} == true ]; then
  98. DOWN_CMD="$DOWN_CMD --debug"
  99. BUILD_CMD="$BUILD_CMD --debug"
  100. fi
  101. if [ ${{ inputs.prefer-pre-built }} == true ]; then
  102. DOWN_CMD="$DOWN_CMD --prefer-pre-built"
  103. fi
  104. if [ ${{ inputs.build-cli }} == true ]; then
  105. BUILD_CMD="$BUILD_CMD --build-cli"
  106. fi
  107. if [ ${{ inputs.build-micro }} == true ]; then
  108. BUILD_CMD="$BUILD_CMD --build-micro"
  109. fi
  110. if [ ${{ inputs.build-fpm }} == true ]; then
  111. BUILD_CMD="$BUILD_CMD --build-fpm"
  112. fi
  113. echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
  114. echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
  115. echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
  116. build:
  117. name: "Build ${{ inputs.version }} on ${{ inputs.os }}"
  118. runs-on: ${{ needs.define-build.outputs.run }}
  119. needs: define-build
  120. timeout-minutes: 240
  121. steps:
  122. - name: "Checkout"
  123. uses: actions/checkout@v4
  124. - name: "Setup PHP"
  125. uses: shivammathur/setup-php@v2
  126. with:
  127. php-version: ${{ inputs.php-version }}
  128. tools: pecl, composer
  129. extensions: curl, openssl, mbstring
  130. ini-values: memory_limit=-1
  131. env:
  132. phpts: nts
  133. # Cache downloaded source
  134. - id: cache-download
  135. uses: actions/cache@v4
  136. with:
  137. path: downloads
  138. key: php-dependencies-${{ inputs.os }}
  139. - name: "Download sources"
  140. run: ${{ needs.define-build.outputs.download }}
  141. - name: "Build PHP"
  142. run: ${{ needs.define-build.outputs.build }}
  143. #- name: Setup tmate session
  144. # if: ${{ failure() }}
  145. # uses: mxschmitt/action-tmate@v3
  146. # Upload cli executable
  147. - if: ${{ inputs.build-cli == true }}
  148. name: "Upload PHP cli SAPI"
  149. uses: actions/upload-artifact@v4
  150. with:
  151. name: php-cli-${{ inputs.php-version }}-${{ inputs.os }}
  152. path: buildroot/bin/php
  153. # Upload micro self-extracted executable
  154. - if: ${{ inputs.build-micro == true }}
  155. name: "Upload PHP micro SAPI"
  156. uses: actions/upload-artifact@v4
  157. with:
  158. name: php-micro-${{ inputs.php-version }}-${{ inputs.os }}
  159. path: buildroot/bin/micro.sfx
  160. # Upload fpm executable
  161. - if: ${{ inputs.build-fpm == true }}
  162. name: "Upload PHP fpm SAPI"
  163. uses: actions/upload-artifact@v4
  164. with:
  165. name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
  166. path: buildroot/bin/php-fpm
  167. # Upload extensions metadata
  168. - uses: actions/upload-artifact@v4
  169. name: "Upload License Files"
  170. with:
  171. name: license-files
  172. path: buildroot/license/
  173. - uses: actions/upload-artifact@v4
  174. name: "Upload Build Metadata"
  175. with:
  176. name: build-meta
  177. path: |
  178. buildroot/build-extensions.json
  179. buildroot/build-libraries.json