CI #64
This file contains hidden or 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: CI | |
on: | |
workflow_dispatch: # allows manual triggering | |
inputs: | |
create_release: | |
description: "Create new release" | |
required: true | |
type: boolean | |
push: | |
branches: | |
- master | |
- ci | |
paths: | |
[ | |
".github/workflows/**", | |
"**/CMakeLists.txt", | |
"**/Makefile", | |
"**/*.h", | |
"**/*.hpp", | |
"**/*.c", | |
"**/*.cpp", | |
"**/*.cu", | |
] | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
[ | |
"**/CMakeLists.txt", | |
"**/Makefile", | |
"**/*.h", | |
"**/*.hpp", | |
"**/*.c", | |
"**/*.cpp", | |
"**/*.cu", | |
] | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
jobs: | |
windows-latest-cmake: | |
runs-on: windows-2019 | |
env: | |
VULKAN_VERSION: 1.3.261.1 | |
strategy: | |
matrix: | |
include: | |
#- build: "noavx" | |
# defines: "-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DSD_BUILD_SHARED_LIBS=ON" | |
#- build: "avx2" | |
# defines: "-DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON" | |
#- build: "avx" | |
# defines: "-DGGML_AVX2=OFF -DSD_BUILD_SHARED_LIBS=ON" | |
#- build: "avx512" | |
# defines: "-DGGML_AVX512=ON -DSD_BUILD_SHARED_LIBS=ON" | |
#- build: "cuda12" | |
# defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON" | |
# - build: "rocm5.5" | |
# defines: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030" -DSD_BUILD_SHARED_LIBS=ON' | |
- build: 'vulkan' | |
defines: "-DSD_VULKAN=ON -DGGML_AVX=ON -DGGML_AVX2=OFF -DGGML_FMA=ON -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF" | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Install Vulkan SDK | |
id: get_vulkan | |
if: ${{ matrix.build == 'vulkan' }} | |
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: Build | |
id: cmake_build | |
run: | | |
mkdir build | |
cd build | |
cmake .. ${{ matrix.defines }} | |
cmake --build . --config Release | |
- name: Get commit hash | |
id: commit | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
uses: pr-mpt/actions-commit-hash@v2 | |
- name: Pack artifacts | |
id: pack_artifacts | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
run: | | |
$filePath = ".\build\bin\Release\*" | |
if (Test-Path $filePath) { | |
echo "Exists at path $filePath" | |
Copy-Item ggml/LICENSE .\build\bin\Release\ggml.txt | |
Copy-Item LICENSE .\build\bin\Release\stable-diffusion.cpp.txt | |
} elseif (Test-Path ".\build\bin\stable-diffusion.dll") { | |
$filePath = ".\build\bin\*" | |
echo "Exists at path $filePath" | |
Copy-Item ggml/LICENSE .\build\bin\ggml.txt | |
Copy-Item LICENSE .\build\bin\stable-diffusion.cpp.txt | |
} else { | |
ls .\build\bin | |
throw "Can't find stable-diffusion.dll" | |
} | |
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip $filePath | |
- name: Upload artifacts | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip | |
path: | | |
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip | |
release: | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
runs-on: ubuntu-latest | |
needs: | |
- windows-latest-cmake | |
steps: | |
- name: Download artifacts | |
id: download-artifact | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifact | |
pattern: sd-* | |
merge-multiple: true | |
- name: Get commit hash | |
id: commit | |
uses: pr-mpt/actions-commit-hash@v2 | |
- name: Create release | |
id: create_release | |
uses: anzz1/action-create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }} | |
- name: Upload release | |
id: upload_release | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const path = require('path'); | |
const fs = require('fs'); | |
const release_id = '${{ steps.create_release.outputs.id }}'; | |
for (let file of await fs.readdirSync('./artifact')) { | |
if (path.extname(file) === '.zip') { | |
console.log('uploadReleaseAsset', file); | |
await github.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: release_id, | |
name: file, | |
data: await fs.readFileSync(`./artifact/${file}`) | |
}); | |
} | |
} |