Skip to content
Merged
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
166 changes: 166 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: Create Platform-Specific Artifacts

on:
release:
types: [ published, created, edited, prereleased ]

workflow_dispatch:
inputs:
release_tag:
description: 'Release tag to build artifacts for'
required: false
type: string

jobs:
prepare-artifacts:
runs-on: ubuntu-latest

outputs:
platforms: ${{ steps.generate-matrix.outputs.platforms }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_tag || github.ref }}

- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq

- name: Generate Build Matrix
id: generate-matrix
run: |
# Extract platforms from platforms.yml
platforms=$(yq -o=json 'keys' platforms.yml)
echo "platforms=$(echo $platforms | jq -c '. | map(split("/")[0]) | unique')" >> $GITHUB_OUTPUT

build-artifacts:
needs: prepare-artifacts

runs-on: ubuntu-latest

strategy:
matrix:
platform: ${{ fromJson(needs.prepare-artifacts.outputs.platforms) }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_tag || github.ref }}

- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq

- name: Create Platform-Specific Artifact
run: |
# Prepare exclusion list
if [ -f ".gitignore" ]; then
cp .gitignore rsync_exclude.txt
else
touch rsync_exclude.txt
fi

# Add platform-specific exclusions from platforms.yml
echo "" >> rsync_exclude.txt
yq e ".\"${{ matrix.platform }}\".exclude[]" platforms.yml >> rsync_exclude.txt

# Add standard exclusions
echo ".git" >> rsync_exclude.txt
echo ".github" >> rsync_exclude.txt
echo "rsync_exclude.txt" >> rsync_exclude.txt

# Copy files using rsync with exclusions
DIST_DIR="dist-${{ matrix.platform }}"
mkdir -p "$DIST_DIR"
echo "$DIST_DIR" >> rsync_exclude.txt
rsync -av --exclude-from=rsync_exclude.txt ./ "$DIST_DIR"/

# Compress artifact
if [[ "${{ matrix.platform }}" == windows-* ]]; then
zip -r "dist-${{ matrix.platform }}.zip" "$DIST_DIR"
ARTIFACT_EXT="zip"
else
tar -czvf "dist-${{ matrix.platform }}.tar.gz" "$DIST_DIR"
ARTIFACT_EXT="tar.gz"
fi

echo "Artifact created: dist-${{ matrix.platform }}.$ARTIFACT_EXT"

- name: Upload Artifact to Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist-*

- name: Upload Artifact to Artifact Hub
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.platform }}
path: dist-*
retention-days: 1

create-release-metadata:
needs: [ prepare-artifacts, build-artifacts ]

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_tag || github.ref }}

- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq

- name: Generate Platform URLs Metadata
run: |
# Prepare variables
RELEASE_TAG="${{ github.event.inputs.release_tag || github.ref }}"
REPO="${{ github.repository }}"

# Start JSON structure
echo "{" > platform-urls.json
echo ' "platform-urls": {' >> platform-urls.json

# Generate URLs for each platform
FIRST=true
platforms=$(yq -o=json 'keys' platforms.yml | jq -r '.[]')
for platform in $platforms; do
if [ "$FIRST" = true ]; then
FIRST=false
else
echo "," >> platform-urls.json
fi

# Determine file extension
if [[ "$platform" == windows-* ]]; then
EXT="zip"
else
EXT="tar.gz"
fi

# Generate URL
printf ' "%s": "https://github.com/%s/releases/download/%s/dist-%s.%s"' \
"$platform" "$REPO" "$RELEASE_TAG" "$platform" "$EXT" >> platform-urls.json
done

# Close JSON structure
echo "" >> platform-urls.json
echo ' }' >> platform-urls.json
echo "}" >> platform-urls.json

cat platform-urls.json

- name: Upload Platform URLs Metadata
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: platform-urls.json
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: [8.1, 8.2, 8.3, 8.4]
max-parallel: 4

name: Tests PHP${{ matrix.php }} - ${{ matrix.os }}

