Skip to content

Build

Build #46

Workflow file for this run

name: Build
on:
release:
types:
- created
workflow_dispatch:
permissions:
contents: write
jobs:
phar:
name: Build PHAR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
tools: box
- name: Install dependencies
uses: ramsey/composer-install@v3
- name: Build PHAR
run: box compile
- name: Ensure the PHAR works
run: build/automate.phar --version
- uses: actions/upload-artifact@v4
name: Upload the PHAR artifact
with:
name: automate-phar
path: build/automate.phar
static-binary:
name: Build static binary ${{ matrix.filename }}
needs: [ phar ]
strategy:
fail-fast: false
matrix:
include:
# Linux amd64
- runs_on: ubuntu-latest
spc_binary: https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
build_options: --build-micro --with-upx-pack
filename: automate-linux-amd64
# MacOS amd64
- runs_on: macos-latest
spc_binary: https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
build_options: --build-micro
filename: automate-darwin-amd64
# MacOS arm64
- runs_on: macos-14
spc_binary: https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
build_options: --build-micro
filename: automate-darwin-arm64
runs-on: ${{ matrix.runs_on }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: build
merge-multiple: true
- name: Install homebrew x86_64
if : matrix.runs_on == 'macos-latest'
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
- name: Get static-php-cli binary
run: |
curl ${{ matrix.spc_binary }} -o bin/spc
chmod +x bin/spc
- name: Fixing missing requirements
run: |
bin/spc doctor --auto-fix
- name: Install UPX package
if: ${{ contains(matrix.build_options, 'upx') }}
run: |
bin/spc install-pkg upx
- name: Build static binary
run: |
bin/spc download --for-extensions="dom,gmp,openssl,phar,sodium,xml,xmlwriter,filter,tokenizer,iconv,mbstring" --with-php=8.3
bin/spc build "dom,gmp,openssl,phar,sodium,xml,xmlwriter,filter,tokenizer,iconv,mbstring" ${{ matrix.build_options }}
bin/spc micro:combine build/automate.phar --output build/${{ matrix.filename }}
- name: Ensure the static binary works
run: build/${{ matrix.filename }} --version
- uses: actions/upload-artifact@v4
name: Upload the static binary artifact
with:
name: ${{ matrix.filename }}
path: build/${{ matrix.filename }}
release:
name: Upload artifacts to the release
if: github.event_name == 'release'
needs: [ static-binary ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: build
merge-multiple: true
- name: Upload files
run: |
gh release upload ${{ github.ref_name }} ./build/automate.phar
gh release upload ${{ github.ref_name }} ./build/automate-linux-amd64
gh release upload ${{ github.ref_name }} ./build/automate-darwin-amd64
gh release upload ${{ github.ref_name }} ./build/automate-darwin-arm64
env:
GH_TOKEN: ${{ github.token }}