Build and Publish PHP Extension #14
Workflow file for this run
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: Build and Publish PHP Extension | |
on: | |
release: | |
types: [created] | |
permissions: | |
contents: write | |
jobs: | |
build-and-upload: | |
name: Build and upload | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# Linux x64 - PHP8.0 | |
- build: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
php-versions: '8.0' | |
# Macos x64 - PHP8.0 | |
- build: x86_64-apple-darwin | |
os: macos-latest | |
target: x86_64-apple-darwin | |
php-versions: '8.0' | |
- build: aarch64-apple-darwin | |
os: macos-latest | |
target: aarch64-apple-darwin | |
php-versions: '8.0' | |
# Windows x64 - PHP8.0 | |
- build: x86_64-pc-windows-msvc | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
php-versions: '8.0' | |
# Linux x64 - PHP8.1 | |
- build: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
php-versions: '8.1' | |
# Macos x64 - PHP8.1 | |
- build: x86_64-apple-darwin | |
os: macos-latest | |
target: x86_64-apple-darwin | |
php-versions: '8.1' | |
- build: aarch64-apple-darwin | |
os: macos-latest | |
target: aarch64-apple-darwin | |
php-versions: '8.1' | |
# Windows x64 - PHP8.1 | |
- build: x86_64-pc-windows-msvc | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
php-versions: '8.1' | |
# Linux x64 - PHP8.2 | |
- build: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
php-versions: '8.2' | |
# Macos x64 - PHP8.2 | |
- build: x86_64-apple-darwin | |
os: macos-latest | |
target: x86_64-apple-darwin | |
php-versions: '8.2' | |
- build: aarch64-apple-darwin | |
os: macos-latest | |
target: aarch64-apple-darwin | |
php-versions: '8.2' | |
# Windows x64 - PHP8.2 | |
- build: x86_64-pc-windows-msvc | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
php-versions: '8.2' | |
# Linux x64 - PHP8.3 | |
- build: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
php-versions: '8.3' | |
# Macos x64 - PHP8.3 | |
- build: x86_64-apple-darwin | |
os: macos-latest | |
target: x86_64-apple-darwin | |
php-versions: '8.3' | |
- build: aarch64-apple-darwin | |
os: macos-latest | |
target: aarch64-apple-darwin | |
php-versions: '8.3' | |
# Windows x64 - PHP8.3 | |
- build: x86_64-pc-windows-msvc | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
php-versions: '8.3' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get the release version from the tag | |
shell: bash | |
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Install Rust (MacOS and Linux) | |
if: matrix.os != 'windows-latest' | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
targets: ${{ matrix.target }} | |
- name: Install Rust (Windows) | |
if: matrix.os == 'windows-latest' | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
- name: Build (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: true | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Build (MacOS and Windows) | |
if: matrix.os != 'ubuntu-latest' | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: Build archive | |
shell: bash | |
run: | | |
# Replace with the name of your binary | |
binary_name="libsql_php" | |
str_version=${{ env.VERSION }} | |
version=${str_version#turso-php-extension/} | |
dirname="$binary_name-$version-php-${{ matrix.php-versions }}-${{ matrix.target }}" | |
mkdir "$dirname" | |
if [ "${{ matrix.os }}" = "macos-latest" ]; then | |
cp "target/${{ matrix.target }}/release/lib${binary_name}.dylib" "target/${{ matrix.target }}/release/lib${binary_name}.so" | |
mv "target/${{ matrix.target }}/release/lib${binary_name}.dylib" "$dirname" | |
mv "target/${{ matrix.target }}/release/lib${binary_name}.so" "$dirname" | |
mv "libsql_php_extension.stubs.php" "$dirname" | |
elif [ "${{ matrix.os }}" = "windows-latest" ]; then | |
mv "target/${{ matrix.target }}/release/${binary_name}.dll" "$dirname" | |
mv "libsql_php_extension.stubs.php" "$dirname" | |
ls "target/${{ matrix.target }}/release" | |
else | |
mv "target/${{ matrix.target }}/release/lib${binary_name}.so" "$dirname" | |
mv "libsql_php_extension.stubs.php" "$dirname" | |
fi | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
7z a "$dirname.zip" "$dirname" | |
echo "ASSET=$dirname.zip" >> $GITHUB_ENV | |
else | |
tar -czf "$dirname.tar.gz" "$dirname" | |
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV | |
fi | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.ASSET }} |