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