Skip to content

Build SD WebUI

Build SD WebUI #48

name: Build SD WebUI
on:
push:
branches:
- main
paths:
- ".github/workflows/build_sd_webui.yml"
# delete:
# create:
schedule:
# * is a special character in YAML so you have to quote this string
# UTC 17:00 -> CST (China) 1:00, see https://datetime360.com/cn/utc-cst-china-time/
# https://docs.github.com/zh/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule
- cron: '15 18 * * 0'
workflow_dispatch:
jobs:
Build-SD-WebUI:
name: Build SD WebUI
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: List files in the repository
shell: pwsh
run: |
Get-ChildItem -Path "${{ github.workspace }}" -Recurse
- name: Launch SD WebUI Installer
shell: pwsh
env:
UV_NO_PROGRESS: 1
run: |
$pytorch_package_input = "${{ inputs.pytorch_package }}"
$xformers_package_input = "${{ inputs.xformers_package }}"
if (!$pytorch_package_input) {
$pytorch_package_input = "torch==2.7.0+cu128 torchvision==0.22.0+cu128 torchaudio==2.7.0+cu128"
}
if (!$xformers_package_input) {
$xformers_package_input = "xformers==0.0.30"
}
& "${{ github.workspace }}/stable_diffusion_webui_installer.ps1" `
-InstallPath "${{ github.workspace }}/sd_webui" `
-BuildMode `
-BuildWithUpdate `
-BuildWithUpdateExtension `
-BuildWithLaunch `
-BuildWitchBranch 2 `
-InstallBranch "sd_webui" `
-NoPreDownloadModel `
-DisablePyPIMirror `
-DisableGithubMirror `
-DisableHuggingFaceMirror `
-PyTorchPackage "torch==2.7.0+cu128 torchvision==0.22.0+cu128 torchaudio==2.7.0+cu128" `
-xFormersPackage "$xformers_package_input"
- name: Install Insightface
shell: pwsh
env:
PIP_NO_WARN_SCRIPT_LOCATION: 0
PIP_DISABLE_PIP_VERSION_CHECK: 1
run: |
& "${{ github.workspace }}/sd_webui/python/python.exe" -m pip install insightface
- name: Install OpenPose Editor Assets
shell: pwsh
run: |
function Install-OpenPose-Editor-Assets ($temp_path, $install_path) {
$url = "https://github.com/huchenlei/sd-webui-openpose-editor/releases/download/v0.3.0/dist.zip"
$archive_path = "${temp_path}/dist_archive.zip"
$expand_path = "${temp_path}/editor_dist"
if (!(Test-Path $temp_path)) {
New-Item -ItemType Directory -Path $temp_path -Force
}
try {
Invoke-WebRequest -Uri $url -OutFile $archive_path
Expand-Archive -Path $archive_path -DestinationPath $expand_path -Force
Move-Item -Path $expand_path -Destination $install_path -Force
}
catch {
Write-Host "安装 OpenPose Editor 资源出现错误: $_"
}
}
Install-OpenPose-Editor-Assets `
"${{ github.workspace }}/temp" `
"${{ github.workspace }}/sd_webui/stable-diffusion-webui/extensions/sd-webui-openpose-editor/dist"
- name: Launch to complete dependencies
shell: pwsh
env:
UV_NO_PROGRESS: 1
run: |
& "${{ github.workspace }}/sd_webui/launch.ps1" `
-BuildMode `
-DisablePyPIMirror `
-DisableGithubMirror `
-DisableHuggingFaceMirror
- name: Install Hanamizuki
shell: pwsh
run: |
. "${{ github.workspace }}/sd_webui/activate.ps1"
Install-Hanamizuki
- name: Download VAE approx model
shell: pwsh
run: |
$model_list = @(
"https://huggingface.co/licyk/sd-vae/resolve/main/vae-approx/model.pt",
"https://huggingface.co/licyk/sd-vae/resolve/main/vae-approx/vaeapprox-sd3.pt",
"https://huggingface.co/licyk/sd-vae/resolve/main/vae-approx/vaeapprox-sdxl.pt"
)
$vae_approx_path = "${{ github.workspace }}/sd_webui/stable-diffusion-webui/models/VAE-approx"
New-Item -ItemType Directory -Path "$vae_approx_path" -Force
ForEach ($url in $model_list) {
$filename = Split-Path $url -Leaf
$model_path = Join-Path -Path $vae_approx_path -ChildPath $filename
if (Test-Path $model_path) {
Write-Host "$filename 已存在于 $vae_approx_path"
} else {
Write-Host "下载 $filename 到 $vae_approx_path 中"
Invoke-WebRequest -Uri $url -OutFile $model_path
}
}
- name: Make docs
shell: pwsh
run: |
python "${{ github.workspace }}/.github/make_docs.py" "${{ github.workspace }}/sd_webui"
- name: Archive
shell: pwsh
run: |
$build_time = (Get-Date).ToUniversalTime().AddHours(8).ToString("yyyyMMdd")
$package_name = "sd_webui_licyk_${build_time}"
$protable_name = "${package_name}_nightly.7z"
New-Item -ItemType Directory -Path "${{ github.workspace }}/sdnote/portable/nightly" -Force
Move-Item -Path "${{ github.workspace }}/sd_webui" -Destination "${{ github.workspace }}/${package_name}" -Force
7z a -t7z -bsp1 "${{ github.workspace }}/sdnote/portable/nightly/sd_webui/${protable_name}" "${{ github.workspace }}/${package_name}"
- name: Install HuggingFace and ModelScope library
shell: pwsh
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
run: |
pip install huggingface_hub modelscope
- name: Upload to HuggingFace repo
shell: pwsh
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
WORKSPACE: ${{ github.workspace }}
run: |
python "${{ github.workspace }}/.github/huggingface_release.py"
- name: Upload to ModelScope repo
shell: pwsh
env:
MODELSCOPE_API_TOKEN: ${{ secrets.MODELSCOPE_API_TOKEN }}
WORKSPACE: ${{ github.workspace }}
run: |
python "${{ github.workspace }}/.github/modelscope_release.py"