Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Make the PHP package lighter by "export-ignore" what's not necessary
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/docs export-ignore
/tests export-ignore
/include export-ignore
/rust export-ignore
/CHANGELOG.md export-ignore
/CONTRIBUTING.md export-ignore
88 changes: 88 additions & 0 deletions .github/workflows/build-libs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build Libraries

on:
push:
tags:
- 'v*'



jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
lib_src: rust/target/release/libtakumi_php.so
lib_dst: lib/libtakumi_php.so
artifact: libtakumi_php-linux
- os: macos-latest
lib_src: rust/target/release/libtakumi_php.dylib
lib_dst: lib/libtakumi_php.dylib
artifact: libtakumi_php-macos
- os: windows-latest
lib_src: rust/target/release/takumi_php.dll
lib_dst: lib/takumi_php.dll
artifact: libtakumi_php-windows

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache Rust dependencies
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release

- name: Build Rust library (release)
working-directory: rust
run: cargo build --release

- name: Stage library
shell: bash
run: cp ${{ matrix.lib_src }} ${{ matrix.lib_dst }}

- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.lib_dst }}

commit-libs:
name: Commit libraries to repo
needs: build
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.ref_name }}

- name: Download all artifacts
uses: actions/download-artifact@v8
with:
merge-multiple: true

- name: Commit and push libraries
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add --force lib/
git diff --staged --quiet || git commit -m "chore: update prebuilt libraries for ${{ github.ref_name }}"
git tag -f ${{ github.ref_name }}
git push origin ${{ github.ref_name }} --force
Loading