char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
41fc7584f
char/aliceai-t5-moe
1#!/bin/bash 2# Run all pre-release checks and determine the release version. 3# 4# Usage: make-release-checks.sh [--dry-run] 5# --dry-run: warn on failures instead of aborting 6# 7# Env (when running in GitHub Actions): 8# GH_TOKEN, GITHUB_REPOSITORY, GITHUB_OUTPUT 9# RELEASE_BRANCH: when set, HEAD must belong to origin/RELEASE_BRANCH and must 10# not be older than 3 days from the branch HEAD (skipped when unset) 11set -euo pipefail 12 13SCRIPT_DIR =" $( cd " $( dirname " ${ BASH_SOURCE [0]} " ) " && pwd ) " 14REPO_ROOT =" $( cd " $ SCRIPT_DIR /.." && pwd ) " 15 16DRY_RUN =false 17CHECKS_PASSED =true 18for arg in " $ @" ;do 19case " $ arg " in 20 --dry-run)DRY_RUN =true ;; 21 *)echo "Unknown argument: $ arg " ;exit 1 ;; 22esac 23done 24 25MAJOR =$( grep "set(LLAMA_VERSION_MAJOR" " $ REPO_ROOT /CMakeLists.txt" | sed 's/.*MAJOR \([0-9]*\).*/\1/' ) 26MINOR =$( grep "set(LLAMA_VERSION_MINOR" " $ REPO_ROOT /CMakeLists.txt" | sed 's/.*MINOR \([0-9]*\).*/\1/' ) 27PATCH =$( grep "set(LLAMA_VERSION_PATCH" " $ REPO_ROOT /CMakeLists.txt" | sed 's/.*PATCH \([0-9]*\).*/\1/' ) 28VERSION ="v ${ MAJOR } . ${ MINOR } . ${ PATCH } " 29echo "Determined version: ${ VERSION } " 30if [[ -n" ${ GITHUB_OUTPUT :-} " ]];then 31echo "version= ${ VERSION } " >> " $ GITHUB_OUTPUT " 32fi 33 34SHA =$( git rev-parse HEAD) 35 36echo "Checking that commit ${ SHA } belongs to the release branch..." 37if [[ -z" ${ RELEASE_BRANCH :-} " ]];then 38echo "Warning: RELEASE_BRANCH not set - skipping commit check (local run)" 39else 40TIP ="origin/ ${ RELEASE_BRANCH } " 41COMMIT_ERR ="" 42if !git rev-parse--verify " ${ TIP } " > /dev/null2 >&1;then 43COMMIT_ERR ="branch ${ RELEASE_BRANCH } not found on remote" 44elif !git merge-base--is-ancestor " ${ SHA } " " ${ TIP } " ;then 45COMMIT_ERR ="commit ${ SHA } is not part of branch ${ RELEASE_BRANCH } " 46else 47COMMIT_TS =$( git show -s --format=%ct " ${ SHA } " ) 48TIP_TS =$( git show -s --format=%ct " ${ TIP } " ) 49AGE_DAYS =$(( (TIP_TS -COMMIT_TS ) / 86400 )) 50if (( TIP_TS - COMMIT_TS > 3 * 86400 )) ;then 51COMMIT_ERR ="commit ${ SHA } is ${ AGE_DAYS } day(s) older than the HEAD of ${ RELEASE_BRANCH } (max: 3)" 52fi 53fi 54if [[ -n" ${ COMMIT_ERR } " ]];then 55if [[" $ DRY_RUN " =="true" ]];then 56echo "Warning: ${ COMMIT_ERR } (dry run, continuing)." 57CHECKS_PASSED =false 58else 59echo "Error: ${ COMMIT_ERR } " 60exit 1 61fi 62else 63echo "Commit ${ SHA } is on branch ${ RELEASE_BRANCH } and within 3 days of its HEAD - OK" 64fi 65fi 66 67echo "Checking that tag ${ VERSION } does not already exist..." 68if git ls-remote--tags origin" ${ VERSION } " | grep -q " ${ VERSION } " ;then 69echo "Error: tag ${ VERSION } already exists on remote" 70exit 1 71fi 72echo "Tag ${ VERSION } does not exist on remote - OK" 73 74echo "Checking release.yml status for commit ${ SHA } ..." 75if [[ -z" ${ GITHUB_REPOSITORY :-} " ]];then 76echo "Warning: GITHUB_REPOSITORY not set - skipping CI check (local run)" 77else 78RUNS =$( gh api "repos/ ${ GITHUB_REPOSITORY } /actions/workflows/release.yml/runs?per_page=100" \ 79--jq "[.workflow_runs[] | select(.head_sha == \" ${ SHA } \" and .conclusion == \"success\")] | length" ) 80if [[" $ RUNS " -eq 0 ]];then 81if [[" $ DRY_RUN " =="true" ]];then 82echo "Warning: no successful release.yml run found for HEAD ( ${ SHA } ) (dry run, continuing)." 83CHECKS_PASSED =false 84else 85echo "Error: no successful release.yml run found for HEAD ( ${ SHA } )" 86echo "The nightly build must complete successfully before making a release." 87exit 1 88fi 89else 90echo "Found successful release.yml run for HEAD." 91fi 92fi 93 94MAJOR =$( grep "set(GGML_VERSION_MAJOR" " $ REPO_ROOT /ggml/CMakeLists.txt" | sed 's/.*MAJOR \([0-9]*\).*/\1/' ) 95MINOR =$( grep "set(GGML_VERSION_MINOR" " $ REPO_ROOT /ggml/CMakeLists.txt" | sed 's/.*MINOR \([0-9]*\).*/\1/' ) 96PATCH =$( grep "set(GGML_VERSION_PATCH" " $ REPO_ROOT /ggml/CMakeLists.txt" | sed 's/.*PATCH \([0-9]*\).*/\1/' ) 97GGML_VERSION ="v ${ MAJOR } . ${ MINOR } . ${ PATCH } " 98echo "Local ggml version: ${ GGML_VERSION } " 99 100if !git clone--depth 1--branch " ${ GGML_VERSION } " https://github.com/ggml-org/ggml.git upstream-ggml2 > /dev/null;then 101echo "Warning: tag ${ GGML_VERSION } not found in upstream ggml - skipping comparison" 102else 103echo "Comparing local ggml/ src and include with upstream ${ GGML_VERSION } ..." 104DIFF =$( diff -rq " $ REPO_ROOT /ggml/src" upstream-ggml/src 2 >&1 || true ) 105DIFF +=$( diff -rq " $ REPO_ROOT /ggml/include" upstream-ggml/include 2 >&1 || true ) 106DIFF +=$( diff " $ REPO_ROOT /ggml/CMakeLists.txt" upstream-ggml/CMakeLists.txt 2 >&1 || true ) 107rm -rf upstream-ggml 108if [[ -n" $ DIFF " ]];then 109echo "local ggml/ differs from upstream ${ GGML_VERSION } :" 110echo " $ DIFF " 111if [[" $ DRY_RUN " =="true" ]];then 112echo "Warning: would abort release due to ggml mismatch (dry run, continuing)." 113CHECKS_PASSED =false 114else 115echo "Error: ggml must match upstream before making a release." 116exit 1 117fi 118else 119echo "local ggml/ matches upstream ${ GGML_VERSION } " 120fi 121fi 122 123echo "Checking container images for commit ${ SHA } ..." 124NIGHTLY_TAG =" $( git tag --points-at " ${ SHA } " | grep -E '(^|-)b[0-9]+(-[0-9a-f]{7})?$' | head -n 1 || true ) " 125if [[ -z" ${ NIGHTLY_TAG } " ]];then 126echo "Warning: no nightly tag points at ${ SHA } - skipping container image check" 127elif [[ -z" ${ GITHUB_REPOSITORY :-} " ]];then 128echo "Warning: GITHUB_REPOSITORY not set - skipping container image check (local run)" 129else 130CONTAINER_REPO =" ${ GITHUB_REPOSITORY ,,} " # lower-case owner/repo for ghcr.io 131GHCR_TOKEN =" $( curl -fsSL \ 132"https://ghcr.io/token?scope=repository: ${ CONTAINER_REPO } :pull&service=ghcr.io" \ 133| grep -oP '"token"\s*:\s*"\K[^"]+' ) " 134 135VARIANTS =("" "-cuda" "-cuda13" "-vulkan" "-rocm" "-intel" "-musa" "-openvino" ) 136TYPES =("full" "light" "server" ) 137CONTAINER_ERR ="" 138for type in " ${ TYPES [@]} " ;do 139for variant in " ${ VARIANTS [@]} " ;do 140tag =" ${ type }${ variant } - ${ NIGHTLY_TAG } " 141STATUS =" $( curl -s -o /dev/null -w "%{http_code}" \ 142-H "Authorization: Bearer ${ GHCR_TOKEN } " \ 143-H "Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json" \ 144"https://ghcr.io/v2/ ${ CONTAINER_REPO } /manifests/ ${ tag } " ) " 145if [[" ${ STATUS } " =="200" ]];then 146echo " ${ tag } - OK" 147else 148echo " ${ tag } - MISSING" 149CONTAINER_ERR +=" ${ tag } " 150fi 151done 152done 153 154if [[ -n" ${ CONTAINER_ERR } " ]];then 155if [[" $ DRY_RUN " =="true" ]];then 156echo "Warning: missing container images for ${ NIGHTLY_TAG } : ${ CONTAINER_ERR } (dry run, continuing)." 157CHECKS_PASSED =false 158else 159echo "Error: missing container images for ${ NIGHTLY_TAG } : ${ CONTAINER_ERR } " 160echo "The Docker workflow must complete successfully before making a release." 161exit 1 162fi 163else 164echo "All container images found for ${ NIGHTLY_TAG } - OK" 165fi 166fi 167 168if [[ -n" ${ GITHUB_OUTPUT :-} " ]];then 169echo "checks_passed= ${ CHECKS_PASSED } " >> " $ GITHUB_OUTPUT " 170fi