mirror of https://github.com/leafspark/AutoGGUF
136 lines
5.6 KiB
YAML
136 lines
5.6 KiB
YAML
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]
|
|
runs-on: ${{ matrix.os }}
|
|
outputs:
|
|
artifact-names: ${{ steps.set-outputs.outputs.artifact-names }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
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"
|
|
Copy-Item -Path "src\gguf\*" -Destination "$distPath\src\gguf" -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"
|
|
Copy-Item -Path ".env.example" -Destination "$distPath\"
|
|
|
|
- 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
|
|
cp -R src/gguf/* $distPath/src/gguf/
|
|
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/
|
|
cp .env.example $distPath/
|
|
|
|
- name: Set outputs for artifact name
|
|
id: set-outputs
|
|
run: echo "artifact-name=AutoGGUF-${{ matrix.os }}-${{ matrix.arch }}-${{ github.event.inputs.build_type }}-${{ github.sha }}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
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
|
|
|
|
generate-checksums:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: ./artifacts
|
|
|
|
- name: Generate SHA256 checksums for all artifacts
|
|
run: |
|
|
cd artifacts
|
|
versionHash=$(echo ${{ github.sha }} | cut -c1-7)
|
|
echo "# AutoGGUF Build Checksums" > ../checksums.txt
|
|
echo "Build: ${{ github.event.inputs.build_type }}" >> ../checksums.txt
|
|
echo "Commit: ${{ github.sha }}" >> ../checksums.txt
|
|
echo "Date: $(date -u)" >> ../checksums.txt
|
|
echo "" >> ../checksums.txt
|
|
|
|
# Find all artifact directories and generate checksums of their zip equivalents
|
|
for artifact_dir in AutoGGUF-*-${{ github.event.inputs.build_type }}-${{ github.sha }}; do
|
|
if [ -d "$artifact_dir" ]; then
|
|
echo "Processing $artifact_dir..."
|
|
cd "$artifact_dir"
|
|
|
|
# Create a temporary zip to calculate hash (simulating what GitHub creates)
|
|
zip -r "../temp_${artifact_dir}.zip" .
|
|
cd ..
|
|
|
|
# Generate SHA256 of the zip file
|
|
hash=$(sha256sum "temp_${artifact_dir}.zip" | cut -d' ' -f1)
|
|
echo "${hash} ${artifact_dir}.zip" >> ../checksums.txt
|
|
|
|
# Clean up the temporary zip
|
|
rm "temp_${artifact_dir}.zip"
|
|
fi
|
|
done
|
|
|
|
- name: Upload checksums
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: AutoGGUF-${{ github.sha }}-SHA256
|
|
path: checksums.txt
|