release-build.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: Build SPC Binary
  2. on:
  3. push:
  4. branches: [ "main" ]
  5. release:
  6. types:
  7. - published
  8. workflow_dispatch:
  9. jobs:
  10. build-release-artifacts:
  11. name: "Build SPC Binary"
  12. runs-on: ubuntu-latest
  13. strategy:
  14. matrix:
  15. php-version:
  16. - "8.2"
  17. micro-version:
  18. - "8.2.18"
  19. operating-system:
  20. - "linux-x86_64"
  21. - "macos-x86_64"
  22. - "linux-aarch64"
  23. - "macos-aarch64"
  24. - "windows-x64"
  25. steps:
  26. - name: "Checkout"
  27. uses: "actions/checkout@v4"
  28. - if: inputs.debug == true
  29. run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
  30. - name: "Install PHP for official runners"
  31. uses: "shivammathur/setup-php@v2"
  32. with:
  33. coverage: none
  34. tools: composer:v2
  35. php-version: "${{ matrix.php-version }}"
  36. ini-values: memory_limit=-1
  37. - name: "Get Composer Cache Directory"
  38. id: composer-cache
  39. run: |
  40. echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
  41. - name: "Cache Composer dependencies"
  42. uses: "actions/cache@v3"
  43. with:
  44. path: "${{ steps.composer-cache.outputs.dir }}"
  45. key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}"
  46. restore-keys: |
  47. php-${{ matrix.php-version }}-locked-composer
  48. - name: "Install Locked Dependencies"
  49. run: "composer install --no-interaction --no-progress"
  50. - name: "Build PHAR File"
  51. run: "composer build:phar"
  52. - name: "Download minimal combination"
  53. run: |
  54. if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then
  55. curl https://dl.static-php.dev/static-php-cli/windows/spc-min/php-${{ matrix.micro-version }}-micro-win.zip -o tmp.zip
  56. unzip tmp.zip
  57. else
  58. curl https://dl.static-php.dev/static-php-cli/minimal/php-${{ matrix.micro-version }}-micro-${{ matrix.operating-system }}.tar.gz -o tmp.tgz
  59. tar -zxvf tmp.tgz
  60. fi
  61. - name: "Generate Executable"
  62. run: |
  63. bin/spc micro:combine spc.phar -M micro.sfx -O spc -I "memory_limit=2G"
  64. if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then
  65. mv spc spc.exe
  66. else
  67. chmod +x spc
  68. fi
  69. - name: "Archive Executable"
  70. run: |
  71. if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then
  72. tar -czf spc-${{ matrix.operating-system }}.tar.gz spc
  73. echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV
  74. echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV
  75. if [ "${{ matrix.operating-system }}" == "linux-x86_64" ]; then
  76. ./spc dev:extensions
  77. fi
  78. else
  79. echo "filename=spc-${{ matrix.operating-system }}.exe" >> $GITHUB_ENV
  80. echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV
  81. fi
  82. - name: "Copy file"
  83. run: |
  84. if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then
  85. mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS
  86. else
  87. mkdir dist/ && cp spc.exe dist/${{ env.filename }}
  88. echo "SUFFIX=.exe" >> $GITHUB_ENV
  89. fi
  90. - name: upload binaries to release
  91. uses: softprops/action-gh-release@v1
  92. if: ${{startsWith(github.ref, 'refs/tags/') }}
  93. with:
  94. files: dist/${{ env.filename }}
  95. - name: "Deploy to Self-Hosted Server"
  96. if: github.repository == 'crazywhalecc/static-php-cli'
  97. uses: easingthemes/ssh-deploy@main
  98. env:
  99. SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }}
  100. ARGS: "-rltgoDzvO"
  101. SOURCE: "dist/"
  102. REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }}
  103. REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }}
  104. REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }}
  105. TARGET: ${{ secrets.DEPLOY_SERVER_TARGET_SPC_NIGHTLY }}
  106. - name: "Upload Artifact"
  107. uses: actions/upload-artifact@v3
  108. with:
  109. path: spc${{ env.SUFFIX }}
  110. name: spc-${{ matrix.operating-system }}${{ env.SUFFIX }}