|
| 1 | +name: Rescue Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag_name: |
| 7 | + description: "Release tag to publish" |
| 8 | + required: true |
| 9 | + default: "v0.3.0" |
| 10 | + source_run_id: |
| 11 | + description: "Build Packages run id containing completed non-CUDA artifacts" |
| 12 | + required: true |
| 13 | + default: "26878136155" |
| 14 | + |
| 15 | +permissions: |
| 16 | + actions: read |
| 17 | + contents: write |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: rescue-release-${{ inputs.tag_name }} |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + windows-cuda: |
| 25 | + name: Windows x64 CUDA ${{ matrix.cuda }} |
| 26 | + runs-on: windows-2022 |
| 27 | + timeout-minutes: 360 |
| 28 | + env: |
| 29 | + CCACHE_MAXSIZE: 5G |
| 30 | + CCACHE_SLOPPINESS: time_macros |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + cuda: ["12.4", "13.1"] |
| 35 | + steps: |
| 36 | + - name: Clone release tag |
| 37 | + uses: actions/checkout@v6 |
| 38 | + with: |
| 39 | + ref: ${{ inputs.tag_name }} |
| 40 | + |
| 41 | + - name: Setup Node.js |
| 42 | + uses: actions/setup-node@v6 |
| 43 | + with: |
| 44 | + node-version: "24" |
| 45 | + cache: "npm" |
| 46 | + cache-dependency-path: "tools/ui/package-lock.json" |
| 47 | + |
| 48 | + - name: Install ccache |
| 49 | + uses: ggml-org/ccache-action@v1.2.21 |
| 50 | + with: |
| 51 | + key: release-windows-cuda-${{ matrix.cuda }} |
| 52 | + variant: ccache |
| 53 | + evict-old-files: 1d |
| 54 | + |
| 55 | + - name: Cache CUDA Toolkit |
| 56 | + id: cache-cuda |
| 57 | + uses: actions/cache@v5 |
| 58 | + with: |
| 59 | + path: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${{ matrix.cuda }} |
| 60 | + key: cuda-windows-${{ matrix.cuda }}-${{ hashFiles('.github/actions/windows-setup-cuda/action.yml') }} |
| 61 | + |
| 62 | + - name: Install CUDA Toolkit |
| 63 | + if: steps.cache-cuda.outputs.cache-hit != 'true' |
| 64 | + uses: ./.github/actions/windows-setup-cuda |
| 65 | + with: |
| 66 | + cuda_version: ${{ matrix.cuda }} |
| 67 | + |
| 68 | + - name: Configure CUDA environment |
| 69 | + shell: pwsh |
| 70 | + run: | |
| 71 | + $ErrorActionPreference = "Stop" |
| 72 | + $cudaPath = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${{ matrix.cuda }}" |
| 73 | + $nvcc = Join-Path $cudaPath "bin\nvcc.exe" |
| 74 | + if (-not (Test-Path $nvcc)) { |
| 75 | + throw "CUDA Toolkit not found at $cudaPath" |
| 76 | + } |
| 77 | +
|
| 78 | + Join-Path $cudaPath "bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 79 | + $libNvvp = Join-Path $cudaPath "libnvvp" |
| 80 | + if (Test-Path $libNvvp) { |
| 81 | + $libNvvp | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 82 | + } |
| 83 | +
|
| 84 | + "CUDA_PATH=$cudaPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 85 | + $versionEnv = "CUDA_PATH_V${{ matrix.cuda }}".Replace(".", "_") |
| 86 | + "$versionEnv=$cudaPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 87 | +
|
| 88 | + - name: Install Ninja |
| 89 | + run: choco install ninja -y |
| 90 | + |
| 91 | + - name: Build CUDA backend |
| 92 | + shell: cmd |
| 93 | + run: | |
| 94 | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 |
| 95 | + cmake -S . -B build -G "Ninja Multi-Config" ^ |
| 96 | + -DGGML_BACKEND_DL=ON ^ |
| 97 | + -DGGML_NATIVE=OFF ^ |
| 98 | + -DGGML_CPU=OFF ^ |
| 99 | + -DGGML_CUDA=ON ^ |
| 100 | + -DGGML_CUDA_FA=ON ^ |
| 101 | + -DGGML_CUDA_FA_ALL_QUANTS=ON ^ |
| 102 | + -DLLAMA_BUILD_BORINGSSL=ON ^ |
| 103 | + -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache ^ |
| 104 | + -DGGML_CUDA_CUB_3DOT2=ON |
| 105 | + set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1 |
| 106 | + cmake --build build --config Release -j %NINJA_JOBS% --target ggml-cuda |
| 107 | +
|
| 108 | + - name: ccache stats |
| 109 | + if: always() |
| 110 | + run: ccache --show-stats |
| 111 | + |
| 112 | + - name: Pack CUDA backend |
| 113 | + run: 7z a -snl "beellama-bin-win-cuda-${{ matrix.cuda }}-x64.zip" .\build\bin\Release\ggml-cuda.dll |
| 114 | + |
| 115 | + - name: Upload CUDA backend |
| 116 | + uses: actions/upload-artifact@v6 |
| 117 | + with: |
| 118 | + path: beellama-bin-win-cuda-${{ matrix.cuda }}-x64.zip |
| 119 | + name: beellama-bin-win-cuda-${{ matrix.cuda }}-x64.zip |
| 120 | + |
| 121 | + - name: Pack CUDA runtime |
| 122 | + shell: pwsh |
| 123 | + run: | |
| 124 | + $ErrorActionPreference = "Stop" |
| 125 | + $dst = ".\build\bin\cudart" |
| 126 | + New-Item -ItemType Directory -Force -Path $dst | Out-Null |
| 127 | + $roots = @("${{ env.CUDA_PATH }}\bin", "${{ env.CUDA_PATH }}\lib", "${{ env.CUDA_PATH }}\bin\x64") |
| 128 | + foreach ($root in $roots) { |
| 129 | + if (Test-Path $root) { |
| 130 | + Get-ChildItem -Path (Join-Path $root "*") -File -ErrorAction SilentlyContinue | |
| 131 | + Where-Object { $_.Name -like "cudart64_*.dll" -or $_.Name -like "cublas64_*.dll" -or $_.Name -like "cublasLt64_*.dll" } | |
| 132 | + Copy-Item -Destination $dst -Force |
| 133 | + } |
| 134 | + } |
| 135 | + 7z a "cudart-beellama-bin-win-cuda-${{ matrix.cuda }}-x64.zip" "$dst\*" |
| 136 | +
|
| 137 | + - name: Upload CUDA runtime |
| 138 | + uses: actions/upload-artifact@v6 |
| 139 | + with: |
| 140 | + path: cudart-beellama-bin-win-cuda-${{ matrix.cuda }}-x64.zip |
| 141 | + name: cudart-beellama-bin-win-cuda-${{ matrix.cuda }}-x64.zip |
| 142 | + |
| 143 | + publish: |
| 144 | + name: Publish rescued release |
| 145 | + needs: windows-cuda |
| 146 | + runs-on: ubuntu-24.04 |
| 147 | + env: |
| 148 | + TAG_NAME: ${{ inputs.tag_name }} |
| 149 | + SOURCE_RUN_ID: ${{ inputs.source_run_id }} |
| 150 | + GH_TOKEN: ${{ github.token }} |
| 151 | + steps: |
| 152 | + - name: Download rebuilt Windows CUDA artifacts |
| 153 | + uses: actions/download-artifact@v7 |
| 154 | + with: |
| 155 | + path: ./artifact |
| 156 | + merge-multiple: true |
| 157 | + |
| 158 | + - name: Download completed artifacts from source run |
| 159 | + shell: bash |
| 160 | + run: | |
| 161 | + set -euo pipefail |
| 162 | + artifacts=( |
| 163 | + beellama-bin-macos-arm64.tar.gz |
| 164 | + beellama-bin-ubuntu-rocm-7.2-x64.tar.gz |
| 165 | + beellama-bin-ubuntu-sycl-x64.tar.gz |
| 166 | + beellama-bin-ubuntu-vulkan-x64.tar.gz |
| 167 | + beellama-bin-ubuntu-x64.tar.gz |
| 168 | + beellama-bin-win-cpu-x64.zip |
| 169 | + beellama-bin-win-hip-radeon-x64.zip |
| 170 | + beellama-bin-win-sycl-x64.zip |
| 171 | + ) |
| 172 | + for artifact in "${artifacts[@]}"; do |
| 173 | + gh run download "${SOURCE_RUN_ID}" \ |
| 174 | + --repo "${GITHUB_REPOSITORY}" \ |
| 175 | + --name "${artifact}" \ |
| 176 | + --dir ./artifact |
| 177 | + done |
| 178 | +
|
| 179 | + - name: Prepare release assets |
| 180 | + shell: bash |
| 181 | + run: | |
| 182 | + set -euo pipefail |
| 183 | + shopt -s nullglob |
| 184 | +
|
| 185 | + mkdir -p release |
| 186 | +
|
| 187 | + expected_artifacts=( |
| 188 | + artifact/beellama-bin-macos-arm64.tar.gz |
| 189 | + artifact/beellama-bin-ubuntu-rocm-7.2-x64.tar.gz |
| 190 | + artifact/beellama-bin-ubuntu-sycl-x64.tar.gz |
| 191 | + artifact/beellama-bin-ubuntu-vulkan-x64.tar.gz |
| 192 | + artifact/beellama-bin-ubuntu-x64.tar.gz |
| 193 | + artifact/beellama-bin-win-cpu-x64.zip |
| 194 | + artifact/beellama-bin-win-hip-radeon-x64.zip |
| 195 | + artifact/beellama-bin-win-sycl-x64.zip |
| 196 | + artifact/beellama-bin-win-cuda-12.4-x64.zip |
| 197 | + artifact/beellama-bin-win-cuda-13.1-x64.zip |
| 198 | + artifact/cudart-beellama-bin-win-cuda-12.4-x64.zip |
| 199 | + artifact/cudart-beellama-bin-win-cuda-13.1-x64.zip |
| 200 | + ) |
| 201 | + for path in "${expected_artifacts[@]}"; do |
| 202 | + if [[ ! -f "${path}" ]]; then |
| 203 | + echo "Missing expected artifact: ${path}" >&2 |
| 204 | + exit 1 |
| 205 | + fi |
| 206 | + done |
| 207 | +
|
| 208 | + cpu_zip="artifact/beellama-bin-win-cpu-x64.zip" |
| 209 | + temp_dir="$(mktemp -d)" |
| 210 | + unzip -q "${cpu_zip}" -d "${temp_dir}" |
| 211 | + for target_zip in artifact/beellama-bin-win-*-x64.zip; do |
| 212 | + if [[ "$(basename "${target_zip}")" == "beellama-bin-win-cpu-x64.zip" ]]; then |
| 213 | + continue |
| 214 | + fi |
| 215 | + realpath_target_zip="$(realpath "${target_zip}")" |
| 216 | + (cd "${temp_dir}" && zip -qr "${realpath_target_zip}" .) |
| 217 | + done |
| 218 | + rm -rf "${temp_dir}" |
| 219 | +
|
| 220 | + for zip_file in artifact/beellama-bin-win-*.zip; do |
| 221 | + base_name="$(basename "${zip_file}" .zip)" |
| 222 | + mv "${zip_file}" "release/beellama-${TAG_NAME}-${base_name#beellama-}.zip" |
| 223 | + done |
| 224 | +
|
| 225 | + for zip_file in artifact/cudart-beellama-bin-win-cuda-*.zip; do |
| 226 | + base_name="$(basename "${zip_file}" .zip)" |
| 227 | + suffix="${base_name#cudart-beellama-bin-win-}" |
| 228 | + mv "${zip_file}" "release/beellama-${TAG_NAME}-cudart-win-${suffix}.zip" |
| 229 | + done |
| 230 | +
|
| 231 | + for tar_file in artifact/*.tar.gz; do |
| 232 | + mv "${tar_file}" release/ |
| 233 | + done |
| 234 | +
|
| 235 | + sha256sum release/* > release/SHA256SUMS.txt |
| 236 | + ls -lh release |
| 237 | +
|
| 238 | + - name: Write release notes |
| 239 | + shell: bash |
| 240 | + run: | |
| 241 | + set -euo pipefail |
| 242 | + release_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/download/${TAG_NAME}" |
| 243 | + changelog_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/blob/main/CHANGELOG.md" |
| 244 | + image_repo="ghcr.io/${GITHUB_REPOSITORY,,}" |
| 245 | + repo_name="${GITHUB_REPOSITORY#*/}" |
| 246 | + repo_name="${repo_name,,}" |
| 247 | + package_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pkgs/container/${repo_name}" |
| 248 | +
|
| 249 | + docker_link() { |
| 250 | + local tag="$1" |
| 251 | + printf '[`%s:%s`](%s)' "${image_repo}" "${tag}" "${package_url}" |
| 252 | + } |
| 253 | +
|
| 254 | + docker_server="$(docker_link "server-${TAG_NAME}")" |
| 255 | + docker_cpu="$(docker_link "server-cpu-${TAG_NAME}")" |
| 256 | + docker_cuda="$(docker_link "server-cuda-${TAG_NAME}")" |
| 257 | + docker_cuda12="$(docker_link "server-cuda12-${TAG_NAME}")" |
| 258 | + docker_cuda13="$(docker_link "server-cuda13-${TAG_NAME}")" |
| 259 | + docker_rocm="$(docker_link "server-rocm-${TAG_NAME}")" |
| 260 | + docker_vulkan="$(docker_link "server-vulkan-${TAG_NAME}")" |
| 261 | + docker_sycl="$(docker_link "server-sycl-${TAG_NAME}")" |
| 262 | +
|
| 263 | + cat > release-notes.md << EOF |
| 264 | + <details open> |
| 265 | + <summary>Changelog</summary> |
| 266 | +
|
| 267 | + [CHANGELOG.md](${changelog_url}) |
| 268 | +
|
| 269 | + </details> |
| 270 | +
|
| 271 | + **macOS:** |
| 272 | + - [macOS Apple Silicon (arm64)](${release_url}/beellama-${TAG_NAME}-bin-macos-arm64.tar.gz) |
| 273 | +
|
| 274 | + **Linux:** |
| 275 | + - [Ubuntu x64 (CPU)](${release_url}/beellama-${TAG_NAME}-bin-ubuntu-x64.tar.gz) |
| 276 | + - [Ubuntu x64 (Vulkan)](${release_url}/beellama-${TAG_NAME}-bin-ubuntu-vulkan-x64.tar.gz) |
| 277 | + - [Ubuntu x64 (ROCm 7.2)](${release_url}/beellama-${TAG_NAME}-bin-ubuntu-rocm-7.2-x64.tar.gz) |
| 278 | + - [Ubuntu x64 (SYCL)](${release_url}/beellama-${TAG_NAME}-bin-ubuntu-sycl-x64.tar.gz) |
| 279 | +
|
| 280 | + **Windows:** |
| 281 | + - [Windows x64 (CPU)](${release_url}/beellama-${TAG_NAME}-bin-win-cpu-x64.zip) |
| 282 | + - [Windows x64 (SYCL)](${release_url}/beellama-${TAG_NAME}-bin-win-sycl-x64.zip) |
| 283 | + - [Windows x64 (CUDA 12)](${release_url}/beellama-${TAG_NAME}-bin-win-cuda-12.4-x64.zip) - [CUDA 12.4 DLLs](${release_url}/beellama-${TAG_NAME}-cudart-win-cuda-12.4-x64.zip) |
| 284 | + - [Windows x64 (CUDA 13)](${release_url}/beellama-${TAG_NAME}-bin-win-cuda-13.1-x64.zip) - [CUDA 13.1 DLLs](${release_url}/beellama-${TAG_NAME}-cudart-win-cuda-13.1-x64.zip) |
| 285 | + - [Windows x64 (HIP)](${release_url}/beellama-${TAG_NAME}-bin-win-hip-radeon-x64.zip) |
| 286 | +
|
| 287 | + **Docker:** |
| 288 | + - ${docker_server} / ${docker_cpu} (CPU, linux/amd64 + linux/arm64; usable on Apple Silicon Docker Desktop without Metal acceleration) |
| 289 | + - ${docker_cuda} / ${docker_cuda12} |
| 290 | + - ${docker_cuda13} |
| 291 | + - ${docker_rocm} |
| 292 | + - ${docker_vulkan} |
| 293 | + - ${docker_sycl} |
| 294 | + EOF |
| 295 | +
|
| 296 | + - name: Publish release |
| 297 | + shell: bash |
| 298 | + run: | |
| 299 | + set -euo pipefail |
| 300 | + mapfile -t release_files < <(find release -type f ! -name release-notes.md | sort) |
| 301 | + if [[ "${#release_files[@]}" -eq 0 ]]; then |
| 302 | + echo "No release files found" >&2 |
| 303 | + exit 1 |
| 304 | + fi |
| 305 | +
|
| 306 | + if gh release view "${TAG_NAME}" >/dev/null 2>&1; then |
| 307 | + gh release upload "${TAG_NAME}" "${release_files[@]}" --clobber |
| 308 | + gh release edit "${TAG_NAME}" --title "${TAG_NAME}" --notes-file release-notes.md |
| 309 | + else |
| 310 | + gh release create "${TAG_NAME}" "${release_files[@]}" --title "${TAG_NAME}" --notes-file release-notes.md --verify-tag |
| 311 | + fi |
0 commit comments