PHP (Windows) #1
This file contains 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: PHP (Windows) | |
on: | |
workflow_call: | |
workflow_dispatch: | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PHP_EXTENSIONS: bz2,ctype,curl,dom,filter,gd,iconv,mbstring,opcache,openssl,pdo,pdo_sqlite,phar,session,simplexml,sqlite3,tokenizer,xml,xmlwriter,yaml,zip,zlib | |
PHP_LIBRARIES: libjpeg,libavif,freetype,libwebp | |
PHP_VERSION: 8.3 | |
jobs: | |
build: | |
name: Build PHP | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# @todo Use 2.4.5 when it is tagged. | |
repository: crazywhalecc/static-php-cli | |
ref: main | |
- name: Generate cache key | |
shell: bash | |
run: | | |
CACHE_KEY=${{ runner.os }}-$PHP_VERSION-$(echo $PHP_EXTENSIONS | tr ',' '-') | |
echo "CACHE_KEY=${CACHE_KEY}" >> "$GITHUB_ENV" | |
# Cache the built binaries so we can skip the build steps if there is a cache hit. | |
- id: cache | |
name: Cache binaries | |
uses: actions/cache@v4 | |
with: | |
path: buildroot/bin | |
key: php-${{ env.CACHE_KEY }} | |
- if: steps.cache.outputs.cache-hit != 'true' | |
name: Install Composer dependencies | |
run: composer install --no-dev | |
- if: steps.cache.outputs.cache-hit != 'true' | |
run: ./bin/spc doctor | |
# Fetch the source code for PHP's dependencies if they aren't already cached. | |
- if: steps.cache.outputs.cache-hit != 'true' | |
name: Download PHP source code | |
run: ./bin/spc download --with-php="${{ env.PHP_VERSION }}" --for-extensions="${{ env.PHP_EXTENSIONS }}" --prefer-pre-built | |
# Build the Drupal-ready PHP interpreter. | |
- if: steps.cache.outputs.cache-hit != 'true' | |
name: Build PHP interpreter | |
run: ./bin/spc build "${{ env.PHP_EXTENSIONS }}" --build-cli --with-libs="${{ env.PHP_LIBRARIES }}" --debug | |
# Upload the built interpreters. | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: php-windows | |
path: buildroot/bin | |
overwrite: true |