Build AutoGGUF (PyInstaller) #29
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 AutoGGUF (PyInstaller) | |
on: | |
workflow_dispatch: | |
inputs: | |
build_type: | |
description: 'Build type (RELEASE or DEV)' | |
required: true | |
default: 'RELEASE' | |
type: choice | |
options: | |
- RELEASE | |
- DEV | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
arch: [x64] | |
include: | |
- os: windows-latest | |
arch: x86 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
architecture: ${{ matrix.arch }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install $(grep -v "^torch" requirements.txt) | |
pip install pyinstaller pillow | |
- name: Build with PyInstaller (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
$archSuffix = if ("${{ matrix.arch }}" -eq "x86") { "-x86" } else { "-x64" } | |
if ("${{ github.event.inputs.build_type }}" -eq "RELEASE") { | |
pyinstaller --windowed --onefile --name=AutoGGUF$archSuffix --icon=../../assets/favicon_large.png --add-data "../../assets;assets" --distpath=build\release\dist --workpath=build\release\build --specpath=build\release src\main.py | |
} else { | |
pyinstaller --onefile --name=AutoGGUF$archSuffix --icon=../../assets/favicon_large.png --add-data "../../assets;assets" --distpath=build\dev\dist --workpath=build\dev\build --specpath=build\dev src\main.py | |
} | |
- name: Build with PyInstaller (Linux/macOS) | |
if: matrix.os != 'windows-latest' | |
run: | | |
if [ "${{ github.event.inputs.build_type }}" = "RELEASE" ]; then | |
pyinstaller --windowed --onefile --name=AutoGGUF-x64 --icon=../../assets/favicon_large.png --add-data "../../assets:assets" --distpath=build/release/dist --workpath=build/release/build --specpath=build/release src/main.py | |
else | |
pyinstaller --onefile --name=AutoGGUF-x64 --icon=../../assets/favicon_large.png --add-data "../../assets:assets" --distpath=build/dev/dist --workpath=build/dev/build --specpath=build/dev src/main.py | |
fi | |
- name: Copy additional files (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
$distPath = if ("${{ github.event.inputs.build_type }}" -eq "RELEASE") { "build\release\dist" } else { "build\dev\dist" } | |
New-Item -ItemType Directory -Force -Path "$distPath\src\gguf-py" | |
Copy-Item -Path "src\gguf-py\*" -Destination "$distPath\src\gguf-py" -Recurse | |
Copy-Item -Path "src\convert_hf_to_gguf.py" -Destination "$distPath\src" | |
Copy-Item -Path "src\convert_lora_to_gguf.py" -Destination "$distPath\src" | |
Copy-Item -Path "src\convert_lora_to_ggml.py" -Destination "$distPath\src" | |
Copy-Item -Path "src\quantize_to_fp8_dynamic.py" -Destination "$distPath\src" | |
- name: Copy additional files (Linux/macOS) | |
if: matrix.os != 'windows-latest' | |
run: | | |
distPath=$(if [ "${{ github.event.inputs.build_type }}" = "RELEASE" ]; then echo "build/release/dist"; else echo "build/dev/dist"; fi) | |
mkdir -p $distPath/src/gguf-py | |
cp -R src/gguf-py/* $distPath/src/gguf-py/ | |
cp src/convert_hf_to_gguf.py $distPath/src/ | |
cp src/convert_lora_to_gguf.py $distPath/src/ | |
cp src/convert_lora_to_ggml.py $distPath/src/ | |
cp src/quantize_to_fp8_dynamic.py $distPath/src/ | |
- name: Generate SHA256 (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
$distPath = if ("${{ github.event.inputs.build_type }}" -eq "RELEASE") { "build\release\dist" } else { "build\dev\dist" } | |
$archSuffix = if ("${{ matrix.arch }}" -eq "x86") { "-x86" } else { "-x64" } | |
$exeName = "AutoGGUF$archSuffix.exe" | |
$versionHash = "${{ github.sha }}".Substring(0, 7) | |
$hashFile = "AutoGGUF-${{ matrix.os }}-${{ matrix.arch }}-$versionHash.sha256" | |
$hash = (Get-FileHash "$distPath\$exeName" -Algorithm SHA256).Hash.ToLower() | |
"$hash *$exeName" | Out-File -FilePath "$distPath\$hashFile" -Encoding utf8 | |
- name: Generate SHA256 (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
distPath=$(if [ "${{ github.event.inputs.build_type }}" = "RELEASE" ]; then echo "build/release/dist"; else echo "build/dev/dist"; fi) | |
exeName="AutoGGUF-x64" | |
versionHash=$(echo ${{ github.sha }} | cut -c1-7) | |
hashFile="AutoGGUF-${{ matrix.os }}-x64-$versionHash.sha256" | |
cd $distPath && sha256sum $exeName > $hashFile | |
- name: Generate SHA256 (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
distPath=$(if [ "${{ github.event.inputs.build_type }}" = "RELEASE" ]; then echo "build/release/dist"; else echo "build/dev/dist"; fi) | |
exeName="AutoGGUF-x64" | |
versionHash=$(echo ${{ github.sha }} | cut -c1-7) | |
hashFile="AutoGGUF-${{ matrix.os }}-x64-$versionHash.sha256" | |
cd $distPath && shasum -a 256 $exeName > $hashFile | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: AutoGGUF-${{ matrix.os }}-${{ matrix.arch }}-${{ github.event.inputs.build_type }}-${{ github.sha }} | |
path: | | |
build/${{ github.event.inputs.build_type == 'RELEASE' && 'release' || 'dev' }}/dist | |
!build/${{ github.event.inputs.build_type == 'RELEASE' && 'release' || 'dev' }}/dist/AutoGGUF-*.sha256 | |
- name: Upload SHA256 | |
uses: actions/upload-artifact@v2 | |
with: | |
name: AutoGGUF-${{ github.sha }}-SHA256 | |
path: build/${{ github.event.inputs.build_type == 'RELEASE' && 'release' || 'dev' }}/dist/AutoGGUF-*.sha256 |