build-macos-x86_64.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. name: CI on x86_64 macOS
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. version:
  6. required: true
  7. description: php version to compile
  8. default: '8.3'
  9. type: choice
  10. options:
  11. - '8.4'
  12. - '8.3'
  13. - '8.2'
  14. - '8.1'
  15. - '8.0'
  16. - '7.4'
  17. build-cli:
  18. description: build cli binary
  19. default: true
  20. type: boolean
  21. build-micro:
  22. description: build phpmicro binary
  23. type: boolean
  24. build-fpm:
  25. description: build fpm binary
  26. type: boolean
  27. extensions:
  28. description: extensions to compile (comma separated)
  29. required: true
  30. type: string
  31. prefer-pre-built:
  32. description: prefer pre-built binaries (reduce build time)
  33. type: boolean
  34. default: true
  35. debug:
  36. description: enable debug logs
  37. type: boolean
  38. env:
  39. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  40. jobs:
  41. build:
  42. name: build ${{ inputs.version }} on macOS x86_64
  43. runs-on: macos-13
  44. steps:
  45. - uses: actions/checkout@v4
  46. # Install macOS missing packages and mark os suffix
  47. - run: |
  48. brew install automake gzip
  49. echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
  50. - name: "Setup PHP"
  51. uses: shivammathur/setup-php@v2
  52. with:
  53. php-version: 8.1
  54. tools: pecl, composer
  55. extensions: curl, openssl, mbstring, tokenizer
  56. ini-values: memory_limit=-1
  57. # Cache composer dependencies
  58. - id: cache-composer-deps
  59. uses: actions/cache@v4
  60. with:
  61. path: vendor
  62. key: composer-dependencies
  63. # If there's no Composer cache, install dependencies
  64. - if: steps.cache-composer-deps.outputs.cache-hit != 'true'
  65. run: composer update --no-dev --classmap-authoritative
  66. - name: Generate hashed key for download cache
  67. run: |
  68. INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
  69. echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
  70. # Cache downloaded source
  71. - id: cache-download
  72. uses: actions/cache@v4
  73. with:
  74. path: downloads
  75. key: php-${{ env.INPUT_HASH }}
  76. # With or without debug
  77. - if: inputs.debug == true
  78. run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
  79. - if: inputs.prefer-pre-built == true
  80. run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
  81. # With target select: cli, micro or both
  82. - if: ${{ inputs.build-cli == true }}
  83. run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
  84. - if: ${{ inputs.build-micro == true }}
  85. run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
  86. - if: ${{ inputs.build-fpm == true }}
  87. run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
  88. # If there's no dependencies cache, fetch sources, with or without debug
  89. - if: steps.cache-download.outputs.cache-hit != 'true'
  90. run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
  91. # Run build command
  92. - run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
  93. # Upload cli executable
  94. - if: ${{ inputs.build-cli == true }}
  95. uses: actions/upload-artifact@v4
  96. with:
  97. name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
  98. path: buildroot/bin/php
  99. # Upload micro self-extracted executable
  100. - if: ${{ inputs.build-micro == true }}
  101. uses: actions/upload-artifact@v4
  102. with:
  103. name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
  104. path: buildroot/bin/micro.sfx
  105. # Upload fpm executable
  106. - if: ${{ inputs.build-fpm == true }}
  107. uses: actions/upload-artifact@v4
  108. with:
  109. name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
  110. path: buildroot/bin/php-fpm
  111. # Upload extensions metadata
  112. - uses: actions/upload-artifact@v4
  113. with:
  114. name: license-files
  115. path: buildroot/license/
  116. - uses: actions/upload-artifact@v4
  117. with:
  118. name: build-meta
  119. path: |
  120. buildroot/build-extensions.json
  121. buildroot/build-libraries.json