ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / scripts / make-release-checks.sh
| 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) |
| 11 | set -euo pipefail |
| 12 | |
| 13 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 14 | REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 15 | |
| 16 | DRY_RUN=false |
| 17 | CHECKS_PASSED=true |
| 18 | for arg in "$@"; do |
| 19 | case "$arg" in |
| 20 | --dry-run) DRY_RUN=true ;; |
| 21 | *) echo "Unknown argument: $arg"; exit 1 ;; |
| 22 | esac |
| 23 | done |
| 24 | |
| 25 | MAJOR=$(sed -n 's/^set(GGML_VERSION_MAJOR \([0-9][0-9]*\)).*/\1/p' "$REPO_ROOT/CMakeLists.txt") |
| 26 | MINOR=$(sed -n 's/^set(GGML_VERSION_MINOR \([0-9][0-9]*\)).*/\1/p' "$REPO_ROOT/CMakeLists.txt") |
| 27 | PATCH=$(sed -n 's/^set(GGML_VERSION_PATCH \([0-9][0-9]*\)).*/\1/p' "$REPO_ROOT/CMakeLists.txt") |
| 28 | VERSION="v${MAJOR}.${MINOR}.${PATCH}" |
| 29 | echo "Determined version: ${VERSION}" |
| 30 | if [[ -n "${GITHUB_OUTPUT:-}" ]]; then |
| 31 | echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 32 | fi |
| 33 | |
| 34 | SHA=$(git rev-parse HEAD) |
| 35 | |
| 36 | echo "Checking that commit ${SHA} belongs to the release branch..." |
| 37 | if [[ -z "${RELEASE_BRANCH:-}" ]]; then |
| 38 | echo "Warning: RELEASE_BRANCH not set - skipping commit check (local run)" |
| 39 | else |
| 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 |
| 65 | fi |
| 66 | |
| 67 | echo "Checking that tag ${VERSION} does not already exist..." |
| 68 | if git ls-remote --tags origin "${VERSION}" | grep -q "${VERSION}"; then |
| 69 | echo "Error: tag ${VERSION} already exists on remote" |
| 70 | exit 1 |
| 71 | fi |
| 72 | echo "Tag ${VERSION} does not exist on remote - OK" |
| 73 | |
| 74 | echo "Checking release.yml status for commit ${SHA}..." |
| 75 | if [[ -z "${GITHUB_REPOSITORY:-}" ]]; then |
| 76 | echo "Warning: GITHUB_REPOSITORY not set - skipping CI check (local run)" |
| 77 | else |
| 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 release workflow 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 |
| 92 | fi |
| 93 | |
| 94 | echo "Checking API/ABI compatibility..." |
| 95 | set +e |
| 96 | bash "$SCRIPT_DIR/check-release-apiabi.sh" |
| 97 | APIABI_RESULT=$? |
| 98 | set -e |
| 99 | if [[ $APIABI_RESULT -ne 0 ]]; then |
| 100 | if [[ "$DRY_RUN" == "true" ]]; then |
| 101 | echo "Warning: API/ABI check found backwards-incompatible changes (dry run, continuing)." |
| 102 | CHECKS_PASSED=false |
| 103 | else |
| 104 | echo "Error: API/ABI check found backwards-incompatible changes." |
| 105 | exit 1 |
| 106 | fi |
| 107 | else |
| 108 | echo "API/ABI compatibility check passed - OK" |
| 109 | fi |
| 110 | |
| 111 | if [[ -n "${GITHUB_OUTPUT:-}" ]]; then |
| 112 | echo "checks_passed=${CHECKS_PASSED}" >> "$GITHUB_OUTPUT" |
| 113 | fi |