Static CLI build #18
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: Static CLI build | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
jobs: | |
build: | |
name: build ${{ matrix.php-versions }} on macOS x86_64 | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
php-versions: ['8.3'] | |
steps: | |
- uses: actions/checkout@v3 | |
# Install macOS missing packages and mark os suffix | |
- run: | | |
brew install automake gzip | |
- name: Install PHP | |
run: | | |
brew install php@${{ matrix.php-versions }} | |
echo "::add-path::$(brew --prefix php@${{ matrix.php-versions }})/bin" | |
- name: Install Composer | |
run: | | |
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_CHECKSUM="$(php -r 'echo hash_file("sha384", "composer-setup.php");')" | |
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then | |
>&2 echo 'ERROR: Invalid installer checksum' | |
rm composer-setup.php | |
exit 1 | |
fi | |
php composer-setup.php --install-dir=/usr/local/bin --filename=composer | |
rm composer-setup.php | |
- name: Paths | |
run: | | |
echo "ARTIFACT_NAME=php-${{ matrix.php-versions }}-glfw-cli-macos-x86_64" >> $GITHUB_ENV | |
echo "ARTIFACT_DIR=/tmp/php-${{ matrix.php-versions }}-glfw-cli-macos-x86_64" >> $GITHUB_ENV | |
echo "STATIC_CLI_DIR=/tmp/static-php-cli" >> $GITHUB_ENV | |
# Cache downloads | |
- id: cache-static-php-cli | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/static-php-cli | |
key: cache-static-php-cli | |
- name: Download static-php-cli | |
if: steps.cache-static-php-cli.outputs.cache-hit != 'true' | |
run: | | |
# Clone only the specific commit to save time and space | |
git clone --depth 1 --branch main https://github.com/crazywhalecc/static-php-cli.git /tmp/static-php-cli | |
cd /tmp/static-php-cli | |
# Install composer dependencies | |
composer install --no-dev --no-interaction --no-progress --no-suggest --no-scripts --prefer-dist --optimize-autoloader | |
- if: steps.cache-static-php-cli.outputs.cache-hit != 'true' | |
run: cd /tmp/static-php-cli && ./bin/spc download --with-php=${{ matrix.php-versions }} --all | |
- name: Copy the current workspace aka php-glfw version to the static-php-cli | |
run: | | |
cp -r . /tmp/static-php-cli/downloads/ext-glfw | |
# Run build command | |
- run: cd /tmp/static-php-cli && ./bin/spc build "curl,glfw,mbstring,zip" --build-cli --debug | |
# create a new directory where we store the copy of data | |
# we are interested in for the artifact | |
- name: Create artifact directory | |
run: | | |
mkdir -p $ARTIFACT_DIR | |
mkdir -p $ARTIFACT_DIR/bin | |
cp -r $STATIC_CLI_DIR/buildroot/bin/php $ARTIFACT_DIR/bin/php | |
cp -r $STATIC_CLI_DIR/buildroot/license $ARTIFACT_DIR/license | |
cp -r $STATIC_CLI_DIR/buildroot/build-extensions.json $ARTIFACT_DIR/build-extensions.json | |
cp -r $STATIC_CLI_DIR/buildroot/build-libraries.json $ARTIFACT_DIR/build-libraries.json | |
# Zip the artifact into the artifact dir | |
- name: Create a zip archive | |
run: | | |
cd $ARTIFACT_DIR | |
zip -r $ARTIFACT_NAME.zip . | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.zip | |