Build UNet Studio #149
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build UNet Studio | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag' | |
required: true | |
default: '2023.04.17' | |
release_name: | |
description: 'Release Name' | |
required: true | |
default: '2022.04.17 "Sun" Release' | |
jobs: | |
windows_build: | |
runs-on: windows-2019 | |
env: | |
CMAKE_PREFIX_PATH: D:/a/UNet-Studio/UNet-Studio/libtorch | |
Torch_DIR: D:/a/UNet-Studio/UNet-Studio/libtorch/share/cmake/Torch | |
steps: | |
- uses: actions/[email protected] | |
- name: Install CUDA | |
uses: Jimver/[email protected] | |
with: | |
cuda: '11.7.0' | |
- name: Install LibTorch | |
run: | | |
curl -LO "https://download.pytorch.org/libtorch/cu117/libtorch-win-shared-with-deps-2.0.0%2Bcu117.zip" | |
mkdir libtorch | |
tar -xf "libtorch-win-shared-with-deps-2.0.0%2Bcu117.zip" | |
- name: Install Qt | |
uses: jurplel/[email protected] | |
with: | |
version: 6.5.2 | |
- name: Install Ninja and CMake | |
run: | | |
choco install ninja cmake | |
- name: Install Zlib | |
run: | | |
./build_packages/install_zlib.bat | |
del "C:/Program Files/zlib/lib/zlib.lib" | |
del "C:/Program Files/zlib/bin/zlib.dll" | |
- name: Install TIPL | |
run: | | |
git clone https://github.com/frankyeh/TIPL.git | |
git clone https://github.com/frankyeh/UNet-Studio-Data.git | |
- name: Build UNet Studio | |
run: | | |
dir "D:/a/UNet-Studio/UNet-Studio/libtorch/share/cmake/Torch" | |
for /f "usebackq delims=#" %%a in (`"%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -latest -property installationPath`) do call "%%a\Common7\Tools\VsDevCmd.bat" -arch=x64 | |
mkdir -p build | |
cmake -S . -B build -GNinja -DCMAKE_PREFIX_PATH=D:\a\UNet-Studio\UNet-Studio\libtorch -DTorch_DIR=D:\a\UNet-Studio\UNet-Studio\libtorch\share\cmake\Torch -DCMAKE_BUILD_TYPE=Release -DTIPL_DIR=. | |
cmake --build ./build --parallel --config Release | |
shell: cmd | |
- name: Packaging | |
run: | | |
move UNet-Studio-Data unet_studio_win | |
move install_win.bat unet_studio_win | |
move build\unet_studio.exe unet_studio_win | |
windeployqt --no-translations --no-system-d3d-compiler --compiler-runtime --no-opengl-sw unet_studio_win\unet_studio.exe | |
del *.zip | |
- name: Zip Release (Update) | |
uses: TheDoctor0/[email protected] | |
with: | |
filename: unet_studio_win.zip | |
exclusions: .git | |
path: unet_studio_win | |
- name: Create Release | |
uses: ncipollo/[email protected] | |
with: | |
allowUpdates: true | |
artifacts: "*.zip" | |
tag: ${{ github.event.inputs.tag }} | |
name: ${{ github.event.inputs.release_name }} | |
prerelease: false | |
linux-build: | |
strategy: | |
matrix: | |
os: [ubuntu2204,ubuntu2404] | |
fail-fast: false | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/[email protected] | |
- name: Build and push | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: build_packages/${{ matrix.os }}/Dockerfile | |
push: false | |
outputs: unet-studio | |
- name: Packaging | |
run: | | |
zip -r unet_studio_${{ matrix.os }}.zip unet-studio | |
- name: Create Release | |
uses: ncipollo/[email protected] | |
with: | |
allowUpdates: true | |
artifacts: "*.zip" | |
tag: ${{ github.event.inputs.tag }} | |
name: ${{ github.event.inputs.release_name }} | |
prerelease: false | |
docker_build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: false | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: false | |
swap-storage: true | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to DockerHub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Current Time | |
run: echo "DATE_TAG=$(date "+%Y-%m-%d")" >> $GITHUB_ENV | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: build_packages/docker/Dockerfile | |
push: true | |
tags: | | |
"dsistudio/unetstudio:sun-${{ env.DATE_TAG }}" | |
dsistudio/unetstudio:latest | |
macos-build: | |
strategy: | |
matrix: | |
os: [macos-12,macos-13] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
env: | |
CFLAGS: -Werror | |
steps: | |
- uses: actions/[email protected] | |
- name: Setup Python | |
uses: actions/[email protected] | |
with: | |
python-version: 3.11 | |
- name: Install PyTorch | |
run: | | |
python -m pip install --upgrade pip | |
pip install torch torchvision torchaudio | |
- name: Install CMake | |
run: | | |
brew update | |
brew install cmake | |
- name: Install Qt | |
uses: jurplel/[email protected] | |
with: | |
version: '6.2' | |
- name: Download TIPL and Atlases | |
run: | | |
git clone https://github.com/frankyeh/TIPL.git | |
git clone https://github.com/frankyeh/UNet-Studio-Data.git | |
- name: Build UNet Studio | |
run: | | |
mkdir -p build | |
export TORCH_DIR="$(pip3.11 show torch | grep 'Location:' | awk '{print $2}')" | |
cmake -S . -B build -DCMAKE_PREFIX_PATH=$TORCH_DIR/torch -DCMAKE_BUILD_TYPE:STRING=Release -DTIPL_DIR=. | |
cmake --build ./build --parallel --config Release | |
cd .. | |
- name: Packaging | |
run: | | |
mv build/unet_studio.app . | |
macdeployqt unet_studio.app | |
mv UNet-Studio-Data/* unet_studio.app/Contents/MacOS/ | |
mv unet-studio.icns unet_studio.app/Contents/Resources/ | |
zip -r unet_studio_${{ matrix.os }}.zip unet_studio.app | |
- name: Create Release | |
uses: ncipollo/[email protected] | |
with: | |
allowUpdates: true | |
artifacts: "*.zip" | |
tag: ${{ github.event.inputs.tag }} | |
name: ${{ github.event.inputs.release_name }} | |
prerelease: false |