Build Self-Hosted PHP Binary (Windows) #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Self-Hosted PHP Binary (Windows, spc-min) | |
on: | |
workflow_dispatch: | |
jobs: | |
build-release-artifacts: | |
name: "Build ${{ matrix.php-version }} on ${{ matrix.operating-system }}" | |
runs-on: ${{ matrix.operating-system }} | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: | |
- "8.0" | |
- "8.1" | |
- "8.2" | |
- "8.3" | |
operating-system: | |
- "windows-latest" | |
extensions: | |
- ctype,fileinfo,mbstring,tokenizer,phar | |
steps: | |
- name: "OS type" | |
id: os-type | |
run: | | |
$OS = "windows-x86_64" | |
Add-Content -Path $env:GITHUB_ENV -Value "OS=$OS" | |
- name: "Checkout static-php-cli" | |
uses: actions/checkout@v4 | |
with: | |
repository: crazywhalecc/static-php-cli | |
ref: main | |
- name: "Setup PHP" | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
tools: pecl, composer | |
extensions: curl, openssl, mbstring | |
ini-values: memory_limit=-1 | |
- name: "Cache Composer packages" | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
# Cache downloaded source | |
- id: cache-download | |
uses: actions/cache@v3 | |
with: | |
path: downloads | |
key: php-${{ matrix.php-version }}-dependencies | |
- name: "Install Dependencies" | |
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: "Validate SPC powershell script" | |
run: bin/spc --version | |
- name: "Run Build Tests (doctor)" | |
run: bin/spc doctor --auto-fix | |
# If there's no dependencies cache, fetch sources | |
- name: "Download sources" | |
env: | |
GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }} | |
run: bin/spc download --with-php=${{ matrix.php-version }} --for-extensions="${{ matrix.extensions }}" | |
- name: "Build extensions: ${{ matrix.extensions }}" | |
run: | | |
bin/spc doctor --auto-fix | |
bin/spc install-pkg upx | |
bin/spc build --build-cli --build-micro "${{ matrix.extensions }}" --debug --with-upx-pack | |
$PHPVER = bin/spc dev:php-ver | |
New-Item -ItemType Directory -Force -Path dist | |
Compress-Archive -Path "buildroot\bin\php.exe" -DestinationPath "dist\php-$PHPVER-cli-win.zip" | |
Compress-Archive -Path "buildroot\bin\micro.sfx" -DestinationPath "dist\php-$PHPVER-micro-win.zip" | |
echo ("PHPVER=" + $PHPVER) >> $env:GITHUB_ENV | |
- name: "Deploy cli to Zhamao Server" | |
uses: Creepios/[email protected] | |
with: | |
host: ${{ secrets.DEPLOY_SERVER_HOST }} | |
port: ${{ secrets.DEPLOY_SERVER_PORT }} | |
username: ${{ secrets.DEPLOY_SERVER_USER }} | |
privateKey: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }} | |
localPath: "dist/php-${{ env.PHPVER }}-cli-win.zip" | |
remotePath: ${{ secrets.DEPLOY_SERVER_TARGET_WINDOWS_SPC_MIN }}/ | |
- name: "Deploy micro to Zhamao Server" | |
uses: Creepios/[email protected] | |
with: | |
host: ${{ secrets.DEPLOY_SERVER_HOST }} | |
port: ${{ secrets.DEPLOY_SERVER_PORT }} | |
username: ${{ secrets.DEPLOY_SERVER_USER }} | |
privateKey: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }} | |
localPath: "dist/php-${{ env.PHPVER }}-micro-win.zip" | |
remotePath: ${{ secrets.DEPLOY_SERVER_TARGET_WINDOWS_SPC_MIN }}/ | |
- name: "Upload Artifact" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: php-${{ matrix.php-version }}-windows | |
path: | | |
buildroot/bin/php.exe | |
buildroot/bin/micro.sfx | |
if-no-files-found: error | |