Expand Down
18 changes: 15 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "codewithkyrian/whisper.php",
"description": "PHP bindings for OpenAI Whisper made possible by whisper.cpp",
"type": "library",
"type": "platform-package",
"version": "1.0.0",
"require": {
"php": "^8.1",
"ext-ffi": "*",
"psr/log": "^3.0"
"psr/log": "^3.0",
"codewithkyrian/platform-package-installer": "^1.0"
},
"require-dev": {
"symfony/var-dumper": "^6.4.11|^7.1.5",
Expand Down Expand Up @@ -35,7 +36,18 @@
],
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
"pestphp/pest-plugin": true,
"codewithkyrian/platform-package-installer": true
}
},
"extra": {
"platform-urls": {
"linux-x86_64": "https://github.com/Codewithkyrian/whisper.php/releases/download/{version}/dist-linux-x86_64.tar.gz",
"linux-arm64": "https://github.com/Codewithkyrian/whisper.php/releases/download/{version}/dist-linux-arm64.tar.gz",
"darwin-x86_64": "https://github.com/Codewithkyrian/whisper.php/releases/download/{version}/dist-darwin-x86_64.tar.gz",
"darwin-arm64": "https://github.com/Codewithkyrian/whisper.php/releases/download/{version}/dist-darwin-arm64.tar.gz",
"windows-x86_64": "https://github.com/Codewithkyrian/whisper.php/releases/download/{version}/dist-windows-x86_64.zip",
"windows-arm64": "https://github.com/Codewithkyrian/whisper.php/releases/download/{version}/dist-windows-arm64.zip"
}
}
}
1 change: 0 additions & 1 deletion lib/.gitignore

This file was deleted.

Binary file added lib/darwin-arm64/libggml-base.dylib
Binary file not shown.
Binary file added lib/darwin-arm64/libggml-blas.dylib
Binary file not shown.
Binary file added lib/darwin-arm64/libggml-cpu.dylib
Binary file not shown.
Binary file added lib/darwin-arm64/libggml-metal.dylib
Binary file not shown.
Binary file added lib/darwin-arm64/libggml.dylib
Binary file not shown.
Binary file added lib/darwin-arm64/libsamplerate.dylib
Binary file not shown.
Binary file added lib/darwin-arm64/libsndfile.dylib
Binary file not shown.
Binary file added lib/darwin-arm64/libwhisper.dylib
Binary file not shown.
Binary file added lib/darwin-x86_64/libggml-base.dylib
Binary file not shown.
Binary file added lib/darwin-x86_64/libggml-blas.dylib
Binary file not shown.
Binary file added lib/darwin-x86_64/libggml-cpu.dylib
Binary file not shown.
Binary file added lib/darwin-x86_64/libggml-metal.dylib
Binary file not shown.
Binary file added lib/darwin-x86_64/libggml.dylib
Binary file not shown.
Binary file added lib/darwin-x86_64/libsamplerate.dylib
Binary file not shown.
Binary file added lib/darwin-x86_64/libsndfile.dylib
Binary file not shown.
Binary file added lib/darwin-x86_64/libwhisper.dylib
Binary file not shown.
Binary file added lib/linux-arm64/libggml.so
Binary file not shown.
Binary file added lib/linux-arm64/libsamplerate.so
Binary file not shown.
Binary file added lib/linux-arm64/libsndfile.so
Binary file not shown.
Binary file added lib/linux-arm64/libwhisper.so
Binary file not shown.
Binary file added lib/linux-x86_64/libggml.so
Binary file not shown.
Binary file added lib/linux-x86_64/libsamplerate.so
Binary file not shown.
Binary file added lib/linux-x86_64/libsndfile.so
Binary file not shown.
Binary file added lib/linux-x86_64/libwhisper.so
Binary file not shown.
Binary file added lib/windows-x86_64/ggml-whisper.dll
Binary file not shown.
Binary file added lib/windows-x86_64/libsamplerate.dll
Binary file not shown.
Binary file added lib/windows-x86_64/libsndfile.dll
Binary file not shown.
Binary file added lib/windows-x86_64/libwhisper.dll
Binary file not shown.
55 changes: 55 additions & 0 deletions platforms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
linux-x86_64:
exclude:
- libs/linux-arm64
- libs/darwin-*
- libs/windows-*
- "*.exe"
- "*.dylib"
- "**/*.windows.*"

linux-arm64:
exclude:
- libs/linux-x86_64
- libs/windows-*
- libs/darwin-*
- "*.exe"
- "*.dylib"
- "**/*.windows.*"

darwin-x86_64:
exclude:
- libs/darwin-arm64
- libs/windows-*
- libs/linux-*
- "*.exe"
- "*.so"
- "**/*.linux.*"

darwin-arm64:
exclude:
- libs/darwin-x86_64
- libs/windows-*
- libs/linux-*
- "*.exe"
- "*.so"
- "**/*.linux.*"

windows-x86_64:
exclude:
- libs/windows-arm64
- libs/linux-*
- libs/darwin-*
- "*.so"
- "*.dylib"
- "**/*.darwin.*"
- "**/*.linux.*"

windows-arm64:
exclude:
- libs/windows-x86_64
- libs/linux-*
- libs/darwin-*
- "*.so"
- "*.dylib"
- "**/*.darwin.*"
- "**/*.linux.*"
Loading
Loading