forked from leafspark/AutoGGUF
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (106 loc) · 5.46 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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 }}
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"
- 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/
- 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 = "-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@v3
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@v3
with:
name: AutoGGUF-${{ github.sha }}-SHA256
path: build/${{ github.event.inputs.build_type == 'RELEASE' && 'release' || 'dev' }}/dist/AutoGGUF-*.sha256