char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
c4b0225d8
char/aliceai-t5-moe
1#!/bin/bash 2# 3# Release preparation script for llama.cpp. 4# 5# Bumps the version in CMakeLists.txt on a release candidate branch. 6# The branch should then be pushed and a PR created, reviewed, and 7# merged. After the PR is merged and the build-cpu workflow has 8# completed successfully, the release is finalized by the make-release 9# workflow (.github/workflows/make-release.yml), which creates the tag. 10# 11# Usage: 12# ./scripts/release.sh [major|minor|patch] [--dry-run] 13# 14# Example: 15# $ ./scripts/release.sh minor 16# 17# The script: 18# 1. Creates a release candidate branch (llama-rc-v<major>.<minor>.<patch>) 19# 2. Bumps the version in CMakeLists.txt 20# 3. Commits the version bump 21# 22 23set -e 24 25if [ ! -f"CMakeLists.txt" ] || [ ! -d"scripts" ];then 26echo "Error: Must be run from llama.cpp root directory" 27exit 1 28fi 29 30# Parse command line arguments 31VERSION_TYPE ="" 32DRY_RUN =false 33 34for arg in " $ @" ;do 35case $ arg in 36 --dry-run) 37DRY_RUN =true 38 ;; 39 major| minor| patch) 40VERSION_TYPE =" $ arg " 41 ;; 42 *) 43echo "Error: Unknown argument ' $ arg '" 44echo "Usage: $ 0 [major|minor|patch] [--dry-run]" 45exit 1 46 ;; 47esac 48done 49 50# Default to patch if no version type specified 51VERSION_TYPE =" ${ VERSION_TYPE :-patch} " 52 53# Common validation functions 54check_git_status () { 55# Check for uncommitted changes (skip in dry-run) 56if [" $ DRY_RUN " = false ]&& !git diff-index--quiet HEAD-- ;then 57echo "Error: You have uncommitted changes. Please commit or stash them first." 58exit 1 59fi 60} 61 62check_master_branch () { 63# Ensure we're on master branch 64CURRENT_BRANCH =$( git branch --show-current ) 65if [" $ CURRENT_BRANCH " !="master" ];then 66if [" $ DRY_RUN " = true ];then 67echo "[dry run] Warning: Not on master branch (currently on: $ CURRENT_BRANCH ). Continuing with dry-run..." 68echo "" 69else 70echo "Error: Must be on master branch. Currently on: $ CURRENT_BRANCH " 71exit 1 72fi 73fi 74} 75 76check_master_up_to_date () { 77# Check if we have the latest from master (skip in dry-run) 78if [" $ DRY_RUN " = false ];then 79echo "Checking if local master is up-to-date with remote..." 80git fetch origin master 81LOCAL =$( git rev-parse HEAD) 82REMOTE =$( git rev-parse origin/master) 83 84if [" $ LOCAL " !=" $ REMOTE " ];then 85echo "Error: Your local master branch is not up-to-date with origin/master." 86echo "Please run 'git pull origin master' first." 87exit 1 88fi 89echo "✓ Local master is up-to-date with remote" 90echo "" 91elif [" $( git branch --show-current ) " ="master" ];then 92echo "[dry run] Warning: Dry-run mode - not checking if master is up-to-date with remote" 93echo "" 94fi 95} 96 97# In-place sed that works on both GNU (Linux) and BSD (macOS) sed 98sed_inplace () { 99if sed --version > /dev/null2 >&1;then 100sed -i " $ @" 101else 102sed -i '' " $ @" 103fi 104} 105 106prepare_release () { 107if [" $ DRY_RUN " = true ];then 108echo "[dry-run] Preparing release (no changes will be made)" 109else 110echo "Starting release preparation..." 111fi 112echo "" 113 114check_git_status 115check_master_branch 116check_master_up_to_date 117 118# Extract current version from CMakeLists.txt 119echo "Step 1: Reading current version..." 120MAJOR =$( grep "set(LLAMA_VERSION_MAJOR" CMakeLists.txt | sed 's/.*MAJOR \([0-9]*\).*/\1/' ) 121MINOR =$( grep "set(LLAMA_VERSION_MINOR" CMakeLists.txt | sed 's/.*MINOR \([0-9]*\).*/\1/' ) 122PATCH =$( grep "set(LLAMA_VERSION_PATCH" CMakeLists.txt | sed 's/.*PATCH \([0-9]*\).*/\1/' ) 123 124echo "Current version: $ MAJOR . $ MINOR . $ PATCH " 125 126# Calculate new version 127case $ VERSION_TYPE in 128 major) 129NEW_MAJOR =$((MAJOR + 1)) 130NEW_MINOR =0 131NEW_PATCH =0 132 ;; 133 minor) 134NEW_MAJOR =$ MAJOR 135NEW_MINOR =$((MINOR + 1)) 136NEW_PATCH =0 137 ;; 138 patch) 139NEW_MAJOR =$ MAJOR 140NEW_MINOR =$ MINOR 141NEW_PATCH =$((PATCH + 1)) 142 ;; 143esac 144 145NEW_VERSION =" $ NEW_MAJOR . $ NEW_MINOR . $ NEW_PATCH " 146RC_BRANCH ="llama-rc-v $ NEW_VERSION " 147echo "New release version: $ NEW_VERSION " 148echo "Release candidate branch: $ RC_BRANCH " 149echo "" 150 151# Create release candidate branch 152echo "Step 2: Creating release candidate branch..." 153if [" $ DRY_RUN " = true ];then 154echo " [dry-run] Would create branch: $ RC_BRANCH " 155else 156git checkout-b " $ RC_BRANCH " 157echo "✓ Created and switched to branch: $ RC_BRANCH " 158fi 159echo "" 160 161# Update CMakeLists.txt for release 162echo "Step 3: Updating version in CMakeLists.txt..." 163if [" $ DRY_RUN " = true ];then 164echo " [dry-run] Would update LLAMA_VERSION_MAJOR to $ NEW_MAJOR " 165echo " [dry-run] Would update LLAMA_VERSION_MINOR to $ NEW_MINOR " 166echo " [dry-run] Would update LLAMA_VERSION_PATCH to $ NEW_PATCH " 167else 168sed_inplace -e "s/set(LLAMA_VERSION_MAJOR [0-9]*)/set(LLAMA_VERSION_MAJOR $ NEW_MAJOR )/" CMakeLists.txt 169sed_inplace -e "s/set(LLAMA_VERSION_MINOR [0-9]*)/set(LLAMA_VERSION_MINOR $ NEW_MINOR )/" CMakeLists.txt 170sed_inplace -e "s/set(LLAMA_VERSION_PATCH [0-9]*)/set(LLAMA_VERSION_PATCH $ NEW_PATCH )/" CMakeLists.txt 171fi 172echo "" 173 174# Commit version bump 175echo "Step 4: Committing version bump..." 176if [" $ DRY_RUN " = true ];then 177echo " [dry-run] Would commit: 'llama.cpp : bump version to $ NEW_VERSION '" 178else 179git add CMakeLists.txt 180git commit-m "llama.cpp : bump version to $ NEW_VERSION " 181fi 182echo "" 183 184echo "" 185if [" $ DRY_RUN " = true ];then 186echo "[dry-run] Summary (no changes were made):" 187echo " • Would have created branch: $ RC_BRANCH " 188echo " • Would have updated version to: $ NEW_VERSION " 189else 190echo "Release preparation completed!" 191echo "Summary:" 192echo " • Created branch: $ RC_BRANCH " 193echo " • Updated version to: $ NEW_VERSION " 194echo "" 195echo "Next steps:" 196echo " • Push branch to remote: git push origin $ RC_BRANCH " 197echo " • Create a Pull Request from $ RC_BRANCH to master" 198echo " • After the PR is merged and the build-cpu workflow has passed," 199echo " create the release with the make-release workflow" 200echo " (.github/workflows/make-release.yml)" 201fi 202} 203 204prepare_release