release-build.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.1"
  17. micro-version:
  18. - "8.1.26"
  19. operating-system:
  20. - "linux-x86_64"
  21. - "macos-x86_64"
  22. - "linux-aarch64"
  23. - "macos-aarch64"
  24. steps:
  25. - name: "Checkout"
  26. uses: "actions/checkout@v4"
  27. - if: inputs.debug == true
  28. run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
  29. - name: "Install PHP for official runners"
  30. uses: "shivammathur/setup-php@v2"
  31. with:
  32. coverage: none
  33. tools: composer:v2
  34. php-version: "${{ matrix.php-version }}"
  35. ini-values: memory_limit=-1
  36. - name: "Get Composer Cache Directory"
  37. id: composer-cache
  38. run: |
  39. echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
  40. - name: "Cache Composer dependencies"
  41. uses: "actions/cache@v3"
  42. with:
  43. path: "${{ steps.composer-cache.outputs.dir }}"
  44. key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}"
  45. restore-keys: |
  46. php-${{ matrix.php-version }}-locked-composer
  47. - name: "Install Locked Dependencies"
  48. run: "composer install --no-interaction --no-progress"
  49. - name: "Build PHAR File"
  50. run: "composer build:phar"
  51. - name: "Download minimal combination"
  52. run: |
  53. curl https://dl.static-php.dev/static-php-cli/minimal/php-${{ matrix.micro-version }}-micro-${{ matrix.operating-system }}.tar.gz -o tmp.tgz
  54. tar -zxvf tmp.tgz
  55. - name: "Generate Executable"
  56. run: |
  57. cat micro.sfx spc.phar > spc
  58. chmod +x spc
  59. - name: "Archive Executable"
  60. run: |
  61. tar -czf spc-${{ matrix.operating-system }}.tar.gz spc
  62. echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV
  63. echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV
  64. if [ "${{ matrix.operating-system }}" == "linux-x86_64" ]; then
  65. ./spc dev:extensions
  66. fi
  67. - name: "Copy file"
  68. run: "mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS"
  69. - name: upload binaries to release
  70. uses: softprops/action-gh-release@v1
  71. if: ${{startsWith(github.ref, 'refs/tags/') }}
  72. with:
  73. files: ${{ env.filename }}
  74. - name: "Deploy to Self-Hosted Server"
  75. if: github.repository == 'crazywhalecc/static-php-cli'
  76. uses: easingthemes/ssh-deploy@main
  77. env:
  78. SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }}
  79. ARGS: "-rltgoDzvO"
  80. SOURCE: "dist/"
  81. REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }}
  82. REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }}
  83. REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }}
  84. TARGET: ${{ secrets.DEPLOY_SERVER_TARGET_SPC_NIGHTLY }}
  85. - name: "Upload Artifact"
  86. uses: actions/upload-artifact@v3
  87. with:
  88. path: spc
  89. name: spc-${{ matrix.operating-system }}