Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new GH action to build binary SPC #184

Merged
merged 3 commits into from
Sep 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build Release Artifacts

on:
release:
types:
- published
workflow_dispatch:

jobs:
build-release-artifacts:
name: "Build Release Artifacts"
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
operating-system:
- "ubuntu-latest"
- "macos-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: none
tools: composer:v2
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1

- name: "Get Composer Cache Directory"
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: "Cache Composer dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.composer-cache.outputs.dir }}"
key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}"
crazywhalecc marked this conversation as resolved.
Show resolved Hide resolved
restore-keys: |
php-${{ matrix.php-version }}-locked-composer-
- name: "Install locked dependencies"
run: "composer install --no-interaction --no-progress"
crazywhalecc marked this conversation as resolved.
Show resolved Hide resolved

# Cache downloaded source
- id: cache-download
uses: actions/cache@v3
with:
path: downloads
key: php-${{ matrix.php-version }}-dependencies

# If there's no dependencies cache, fetch sources
- if: steps.cache-download.outputs.cache-hit != 'true'
crazywhalecc marked this conversation as resolved.
Show resolved Hide resolved
name: "Download sources"
run: bin/spc download --with-php=${{ matrix.php-version }} --all

- name: "Build phpmicro"
run: |
SPC_USE_SUDO=yes bin/spc doctor --auto-fix
bin/spc build pcntl,posix,mbstring,tokenizer,phar --build-micro --debug
crazywhalecc marked this conversation as resolved.
Show resolved Hide resolved

- name: "Build PHAR file"
run: "composer build:phar"

- name: "Generate Executable"
run: "bin/spc micro:combine spc.phar -O spc"

- name: "Archive Executable"
run: |
OS=""
if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then
OS="linux-x86_64"
elif [ "${{ matrix.operating-system }}" = "macos-latest" ]; then
OS="macos-x86_64"
fi
tar -czf spc-$OS.tar.gz spc
echo "filename=spc-$OS.tar.gz" >> $GITHUB_ENV
echo "OS=$OS" >> $GITHUB_ENV

- name: "Test Micro file"
run: "./spc dev:extensions"

- name: upload binaries to release
uses: softprops/action-gh-release@v1
if: ${{startsWith(github.ref, 'refs/tags/') }}
with:
files: ${{ env.filename }}

- name: "Upload Artifact"
uses: actions/upload-artifact@v3
with:
path: spc
name: spc-${{ env.OS }}