Skip to content

Commit 7e2749d

Browse files
committed
[Amir] Enhance BodhiApp release management with new Makefile and documentation
- Introduced Makefile.bodhiapp for managing llama-server binary releases and Docker base images. - Added functions for git branch validation, tag management, and version creation based on git commits. - Created README-bodhiapp.md detailing the release process, versioning strategy, and available make targets. - Updated llama-server.yml workflow to support version extraction from tags and manual triggers. - Commented out deprecated Makefile sections to maintain compatibility with the CMake build system.
1 parent cd46a68 commit 7e2749d

File tree

4 files changed

+434
-10
lines changed

4 files changed

+434
-10
lines changed

.github/workflows/llama-server.yml

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: llama-server standalone
22

33
on:
4+
push:
5+
tags:
6+
- 'llama-server/v*' # Only triggered by version tags like llama-server/v2508201420-abc1234
47
workflow_dispatch: # allows manual triggering
58
inputs:
69
create_release:
@@ -21,7 +24,43 @@ env:
2124
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
2225

2326
jobs:
27+
# Extract version information from tag (similar to base-images pattern)
28+
extract-version:
29+
runs-on: ubuntu-latest
30+
outputs:
31+
version: ${{ steps.version.outputs.version }}
32+
commit_hash: ${{ steps.version.outputs.commit_hash }}
33+
timestamp: ${{ steps.version.outputs.timestamp }}
34+
readable_date: ${{ steps.version.outputs.readable_date }}
35+
triggered_by_tag: ${{ steps.version.outputs.triggered_by_tag }}
36+
steps:
37+
- name: Extract version information from tag
38+
id: version
39+
run: |
40+
# Check if triggered by tag or manual dispatch
41+
if [[ $GITHUB_REF == refs/tags/llama-server/v* ]]; then
42+
# Extract version from tag (llama-server/v2508201420-abc1234 -> 2508201420-abc1234)
43+
VERSION=${GITHUB_REF#refs/tags/llama-server/v}
44+
TIMESTAMP=$(echo "$VERSION" | cut -d'-' -f1)
45+
COMMIT_HASH=$(echo "$VERSION" | cut -d'-' -f2)
46+
READABLE_DATE=$(date -d "20$TIMESTAMP" "+%Y-%m-%d %H:%M" 2>/dev/null || echo "Invalid timestamp")
47+
TRIGGERED_BY_TAG="true"
48+
else
49+
# Manual trigger - create version from current commit
50+
COMMIT_HASH="$(git rev-parse --short=7 HEAD)"
51+
TIMESTAMP="$(date +%y%m%d%H%M)"
52+
VERSION="${TIMESTAMP}-${COMMIT_HASH}"
53+
READABLE_DATE="$(date '+%Y-%m-%d %H:%M')"
54+
TRIGGERED_BY_TAG="false"
55+
fi
56+
echo "version=$VERSION" >> $GITHUB_OUTPUT
57+
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
58+
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
59+
echo "readable_date=$READABLE_DATE" >> $GITHUB_OUTPUT
60+
echo "triggered_by_tag=$TRIGGERED_BY_TAG" >> $GITHUB_OUTPUT
61+
echo "Extracted version: $VERSION (Date: $READABLE_DATE, Commit: $COMMIT_HASH, Tag: $TRIGGERED_BY_TAG)"
2462
macos-arm64:
63+
needs: extract-version
2564
runs-on: macos-14
2665
strategy:
2766
matrix:
@@ -63,6 +102,7 @@ jobs:
63102
path: build/bin/llama-server
64103

65104
ubuntu-cpu:
105+
needs: extract-version
66106
runs-on: ubuntu-22.04
67107
steps:
68108
- name: Clone
@@ -91,6 +131,7 @@ jobs:
91131
path: build/bin/llama-server
92132

93133
ubuntu-arm64:
134+
needs: extract-version
94135
runs-on: ubuntu-22.04
95136
steps:
96137
- name: Clone
@@ -398,6 +439,7 @@ jobs:
398439
path: build/bin/Release/llama-server.exe
399440

400441
windows-cpu:
442+
needs: extract-version
401443
runs-on: windows-latest
402444

403445
env:
@@ -654,6 +696,7 @@ jobs:
654696
if: always() || github.event.inputs.create_release == 'true'
655697
runs-on: ubuntu-latest
656698
needs:
699+
- extract-version
657700
- macos-arm64
658701
- ubuntu-cpu
659702
- ubuntu-arm64
@@ -679,13 +722,19 @@ jobs:
679722
id: tag
680723
shell: bash
681724
run: |
682-
BUILD_NUMBER="$(git rev-list --count HEAD)"
683-
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
684-
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
685-
echo "name=server-b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
725+
if [[ "${{ needs.extract-version.outputs.triggered_by_tag }}" == "true" ]]; then
726+
# Use version from tag
727+
echo "name=server-${{ needs.extract-version.outputs.version }}" >> $GITHUB_OUTPUT
686728
else
687-
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
688-
echo "name=server-${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
729+
# Manual trigger - use legacy naming for compatibility
730+
BUILD_NUMBER="$(git rev-list --count HEAD)"
731+
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
732+
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
733+
echo "name=server-b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
734+
else
735+
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
736+
echo "name=server-${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
737+
fi
689738
fi
690739
691740
- name: Download artifacts

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
ifndef LLAMA_MAKEFILE
2-
$(error The Makefile build is deprecated. Use the CMake build instead. For more details, see https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md)
3-
endif
1+
# ifndef LLAMA_MAKEFILE
2+
# $(error The Makefile build is deprecated. Use the CMake build instead. For more details, see https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md)
3+
# endif
44

55
# Define the default target now so that it is always the first target
66
BUILD_TARGETS = \
@@ -211,7 +211,7 @@ ifdef GGML_VULKAN
211211
BUILD_TARGETS += vulkan-shaders-gen
212212
endif
213213

214-
default: $(BUILD_TARGETS) $(LEGACY_TARGETS_BUILD)
214+
# default: $(BUILD_TARGETS) $(LEGACY_TARGETS_BUILD)
215215

216216
test: $(TEST_TARGETS)
217217
@failures=0; \
@@ -1606,3 +1606,6 @@ ifneq (,$(wildcard embedding))
16061606
@echo " Remove the 'embedding' binary to remove this warning."
16071607
@echo "#########"
16081608
endif
1609+
1610+
# BodhiApp custom targets - include our Makefile
1611+
-include Makefile.bodhiapp

Makefile.bodhiapp

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# BodhiApp Release Management
2+
# This file contains release logic for llama-server binaries and delegation to base-images
3+
# It keeps the original Makefile clean while providing standardized release commands
4+
5+
.PHONY: release-server release-base-images help-bodhiapp show-server-git-info validate-server-release clean-server-release
6+
7+
# Function to check git branch status - borrowed from base-images/Makefile
8+
define check_git_branch
9+
@CURRENT_BRANCH=$$(git branch --show-current) && \
10+
if [ "$$CURRENT_BRANCH" != "master" ]; then \
11+
read -p "Warning: You are not on master branch (current: $$CURRENT_BRANCH). Continue? [y/N] " confirm && \
12+
if [ "$$confirm" != "y" ]; then \
13+
echo "Aborting release." && exit 1; \
14+
fi \
15+
fi && \
16+
echo "Fetching latest changes from remote..." && \
17+
git fetch origin master && \
18+
LOCAL_HEAD=$$(git rev-parse HEAD) && \
19+
REMOTE_HEAD=$$(git rev-parse origin/master) && \
20+
if [ "$$LOCAL_HEAD" != "$$REMOTE_HEAD" ]; then \
21+
echo "Warning: Your local master branch is different from origin/master" && \
22+
echo "Local: $$LOCAL_HEAD" && \
23+
echo "Remote: $$REMOTE_HEAD" && \
24+
read -p "Continue anyway? [y/N] " confirm && \
25+
if [ "$$confirm" != "y" ]; then \
26+
echo "Aborting release." && exit 1; \
27+
fi \
28+
fi
29+
endef
30+
31+
# Function to safely delete existing tag - borrowed from base-images/Makefile
32+
define delete_tag_if_exists
33+
echo "Checking for existing tag $(1)..." && \
34+
if git rev-parse "$(1)" >/dev/null 2>&1; then \
35+
read -p "Tag $(1) already exists. Delete and recreate? [y/N] " confirm && \
36+
if [ "$$confirm" = "y" ]; then \
37+
echo "Deleting existing tag $(1)..." && \
38+
git tag -d "$(1)" 2>/dev/null || true && \
39+
git push --delete origin "$(1)" 2>/dev/null || true; \
40+
else \
41+
echo "Aborting release." && exit 1; \
42+
fi \
43+
fi
44+
endef
45+
46+
# Function to create timestamp-based version from git commit
47+
define create_version_from_git
48+
COMMIT_TIMESTAMP=$$(git log -1 --format=%ct) && \
49+
COMMIT_HASH=$$(git rev-parse --short=7 HEAD) && \
50+
if [ "$$(uname)" = "Darwin" ]; then \
51+
VERSION="$$(date -r $$COMMIT_TIMESTAMP +%y%m%d%H%M)-$$COMMIT_HASH"; \
52+
else \
53+
VERSION="$$(date -d @$$COMMIT_TIMESTAMP +%y%m%d%H%M)-$$COMMIT_HASH"; \
54+
fi && \
55+
echo "$$VERSION"
56+
endef
57+
58+
# Function to validate release prerequisites
59+
define validate_release_prerequisites
60+
echo "Validating release prerequisites..." && \
61+
if ! command -v git >/dev/null 2>&1; then \
62+
echo "Error: git is required but not installed" && exit 1; \
63+
fi && \
64+
if ! git rev-parse --git-dir >/dev/null 2>&1; then \
65+
echo "Error: Not in a git repository" && exit 1; \
66+
fi && \
67+
if [ ! -f ".github/workflows/llama-server.yml" ]; then \
68+
echo "Error: llama-server.yml workflow not found" && exit 1; \
69+
fi && \
70+
echo "Prerequisites validated successfully"
71+
endef
72+
73+
# Release binary builds (all platforms)
74+
release-server: ## Release llama-server binaries (creates llama-server/v{timestamp}-{hash} tag)
75+
@echo "Preparing to release llama-server binaries..."
76+
@$(call validate_release_prerequisites)
77+
$(call check_git_branch)
78+
@echo "Creating version from current git commit..."
79+
@VERSION=$$($(call create_version_from_git)) && \
80+
TAG_NAME="llama-server/v$$VERSION" && \
81+
echo "New version from git commit: $$VERSION" && \
82+
echo "Tag to create: $$TAG_NAME" && \
83+
$(call delete_tag_if_exists,$$TAG_NAME) && \
84+
echo "Creating llama-server release tag $$TAG_NAME..." && \
85+
git tag "$$TAG_NAME" && \
86+
git push origin "$$TAG_NAME" && \
87+
echo "llama-server release tag $$TAG_NAME pushed. GitHub workflow will handle the binary build and release."
88+
89+
# Release Docker base images (all variants)
90+
release-base-images: ## Release Docker base images (creates base-images/v{timestamp}-{hash} tag)
91+
@echo "Starting base images release..."
92+
@$(MAKE) -C .devops/base-images release-base-images
93+
94+
show-server-git-info: ## Show current git commit information for llama-server version generation
95+
@echo "=== Git Information for llama-server Version Generation ==="
96+
@COMMIT_TIMESTAMP=$$(git log -1 --format=%ct) && \
97+
COMMIT_HASH=$$(git rev-parse --short=7 HEAD) && \
98+
if [ "$$(uname)" = "Darwin" ]; then \
99+
READABLE_DATE=$$(date -r $$COMMIT_TIMESTAMP "+%Y-%m-%d %H:%M:%S") && \
100+
VERSION="$$(date -r $$COMMIT_TIMESTAMP +%y%m%d%H%M)-$$COMMIT_HASH"; \
101+
else \
102+
READABLE_DATE=$$(date -d @$$COMMIT_TIMESTAMP "+%Y-%m-%d %H:%M:%S") && \
103+
VERSION="$$(date -d @$$COMMIT_TIMESTAMP +%y%m%d%H%M)-$$COMMIT_HASH"; \
104+
fi && \
105+
echo "Current commit: $$COMMIT_HASH" && \
106+
echo "Commit timestamp: $$COMMIT_TIMESTAMP" && \
107+
echo "Readable date: $$READABLE_DATE" && \
108+
echo "Generated version: $$VERSION" && \
109+
echo "Tag would be: llama-server/v$$VERSION"
110+
@echo "============================================="
111+
112+
validate-server-release: ## Validate prerequisites for llama-server release
113+
@$(call validate_release_prerequisites)
114+
@echo "llama-server release validation completed successfully"
115+
116+
clean-server-release: ## Remove local llama-server release tags (interactive)
117+
@echo "Cleaning up local llama-server tags..."
118+
@git tag -l "llama-server/v*" | while read tag; do \
119+
read -p "Delete local tag $$tag? [y/N] " confirm && \
120+
if [ "$$confirm" = "y" ]; then \
121+
git tag -d "$$tag" && echo "Deleted: $$tag"; \
122+
fi \
123+
done
124+
125+
# Show BodhiApp-specific targets
126+
help-bodhiapp: ## Show BodhiApp release targets
127+
@echo ''
128+
@echo 'BodhiApp Release Targets:'
129+
@echo ' make release-server - Release llama-server binaries for all platforms'
130+
@echo ' make release-base-images - Release Docker base images for all variants'
131+
@echo ' make show-server-git-info - Show llama-server version info'
132+
@echo ' make validate-server-release - Validate llama-server release prerequisites'
133+
@echo ' make clean-server-release - Clean local llama-server tags'
134+
@echo ' make help-bodhiapp - Show this help message'
135+
@echo ''
136+
@echo 'For more details, see README-bodhiapp.md'

0 commit comments

Comments
 (0)