Skip to content

Release and Check build on multiple platforms #129

Release and Check build on multiple platforms

Release and Check build on multiple platforms #129

Workflow file for this run

name: Release and Check build on multiple platforms
on:
workflow_dispatch:
inputs:
push_docker:
description: 'Push Docker image to registry?'
required: true
default: false
type: boolean
push:
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
pull_request:
jobs:
prepare-conan-cache:
name: Prepare Conan cache for Windows
runs-on: windows-2019
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Cache Conan
id: cache-conan
uses: actions/cache@v4
with:
path: |
~/.conan2
build\generators
CMakeUserPresets.json
key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.txt') }}
restore-keys: ${{ runner.os }}-conan
- name: Install Conan
if: steps.cache-conan.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install conan
- name: Set up Conan
if: steps.cache-conan.outputs.cache-hit != 'true'
run: |
New-Item -ItemType Directory -Force -Path build
cd build
conan profile detect
conan install .. -s compiler.cppstd=17 --build=missing
build-windows:
name: Build on Windows
needs: [prepare-conan-cache]
runs-on: windows-2019
env:
VULKAN_VERSION: 1.3.261.1
strategy:
matrix:
variant:
- name: CPU avx
cmake_flags: "-DSDGUI_AVX=ON"
targets: "stable_diffusion_cpp_avx"
cache-key: windows-avx
- name: CPU avx2
cmake_flags: "-DSDGUI_AVX2=ON"
targets: "stable_diffusion_cpp_avx2"
cache-key: windows-avx2
- name: CPU avx512
cmake_flags: "-DSDGUI_AVX512=ON"
targets: "stable_diffusion_cpp_avx512"
cache-key: windows-avx512
- name: CUDA
cmake_flags: "-DSDGUI_CUDA=ON"
targets: "stable_diffusion_cpp_cuda"
cache-key: windows-cuda
- name: VULKAN
cmake_flags: "-DSDGUI_VULKAN=ON"
targets: "stable_diffusion_cpp_vulkan"
cache-key: windows-vulkan
# - name: HIPBLAS
# cmake_flags: "-DSDGUI_HIPBLAS=ON"
# targets: "stable_diffusion_cpp_hipblas"
# cache-key: windows-hipblas
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Cache build outputs
id: cache-build
uses: actions/cache@v4
with:
path: |
build/Release/*.dll
build/include
key: ${{ matrix.variant.cache-key }}-${{ hashFiles('cmake/sdcpp_version.cmake') }}-${{ hashFiles('cmake/llama_version.cmake') }}
restore-keys: ${{ matrix.variant.cache-key }}-
- name: Install CUDA Toolkit
if: ${{ matrix.variant.name == 'CUDA' && steps.cache-build.outputs.cache-hit != 'true' }}
id: cuda-toolkit
uses: Jimver/cuda-toolkit@v0.2.11
with:
cuda: "12.2.0"
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
method: "network"
- name: Print cuda version
if: ${{ matrix.variant.name == 'CUDA' && steps.cache-build.outputs.cache-hit != 'true' }}
run: |
echo "Installed cuda version is: ${{steps.cuda-toolkit.outputs.cuda}}"
- name: Install ROCm Toolkit
if: ${{ matrix.variant.name == 'HIPBLAS' && steps.cache-build.outputs.cache-hit != 'true' }}
uses: Cyberhan123/rocm-toolkit@v0.1.0
with:
rocm: "5.5.0"
- name: Install Ninja
if: ${{ matrix.variant.name == 'HIPBLAS' && steps.cache-build.outputs.cache-hit != 'true' }}
uses: urkle/action-get-ninja@v1
with:
version: 1.11.1
- name: Install Vulkan SDK
id: get_vulkan
if: ${{ matrix.variant.name == 'VULKAN' && steps.cache-build.outputs.cache-hit != 'true' }}
run: |
curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/VulkanSDK-${env:VULKAN_VERSION}-Installer.exe"
& "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
- name: Configure CMake
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSDGUI_WINDOWLESS=ON -DSDGUI_SERVER=OFF -DCUDA_TOOLKIT_ROOT_DIR="${{steps.cuda-toolkit.outputs.CUDA_PATH}}" ${{ matrix.variant.cmake_flags }}
- name: Build Targets
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
cmake --build build --config Release
- name: Upload Build Outputs
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.variant.cache-key }}
path: |
build/Release/*.dll
build/include
compression-level: 0
overwrite: true
package-installer:
name: Build main Application
runs-on: windows-2019
needs: [build-windows]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Restore builds
uses: actions/download-artifact@v4
with:
path: build
pattern: windows-*
merge-multiple: true
- name: Cache Conan
id: cache-conan
uses: actions/cache@v4
with:
path: |
~/.conan2
build\generators
CMakeUserPresets.json
key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.txt') }}
restore-keys: ${{ runner.os }}-conan
- name: Install Conan
run: |
python -m pip install --upgrade pip
pip install conan
- name: Set up Conan
run: |
cd build
conan profile detect
conan install .. -s compiler.cppstd=17 --build=never
- name: Compile main application
run: |
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release --preset conan-default -DSDGUI_WINDOWLESS=OFF -DSDGUI_SERVER=OFF
cmake --build . --config Release --target po-compile
cmake --build . --config Release
- name: Generate installer
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
run: |
cd build
cmake --build . --config Release --target package
- name: Upload Release Outputs
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@v4
with:
name: prebuild-packages-windows
path: |
build/*.exe
build/*.7z
build/*.sha256
compression-level: 0
overwrite: true
build-ubuntu:
name: Build on Ubuntu
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
# variant: [CPU, HIPBLAS, CUDA, VULKAN]
variant: [CPU, CUDA, VULKAN]
runs-on: ${{ matrix.os }}
steps:
- name: Set up build environment
run: |
echo "Running on OS: ${{ matrix.os }}, Variant: ${{ matrix.variant }}"
env:
DEBIAN_FRONTEND: noninteractive
- name: Check out code
uses: actions/checkout@v3
- name: Cache builds
uses: actions/cache@v4
id: sd-cpp-cache
with:
path: |
build/*.so
build/include
key: ${{ matrix.os }}-build-${{ matrix.variant }}-${{ hashFiles('cmake/sdcpp_version.cmake') }}-${{ hashFiles('cmake/llama_version.cmake') }}
restore-keys: ${{ matrix.os }}-build-${{ matrix.variant }}-
- name: Maximize build space
# if: ${{ (matrix.variant == 'HIPBLAS' || matrix.variant == 'CUDA' || matrix.variant == 'VULKAN' ) && steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
if: ${{ (matrix.variant == 'HIPBLAS' || matrix.variant == 'CUDA' || matrix.os == 'ubuntu-22.04' ) && steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
uses: AdityaGarg8/remove-unwanted-software@v4.1
with:
remove-android: 'true'
remove-dotnet: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
remove-large-packages: 'true'
remove-swapfile: 'true'
- name: Install base dependencies
if: ${{ steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
run: |
sudo apt update
sudo apt install -y --no-install-recommends fuse3 cmake gettext git build-essential ninja-build libexiv2-dev libssl-dev libjpeg-dev libpng-dev libtiff-dev libgtk-3-dev libcurl4-openssl-dev libsecret-1-dev libnotify-dev libwebkit2gtk-4.1-dev libsdl2-dev libomp-dev >/dev/null
- name: CACHE ROCM installer
if: ${{ matrix.variant == 'HIPBLAS' && steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
uses: actions/cache@v4
id: ubuntu-rocm-installer
with:
path: /tmp/amdgpu-install.deb
key: amdgpu-install-ubuntu-${{ matrix.os }}
- name: Download ROCM installer
if: ${{ matrix.variant == 'HIPBLAS' && steps.ubuntu-rocm-installer.outputs.cache-hit != 'true' && steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
run: |
sudo apt install -y wget >/dev/null
source /etc/lsb-release
wget https://repo.radeon.com/amdgpu-install/6.2.2/ubuntu/${DISTRIB_CODENAME}/amdgpu-install_6.2.60202-1_all.deb -O /tmp/amdgpu-install.deb
- name: Install ROCm toolkit
if: ${{ matrix.variant == 'HIPBLAS' && steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
run: |
sudo apt update >/dev/null
sudo apt install -y "linux-headers-$(uname -r)" "linux-modules-extra-$(uname -r)" >/dev/null
sudo dpkg -i /tmp/amdgpu-install.deb
sudo apt update >/dev/null
sudo apt install -y rocm-openmp-sdk rocm-cmake hip-dev rocm-hip-runtime-dev clang-tools lld hipblas-dev
sudo tee --append /etc/ld.so.conf.d/rocm.conf <<EOF
/opt/rocm/lib
/opt/rocm/lib64
EOF
sudo ldconfig
- name: Install Vulkan SDK
if: ${{ matrix.variant == 'VULKAN' && steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
run: |
source /etc/lsb-release
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
echo "deb https://packages.lunarg.com/vulkan ${DISTRIB_CODENAME} main" | sudo tee /etc/apt/sources.list.d/lunarg-vulkan-${DISTRIB_CODENAME}.list
sudo apt update
sudo apt install -y vulkan-sdk
- name: Install CUDA toolkit
if: ${{ matrix.variant == 'CUDA' && matrix.os == 'ubuntu-24.04' && steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
run: |
sudo apt update
sudo apt install -y nvidia-cuda-toolkit
- name: Install CUDA 11.7
if: ${{ matrix.variant == 'CUDA' && matrix.os == 'ubuntu-22.04' && steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
run: |
sudo apt update; sudo apt install -y wget software-properties-common
sudo wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
sudo add-apt-repository -y "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt-get install -y --no-install-recommends cuda-compiler-11-7 cuda-cudart-11-7 cuda-cudart-dev-11-7 cuda-driver-dev-11-7 cuda-nvcc-11-7 cuda-libraries-dev-11-7
sudo ln -s /usr/local/cuda-11.7 /usr/local/cuda
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export CUDADIR=/usr/local/cuda
- name: Configure & Build
if: ${{ steps.sd-cpp-cache.outputs.cache-hit != 'true' }}
run: |
mkdir -p build
cd build
# Set CUDA environment variables only for Ubuntu 22.04
if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export CUDADIR=/usr/local/cuda
fi
if [ "${{ matrix.variant }}" = "CPU" ]; then
cmake .. -DCMAKE_BUILD_TYPE=Release -DSDGUI_AVX=ON -DSDGUI_AVX2=ON -DSDGUI_AVX512=ON -DSDGUI_SERVER=OFF -DSDGUI_WINDOWLESS=ON
elif [ "${{ matrix.variant }}" = "HIPBLAS" ]; then
cmake .. -DCMAKE_BUILD_TYPE=Release -DSDGUI_HIPBLAS=ON -DSDGUI_SERVER=OFF -DSDGUI_WINDOWLESS=ON
elif [ "${{ matrix.variant }}" = "VULKAN" ]; then
cmake .. -DCMAKE_BUILD_TYPE=Release -DSDGUI_VULKAN=ON -DSDGUI_SERVER=OFF -DSDGUI_WINDOWLESS=ON
elif [ "${{ matrix.variant }}" = "CUDA" ]; then
cmake .. -DCMAKE_BUILD_TYPE=Release -DSDGUI_CUDA=ON -DSDGUI_SERVER=OFF -DSDGUI_WINDOWLESS=ON
fi
cmake --build . --config Release -j2
- name: Upload Build Outputs
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.variant }}
path: |
build/*.so
build/include
compression-level: 0
overwrite: true
package-ubuntu:
name: Build main Application
needs: [build-ubuntu]
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
runs-on: ${{ matrix.os }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install base dependencies
run: |
sudo apt update
sudo apt install -y fuse3 cmake gettext git build-essential ninja-build libexiv2-dev libssl-dev libjpeg-dev libpng-dev libtiff-dev libgtk-3-dev libcurl4-openssl-dev libsecret-1-dev libnotify-dev libwebkit2gtk-4.1-dev libsdl2-dev libomp-dev >/dev/null
- name: Cache wxWidgets
id: cache-wxwidgets
uses: actions/cache@v4
with:
path: |
build/_deps/wxwidgets-src
build/_deps/wxwidgets-build
build/_deps/wxwidgets-subbuild
key: ${{ matrix.os }}-wxwidgets-${{ hashFiles('cmake/wxWidgets_version.cmake') }}
restore-keys: ${{ matrix.os }}-wxwidgets
- name: Restore builds
uses: actions/download-artifact@v4
with:
path: build
pattern: ${{ matrix.os }}-*
merge-multiple: true
- name: Configure & Compile main application
run: |
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DSDGUI_SERVER=ON -DSDGUI_WINDOWLESS=OFF
cmake --build . --config Release --target po-compile
cmake --build . --config Release
- name: Package main application
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
run: |
cd build
cmake --build . --config Release --target package
# mkdir -p AppImageSource/usr/lib
# cp -pP /usr/lib/x86_64-linux-gnu/libexiv2* AppImageSource/usr/lib
# cp -pP /usr/lib/x86_64-linux-gnu/libjpeg* AppImageSource/usr/lib
# cp -pP /usr/lib/x86_64-linux-gnu/libpng* AppImageSource/usr/lib
# cp -pP /usr/lib/x86_64-linux-gnu/libcurl* AppImageSource/usr/lib
# cmake --build . --config Release --target AppImage
- name: Upload Release Outputs
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@v4
with:
name: prebuild-packages-${{ matrix.os }}
path: |
build/*.deb
build/*.tar.gz
build/out/*.AppImage
build/*.sha256
compression-level: 0
overwrite: true
- name: Log in to Docker Hub
if: ${{ (matrix.os == 'ubuntu-24.04') && (startsWith(github.ref, 'refs/tags/') || github.event.inputs.push_docker == 'true') }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker images
if: ${{ (matrix.os == 'ubuntu-24.04') && (startsWith(github.ref, 'refs/tags/') || github.event.inputs.push_docker == 'true') }}
run: |
cd build
docker build --build-arg BACKEND=all -t fszontagh/stablediffusiongui-server:${{ github.ref_name }}-all -f server/Dockerfile .
docker build --build-arg BACKEND=all-cpu -t fszontagh/stablediffusiongui-server:${{ github.ref_name }}-allcpu -f server/Dockerfile .
docker build --build-arg BACKEND=all-gpu -t fszontagh/stablediffusiongui-server:${{ github.ref_name }}-allgpu -f server/Dockerfile .
docker build --build-arg BACKEND=avx -t fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx -f server/Dockerfile .
docker build --build-arg BACKEND=avx2 -t fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx2 -f server/Dockerfile .
docker build --build-arg BACKEND=avx512 -t fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx512 -f server/Dockerfile .
docker build --build-arg BACKEND=cuda -t fszontagh/stablediffusiongui-server:${{ github.ref_name }}-cuda -f server/Dockerfile .
docker build --build-arg BACKEND=vulkan -t fszontagh/stablediffusiongui-server:${{ github.ref_name }}-vulkan -f server/Dockerfile .
docker push fszontagh/stablediffusiongui-server:${{ github.ref_name }}-all
docker push fszontagh/stablediffusiongui-server:${{ github.ref_name }}-allcpu
docker push fszontagh/stablediffusiongui-server:${{ github.ref_name }}-allgpu
docker push fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx
docker push fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx2
docker push fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx512
docker push fszontagh/stablediffusiongui-server:${{ github.ref_name }}-cuda
docker push fszontagh/stablediffusiongui-server:${{ github.ref_name }}-vulkan
- name: Tag and Push Latest Docker images
if: ${{ (matrix.os == 'ubuntu-24.04') && startsWith(github.ref, 'refs/tags/') }}
run: |
docker tag fszontagh/stablediffusiongui-server:${{ github.ref_name }}-all fszontagh/stablediffusiongui-server:latest-all
docker tag fszontagh/stablediffusiongui-server:${{ github.ref_name }}-allcpu fszontagh/stablediffusiongui-server:latest-allcpu
docker tag fszontagh/stablediffusiongui-server:${{ github.ref_name }}-allgpu fszontagh/stablediffusiongui-server:latest-allgpu
docker tag fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx fszontagh/stablediffusiongui-server:latest-avx
docker tag fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx2 fszontagh/stablediffusiongui-server:latest-avx2
docker tag fszontagh/stablediffusiongui-server:${{ github.ref_name }}-avx512 fszontagh/stablediffusiongui-server:latest-avx512
docker tag fszontagh/stablediffusiongui-server:${{ github.ref_name }}-cuda fszontagh/stablediffusiongui-server:latest-cuda
docker tag fszontagh/stablediffusiongui-server:${{ github.ref_name }}-vulkan fszontagh/stablediffusiongui-server:latest-vulkan
docker push fszontagh/stablediffusiongui-server:latest-all
docker push fszontagh/stablediffusiongui-server:latest-allcpu
docker push fszontagh/stablediffusiongui-server:latest-allgpu
docker push fszontagh/stablediffusiongui-server:latest-avx
docker push fszontagh/stablediffusiongui-server:latest-avx2
docker push fszontagh/stablediffusiongui-server:latest-avx512
docker push fszontagh/stablediffusiongui-server:latest-cuda
docker push fszontagh/stablediffusiongui-server:latest-vulkan
merge-packages:
name: Merge packages
runs-on: ubuntu-latest
needs: [package-ubuntu, package-installer]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Create directories
run: |
mkdir -p build
- name: Download packages
uses: actions/download-artifact@v4
id: download-packages
with:
path: build
pattern: prebuild-packages-*
merge-multiple: true
- name: Release Linux packages
uses: softprops/action-gh-release@v2
with:
body: ""
draft: true
prerelease: true
files: |
build/*.deb
build/out/*.AppImage
build/*.tar.gz
build/*.sha256
build/*.exe
build/*.7z