char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Daniel Beveniusscripts : use sed instead of grep for version parsing [no ci] (#28700)41fc7584f

char/aliceai-t5-moe
7.1 KiB170 linesraw
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
19    case "$arg" in
20        --dry-run) DRY_RUN=true ;;
21        *) echo "Unknown argument: $arg"; exit 1 ;;
22    esac
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
31    echo "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
38    echo "Warning: RELEASE_BRANCH not set - skipping commit check (local run)"
39else
40    TIP="origin/${RELEASE_BRANCH}"
41    COMMIT_ERR=""
42    if ! git rev-parse --verify "${TIP}" >/dev/null 2>&1; then
43        COMMIT_ERR="branch ${RELEASE_BRANCH} not found on remote"
44    elif ! git merge-base --is-ancestor "${SHA}" "${TIP}"; then
45        COMMIT_ERR="commit ${SHA} is not part of branch ${RELEASE_BRANCH}"
46    else
47        COMMIT_TS=$(git show -s --format=%ct "${SHA}")
48        TIP_TS=$(git show -s --format=%ct "${TIP}")
49        AGE_DAYS=$(( (TIP_TS - COMMIT_TS) / 86400 ))
50        if (( TIP_TS - COMMIT_TS > 3 * 86400 )); then
51            COMMIT_ERR="commit ${SHA} is ${AGE_DAYS} day(s) older than the HEAD of ${RELEASE_BRANCH} (max: 3)"
52        fi
53    fi
54    if [[ -n "${COMMIT_ERR}" ]]; then
55        if [[ "$DRY_RUN" == "true" ]]; then
56            echo "Warning: ${COMMIT_ERR} (dry run, continuing)."
57            CHECKS_PASSED=false
58        else
59            echo "Error: ${COMMIT_ERR}"
60            exit 1
61        fi
62    else
63        echo "Commit ${SHA} is on branch ${RELEASE_BRANCH} and within 3 days of its HEAD - OK"
64    fi
65fi
66
67echo "Checking that tag ${VERSION} does not already exist..."
68if git ls-remote --tags origin "${VERSION}" | grep -q "${VERSION}"; then
69    echo "Error: tag ${VERSION} already exists on remote"
70    exit 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
76    echo "Warning: GITHUB_REPOSITORY not set - skipping CI check (local run)"
77else
78    RUNS=$(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")
80    if [[ "$RUNS" -eq 0 ]]; then
81        if [[ "$DRY_RUN" == "true" ]]; then
82            echo "Warning: no successful release.yml run found for HEAD (${SHA}) (dry run, continuing)."
83            CHECKS_PASSED=false
84        else
85            echo "Error: no successful release.yml run found for HEAD (${SHA})"
86            echo "The nightly build must complete successfully before making a release."
87            exit 1
88        fi
89    else
90        echo "Found successful release.yml run for HEAD."
91    fi
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-ggml 2>/dev/null; then
101    echo "Warning: tag ${GGML_VERSION} not found in upstream ggml - skipping comparison"
102else
103    echo "Comparing local ggml/ src and include with upstream ${GGML_VERSION}..."
104    DIFF=$(diff -rq "$REPO_ROOT/ggml/src"          upstream-ggml/src          2>&1 || true)
105    DIFF+=$(diff -rq "$REPO_ROOT/ggml/include"     upstream-ggml/include      2>&1 || true)
106    DIFF+=$(diff     "$REPO_ROOT/ggml/CMakeLists.txt" upstream-ggml/CMakeLists.txt 2>&1 || true)
107    rm -rf upstream-ggml
108    if [[ -n "$DIFF" ]]; then
109        echo "local ggml/ differs from upstream ${GGML_VERSION}:"
110        echo "$DIFF"
111        if [[ "$DRY_RUN" == "true" ]]; then
112            echo "Warning: would abort release due to ggml mismatch (dry run, continuing)."
113            CHECKS_PASSED=false
114        else
115            echo "Error: ggml must match upstream before making a release."
116            exit 1
117        fi
118    else
119        echo "local ggml/ matches upstream ${GGML_VERSION}"
120    fi
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
126    echo "Warning: no nightly tag points at ${SHA} - skipping container image check"
127elif [[ -z "${GITHUB_REPOSITORY:-}" ]]; then
128    echo "Warning: GITHUB_REPOSITORY not set - skipping container image check (local run)"
129else
130    CONTAINER_REPO="${GITHUB_REPOSITORY,,}"  # lower-case owner/repo for ghcr.io
131    GHCR_TOKEN="$(curl -fsSL \
132        "https://ghcr.io/token?scope=repository:${CONTAINER_REPO}:pull&service=ghcr.io" \
133        | grep -oP '"token"\s*:\s*"\K[^"]+')"
134
135    VARIANTS=("" "-cuda" "-cuda13" "-vulkan" "-rocm" "-intel" "-musa" "-openvino")
136    TYPES=("full" "light" "server")
137    CONTAINER_ERR=""
138    for type in "${TYPES[@]}"; do
139        for variant in "${VARIANTS[@]}"; do
140            tag="${type}${variant}-${NIGHTLY_TAG}"
141            STATUS="$(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}")"
145            if [[ "${STATUS}" == "200" ]]; then
146                echo "  ${tag} - OK"
147            else
148                echo "  ${tag} - MISSING"
149                CONTAINER_ERR+=" ${tag}"
150            fi
151        done
152    done
153
154    if [[ -n "${CONTAINER_ERR}" ]]; then
155        if [[ "$DRY_RUN" == "true" ]]; then
156            echo "Warning: missing container images for ${NIGHTLY_TAG}:${CONTAINER_ERR} (dry run, continuing)."
157            CHECKS_PASSED=false
158        else
159            echo "Error: missing container images for ${NIGHTLY_TAG}:${CONTAINER_ERR}"
160            echo "The Docker workflow must complete successfully before making a release."
161            exit 1
162        fi
163    else
164        echo "All container images found for ${NIGHTLY_TAG} - OK"
165    fi
166fi
167
168if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
169    echo "checks_passed=${CHECKS_PASSED}" >> "$GITHUB_OUTPUT"
170fi