Skip to content

Build SD-Trainer

Build SD-Trainer #32

name: Build SD-Trainer
on:
push:
branches:
- main
paths:
- ".github/workflows/build_sd_trainer.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: '30 17 * * 0'
workflow_dispatch:
jobs:
Build-SD-Trainer:
name: Build SD-Trainer
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-Trainer Installer
shell: pwsh
env:
UV_NO_PROGRESS: 1
run: |
& "${{ github.workspace }}/sd_trainer_installer.ps1" `
-InstallPath "${{ github.workspace }}/sd_trainer" `
-BuildMode `
-BuildWithUpdate `
-BuildWithLaunch `
-BuildWitchBranch 1 `
-InstallBranch "sd_trainer" `
-DisablePyPIMirror `
-DisableGithubMirror `
-DisableHuggingFaceMirror `
-PyTorchPackage "torch==2.7.0+cu128 torchvision==0.22.0+cu128 torchaudio==2.7.0+cu128" `
-xFormersPackage "xformers==0.0.30"
- name: Install Hanamizuki
shell: pwsh
run: |
. "${{ github.workspace }}/sd_trainer/activate.ps1"
Install-Hanamizuki
- name: Make docs
shell: pwsh
run: |
python "${{ github.workspace }}/.github/make_docs.py" "${{ github.workspace }}/sd_trainer"
- name: Archive
shell: pwsh
run: |
$build_time = (Get-Date).ToUniversalTime().AddHours(8).ToString("yyyyMMdd")
$package_name = "sd_trainer_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_trainer" -Destination "${{ github.workspace }}/${package_name}" -Force
7z a -t7z -bsp1 "${{ github.workspace }}/sdnote/portable/nightly/sd_trainer/${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"