Skip to content

turso-php-extension-v1.6.2 #27

turso-php-extension-v1.6.2

turso-php-extension-v1.6.2 #27

Workflow file for this run

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.1 - NTS
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.1'
phpts: 'nts'
# Linux x64 - PHP8.2 - NTS
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.2'
phpts: 'nts'
# Linux x64 - PHP8.3 - NTS
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.3'
phpts: 'nts'
# Linux x64 - PHP8.4 - NTS
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.4'
phpts: 'nts'
# Linux x64 - PHP8.1 - TS
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.1'
phpts: 'ts'
# Linux x64 - PHP8.2 - TS
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.2'
phpts: 'ts'
# Linux x64 - PHP8.3 - TS
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.3'
phpts: 'ts'
# Linux x64 - PHP8.4 - TS
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.4'
phpts: 'ts'
# -------------------------- Start BETA MacOS 14 --------------------------
# Macos x64 - PHP8.1 - NTS
- build: x86_64-apple-darwin-macos-14
os: macos-latest-large
target: x86_64-apple-darwin
php-versions: '8.1'
phpts: 'nts'
- build: aarch64-apple-darwin-macos-14
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.1'
phpts: 'nts'
# Macos x64 - PHP8.1 - TS
- build: x86_64-apple-darwin-macos-14
os: macos-latest-large
target: x86_64-apple-darwin
php-versions: '8.1'
phpts: 'ts'
- build: aarch64-apple-darwin-macos-14
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.1'
phpts: 'ts'
# Macos x64 - PHP8.2 - NTS
- build: x86_64-apple-darwin-macos-14
os: macos-latest-large
target: x86_64-apple-darwin
php-versions: '8.2'
phpts: 'nts'
- build: aarch64-apple-darwin-macos-14
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.2'
phpts: 'nts'
# Macos x64 - PHP8.2 - TS
- build: x86_64-apple-darwin-macos-14
os: macos-latest-large
target: x86_64-apple-darwin
php-versions: '8.2'
phpts: 'ts'
- build: aarch64-apple-darwin-macos-14
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.2'
phpts: 'ts'
# Macos x64 - PHP8.3 - NTS
- build: x86_64-apple-darwin-macos-14
os: macos-latest-large
target: x86_64-apple-darwin
php-versions: '8.3'
phpts: 'nts'
- build: aarch64-apple-darwin-macos-14
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.3'
phpts: 'nts'
# Macos x64 - PHP8.3 - TS
- build: x86_64-apple-darwin-macos-14
os: macos-latest-large
target: x86_64-apple-darwin
php-versions: '8.3'
phpts: 'ts'
- build: aarch64-apple-darwin-macos-14
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.3'
phpts: 'ts'
# Macos x64 - PHP8.4 - NTS
- build: x86_64-apple-darwin-macos-14
os: macos-latest-large
target: x86_64-apple-darwin
php-versions: '8.4'
phpts: 'nts'
- build: aarch64-apple-darwin-macos-14
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.4'
phpts: 'nts'
# Macos x64 - PHP8.4 - TS
- build: x86_64-apple-darwin-macos-14
os: macos-latest-large
target: x86_64-apple-darwin
php-versions: '8.4'
phpts: 'ts'
- build: aarch64-apple-darwin-macos-14
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.4'
phpts: 'ts'
# -------------------------- End BETA MacOS 14 --------------------------
# -------------------------- Start BETA MacOS 15 --------------------------
# Macos x64 - PHP8.1 - NTS
- build: x86_64-apple-darwin-macos-15-beta
os: macos-15-large
target: x86_64-apple-darwin
php-versions: '8.1'
phpts: 'nts'
- build: aarch64-apple-darwin-macos-15-beta
os: macos-15
target: aarch64-apple-darwin
php-versions: '8.1'
phpts: 'nts'
# Macos x64 - PHP8.1 - TS
- build: x86_64-apple-darwin-macos-15-beta
os: macos-15-large
target: x86_64-apple-darwin
php-versions: '8.1'
phpts: 'ts'
- build: aarch64-apple-darwin-macos-15-beta
os: macos-15
target: aarch64-apple-darwin
php-versions: '8.1'
phpts: 'ts'
# Macos x64 - PHP8.2 - NTS
- build: x86_64-apple-darwin-macos-15-beta
os: macos-15-large
target: x86_64-apple-darwin
php-versions: '8.2'
phpts: 'nts'
- build: aarch64-apple-darwin-macos-15-beta
os: macos-15
target: aarch64-apple-darwin
php-versions: '8.2'
phpts: 'nts'
# Macos x64 - PHP8.2 - TS
- build: x86_64-apple-darwin-macos-15-beta
os: macos-15-large
target: x86_64-apple-darwin
php-versions: '8.2'
phpts: 'ts'
- build: aarch64-apple-darwin-macos-15-beta
os: macos-15
target: aarch64-apple-darwin
php-versions: '8.2'
phpts: 'ts'
# Macos x64 - PHP8.3 - NTS
- build: x86_64-apple-darwin-macos-15-beta
os: macos-15-large
target: x86_64-apple-darwin
php-versions: '8.3'
phpts: 'nts'
- build: aarch64-apple-darwin-macos-15-beta
os: macos-15
target: aarch64-apple-darwin
php-versions: '8.3'
phpts: 'nts'
# Macos x64 - PHP8.3 - TS
- build: x86_64-apple-darwin-macos-15-beta
os: macos-15-large
target: x86_64-apple-darwin
php-versions: '8.3'
phpts: 'ts'
- build: aarch64-apple-darwin-macos-15-beta
os: macos-15
target: aarch64-apple-darwin
php-versions: '8.3'
phpts: 'ts'
# Macos x64 - PHP8.4 - NTS
- build: x86_64-apple-darwin-macos-15-beta
os: macos-15-large
target: x86_64-apple-darwin
php-versions: '8.4'
phpts: 'nts'
- build: aarch64-apple-darwin-macos-15-beta
os: macos-15
target: aarch64-apple-darwin
php-versions: '8.4'
phpts: 'nts'
# Macos x64 - PHP8.4 - TS
- build: x86_64-apple-darwin-macos-15-beta
os: macos-15-large
target: x86_64-apple-darwin
php-versions: '8.4'
phpts: 'ts'
- build: aarch64-apple-darwin-macos-15-beta
os: macos-15
target: aarch64-apple-darwin
php-versions: '8.4'
phpts: 'ts'
# -------------------------- End BETA MacOS 15 --------------------------
# Windows x64 - PHP8.1 - NTS
- build: x86_64-pc-windows-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
php-versions: '8.1'
phpts: 'nts'
# Windows x64 - PHP8.2 - NTS
- build: x86_64-pc-windows-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
php-versions: '8.2'
phpts: 'nts'
# Windows x64 - PHP8.3 - NTS
- build: x86_64-pc-windows-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
php-versions: '8.3'
phpts: 'nts'
# Windows x64 - PHP8.4 - NTS
- build: x86_64-pc-windows-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
php-versions: '8.4'
phpts: 'nts'
# Windows x64 - PHP8.1 - TS
- build: x86_64-pc-windows-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
php-versions: '8.1'
phpts: 'ts'
# Windows x64 - PHP8.2 - TS
- build: x86_64-pc-windows-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
php-versions: '8.2'
phpts: 'ts'
# Windows x64 - PHP8.3 - TS
- build: x86_64-pc-windows-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
php-versions: '8.3'
phpts: 'ts'
# Windows x64 - PHP8.4 - TS
- build: x86_64-pc-windows-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
php-versions: '8.4'
phpts: 'ts'
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-2019'
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: Install Rust (Windows)
if: matrix.os == 'windows-2019'
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
env:
phpts: ${{ matrix.phpts }}
- name: Build Extension
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.phpts }}-${{ matrix.build }}"
mkdir -p "$dirname"
# Check if we are on macOS
if [[ "${{ matrix.os }}" == *"macos"* ]]; then
if [[ -f "target/${{ matrix.target }}/release/lib${binary_name}.dylib" ]]; 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"
else
echo "Error: lib${binary_name}.dylib not found in target/${{ matrix.target }}/release/"
exit 1
fi
elif [[ "${{ matrix.os }}" == "windows-2019" ]]; then
if [[ -f "target/${{ matrix.target }}/release/${binary_name}.dll" ]]; then
mv "target/${{ matrix.target }}/release/${binary_name}.dll" "$dirname"
else
echo "Error: ${binary_name}.dll not found in target/${{ matrix.target }}/release/"
exit 1
fi
else
if [[ -f "target/${{ matrix.target }}/release/lib${binary_name}.so" ]]; then
mv "target/${{ matrix.target }}/release/lib${binary_name}.so" "$dirname"
else
echo "Error: lib${binary_name}.so not found in target/${{ matrix.target }}/release/"
exit 1
fi
fi
# Move stubs file if it exists
if [[ -f "libsql_php_extension.stubs.php" ]]; then
mv "libsql_php_extension.stubs.php" "$dirname"
else
echo "Warning: libsql_php_extension.stubs.php not found."
fi
# Archive the build
if [[ "${{ matrix.os }}" == "windows-2019" ]]; 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 }}