update #62
This file contains hidden or 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 | |
on: [push] | |
permissions: | |
contents: write | |
env: | |
EXTENSION_NAME: php_rocksdb_rc | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php-version: [ '8.1' ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.php-version }} | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: php-config | |
- name: Install latest Rust toolchain | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup default stable | |
- name: Run Tests | |
run: | | |
cargo test | |
linux: | |
runs-on: ubuntu-latest | |
needs: tests | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
strategy: | |
matrix: | |
include: | |
- | |
target: x86_64-unknown-linux-gnu | |
platform: linux/amd64 | |
php-version: '8.0' | |
- | |
os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
platform: linux/arm64 | |
php-version: '8.0' | |
- | |
target: x86_64-unknown-linux-gnu | |
platform: linux/amd64 | |
php-version: '8.1' | |
- | |
os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
platform: linux/arm64 | |
php-version: '8.1' | |
- | |
target: x86_64-unknown-linux-gnu | |
platform: linux/amd64 | |
php-version: '8.2' | |
- | |
os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
platform: linux/arm64 | |
php-version: '8.2' | |
- | |
target: x86_64-unknown-linux-gnu | |
platform: linux/amd64 | |
php-version: '8.3' | |
- | |
os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
platform: linux/arm64 | |
php-version: '8.3' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.php-version }}-${{ matrix.target }} | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: network=host | |
- name: Setup docker | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
push: true | |
tags: localhost:5000/php-build:latest | |
build-args: | | |
FROM_PHP=${{ matrix.php-version }} | |
- name: Build | |
run: | | |
docker run -v ~/.cargo/registry:/root/.cargo/registry -v ~/.cargo/git:/root/.cargo/git --platform ${{ matrix.platform }} --rm -v $PWD:/code localhost:5000/php-build:latest bash -c 'rustup target add ${{ matrix.target }} ; cargo build --release --target ${{ matrix.target }}' | |
- name: Rename file | |
run: cp target/${{ matrix.target }}/release/lib${{ env.EXTENSION_NAME }}.so php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.so | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: php${{ matrix.php-version }}-${{ matrix.target }} | |
path: php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.so | |
- name: Get Cargo Version | |
id: cargo_version | |
run: | | |
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)".*/\1/') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Release Asset | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
files: | | |
php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.so | |
macos: | |
runs-on: macos-13 | |
needs: tests | |
strategy: | |
matrix: | |
include: | |
- | |
target: x86_64-apple-darwin | |
php-version: '8.0' | |
- | |
target: x86_64-apple-darwin | |
php-version: '8.1' | |
- | |
target: x86_64-apple-darwin | |
php-version: '8.2' | |
- | |
target: x86_64-apple-darwin | |
php-version: '8.3' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.php-version }}-${{ matrix.target }} | |
- name: Install latest Rust toolchain | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup default stable | |
rustup target add ${{ matrix.target }} | |
- name: Setup PHP with PECL extension | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: php-config | |
- name: Build | |
run: | | |
cargo build --release --target ${{ matrix.target }} --lib | |
- name: Rename file | |
run: mv target/${{ matrix.target }}/release/lib${{ env.EXTENSION_NAME }}.dylib target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dylib | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: php${{ matrix.php-version }}-${{ matrix.target }} | |
path: target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dylib | |
- name: Get Cargo Version | |
id: cargo_version | |
run: | | |
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)".*/\1/') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Release Asset | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
files: | | |
target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dylib | |
macos-arm: | |
runs-on: macos-latest | |
needs: tests | |
strategy: | |
matrix: | |
include: | |
- | |
target: aarch64-apple-darwin | |
php-version: '8.0' | |
- | |
target: aarch64-apple-darwin | |
php-version: '8.1' | |
- | |
target: aarch64-apple-darwin | |
php-version: '8.2' | |
- | |
target: aarch64-apple-darwin | |
php-version: '8.3' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.php-version }}-${{ matrix.target }} | |
- name: Install latest Rust toolchain | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup default stable | |
rustup target add ${{ matrix.target }} | |
- name: Setup PHP with PECL extension | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: php-config | |
- name: Build | |
run: | | |
cargo build --release --target ${{ matrix.target }} --lib | |
- name: Rename file | |
run: mv target/${{ matrix.target }}/release/lib${{ env.EXTENSION_NAME }}.dylib target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dylib | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: php${{ matrix.php-version }}-${{ matrix.target }} | |
path: target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dylib | |
- name: Get Cargo Version | |
id: cargo_version | |
run: | | |
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)".*/\1/') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Release Asset | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
files: | | |
target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dylib | |
windows: | |
runs-on: windows-latest | |
needs: tests | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-pc-windows-msvc | |
php-version: '8.0' | |
- target: x86_64-pc-windows-msvc | |
php-version: '8.1' | |
- target: x86_64-pc-windows-msvc | |
php-version: '8.2' | |
- target: x86_64-pc-windows-msvc | |
php-version: '8.3' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.php-version }}-${{ matrix.target }} | |
- name: Install latest Rust toolchain | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
echo "C:\Users\runneradmin\.cargo\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 | |
rustup default nightly | |
rustup target add ${{ matrix.target }} | |
- name: Setup PHP with PECL extension | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: php-config | |
- name: Build | |
run: | | |
cargo build --release --target ${{ matrix.target }} --lib | |
- name: Rename file | |
run: mv target/${{ matrix.target }}/release/${{ env.EXTENSION_NAME }}.dll target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dll | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: php${{ matrix.php-version }}-${{ matrix.target }} | |
path: target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dll | |
- name: Get Cargo Version | |
id: cargo_version | |
run: | | |
$content = Get-Content -Path .\Cargo.toml | |
$versionLine = $content | Select-String -Pattern '^version =' | Select-Object -First 1 | |
$version = $versionLine -replace 'version = "', '' -replace '"', '' | |
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append | |
shell: pwsh | |
- name: Create GitHub Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Release Asset | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
files: | | |
target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.dll |