Skip to content

Commit f7a7583

Browse files
committed
[Amir] Update Makefile and add BodhiApp release management files
- Commented out deprecated Makefile build error message and default target for clarity. - Introduced Makefile.bodhiapp for managing BodhiApp-specific release processes, including commands for binary and Docker image releases. - Added README-bodhiapp.md to document the BodhiApp release management workflow and versioning strategy. - Updated GitHub Actions workflow for llama-server to support version extraction from tags and manual triggers.
1 parent cd46a68 commit f7a7583

File tree

4 files changed

+612
-10
lines changed

4 files changed

+612
-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: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
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 sync-upstream sync-upstream-check
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 date-based version (YYYYMMDD format)
47+
define create_version_from_git
48+
if [ "$$(uname)" = "Darwin" ]; then \
49+
VERSION="$$(date +%Y%m%d)"; \
50+
else \
51+
VERSION="$$(date +%Y%m%d)"; \
52+
fi && \
53+
echo "$$VERSION"
54+
endef
55+
56+
# Function to validate release prerequisites
57+
define validate_release_prerequisites
58+
echo "Validating release prerequisites..." && \
59+
if ! command -v git >/dev/null 2>&1; then \
60+
echo "Error: git is required but not installed" && exit 1; \
61+
fi && \
62+
if ! git rev-parse --git-dir >/dev/null 2>&1; then \
63+
echo "Error: Not in a git repository" && exit 1; \
64+
fi && \
65+
if [ ! -f ".github/workflows/llama-server.yml" ]; then \
66+
echo "Error: llama-server.yml workflow not found" && exit 1; \
67+
fi && \
68+
if ! git diff-index --quiet HEAD --; then \
69+
echo "Error: Working directory has uncommitted changes. Please commit or reset changes before release." && exit 1; \
70+
fi && \
71+
echo "Prerequisites validated successfully"
72+
endef
73+
74+
# Function to validate upstream sync prerequisites
75+
define validate_sync_prerequisites
76+
echo "Validating sync prerequisites..." && \
77+
if ! command -v git >/dev/null 2>&1; then \
78+
echo "Error: git is required but not installed" && exit 1; \
79+
fi && \
80+
if ! git rev-parse --git-dir >/dev/null 2>&1; then \
81+
echo "Error: Not in a git repository" && exit 1; \
82+
fi && \
83+
if ! git remote get-url gg >/dev/null 2>&1; then \
84+
echo "Error: 'gg' remote not configured. Please add upstream remote as 'gg'" && exit 1; \
85+
fi && \
86+
if ! git diff-index --quiet HEAD --; then \
87+
echo "Error: Working directory has uncommitted changes. Please commit or reset changes before sync." && exit 1; \
88+
fi && \
89+
CURRENT_BRANCH=$$(git branch --show-current) && \
90+
if [ "$$CURRENT_BRANCH" != "master" ]; then \
91+
echo "Error: Must be on master branch for sync. Current branch: $$CURRENT_BRANCH" && exit 1; \
92+
fi && \
93+
echo "Sync prerequisites validated successfully"
94+
endef
95+
96+
# Release binary builds (all platforms) - creates both branch and tag
97+
release-server: ## Release llama-server binaries (creates bodhiapp_YYYYMMDD branch + llama-server/vYYYYMMDD tag)
98+
@echo "Preparing to release llama-server binaries..."
99+
@$(call validate_release_prerequisites)
100+
$(call check_git_branch)
101+
@echo "Creating version from current date..."
102+
@VERSION=$$($(call create_version_from_git)) && \
103+
BRANCH_NAME="bodhiapp_$$VERSION" && \
104+
TAG_NAME="llama-server/v$$VERSION" && \
105+
echo "Version: $$VERSION" && \
106+
echo "Release branch: $$BRANCH_NAME" && \
107+
echo "Release tag: $$TAG_NAME" && \
108+
$(call delete_tag_if_exists,$$TAG_NAME) && \
109+
echo "Creating release branch $$BRANCH_NAME..." && \
110+
if git show-ref --verify --quiet refs/heads/$$BRANCH_NAME; then \
111+
echo "Branch $$BRANCH_NAME already exists, switching to it..." && \
112+
git checkout $$BRANCH_NAME; \
113+
else \
114+
git checkout -b $$BRANCH_NAME; \
115+
fi && \
116+
echo "Pushing release branch to origin..." && \
117+
git push origin $$BRANCH_NAME && \
118+
echo "Creating and pushing release tag $$TAG_NAME..." && \
119+
git tag "$$TAG_NAME" && \
120+
git push origin "$$TAG_NAME" && \
121+
echo "Switching back to master..." && \
122+
git checkout master && \
123+
echo "Release created successfully:" && \
124+
echo " Branch: $$BRANCH_NAME (for support/hotfixes)" && \
125+
echo " Tag: $$TAG_NAME (triggers CI/CD)" && \
126+
echo " GitHub workflow will handle the binary build and release."
127+
128+
# Release Docker base images (all variants) - creates both branch and tag
129+
release-base-images: ## Release Docker base images (creates bodhiapp_YYYYMMDD branch + base-images/vYYYYMMDD tag)
130+
@echo "Preparing to release Docker base images..."
131+
@$(call validate_release_prerequisites)
132+
$(call check_git_branch)
133+
@echo "Creating version from current date..."
134+
@VERSION=$$($(call create_version_from_git)) && \
135+
BRANCH_NAME="bodhiapp_$$VERSION" && \
136+
TAG_NAME="base-images/v$$VERSION" && \
137+
echo "Version: $$VERSION" && \
138+
echo "Release branch: $$BRANCH_NAME" && \
139+
echo "Release tag: $$TAG_NAME" && \
140+
$(call delete_tag_if_exists,$$TAG_NAME) && \
141+
echo "Creating release branch $$BRANCH_NAME..." && \
142+
if git show-ref --verify --quiet refs/heads/$$BRANCH_NAME; then \
143+
echo "Branch $$BRANCH_NAME already exists, switching to it..." && \
144+
git checkout $$BRANCH_NAME; \
145+
else \
146+
git checkout -b $$BRANCH_NAME; \
147+
fi && \
148+
echo "Pushing release branch to origin..." && \
149+
git push origin $$BRANCH_NAME && \
150+
echo "Creating and pushing release tag $$TAG_NAME..." && \
151+
git tag "$$TAG_NAME" && \
152+
git push origin "$$TAG_NAME" && \
153+
echo "Switching back to master..." && \
154+
git checkout master && \
155+
echo "Release created successfully:" && \
156+
echo " Branch: $$BRANCH_NAME (for support/hotfixes)" && \
157+
echo " Tag: $$TAG_NAME (triggers CI/CD)" && \
158+
echo " GitHub workflow will handle the Docker image build and release."
159+
160+
show-server-git-info: ## Show current git commit information for llama-server version generation
161+
@echo "=== Git Information for llama-server Version Generation ==="
162+
@COMMIT_HASH=$$(git rev-parse --short=7 HEAD) && \
163+
VERSION=$$($(call create_version_from_git)) && \
164+
BRANCH_NAME="bodhiapp_$$VERSION" && \
165+
TAG_NAME="llama-server/v$$VERSION" && \
166+
echo "Current commit: $$COMMIT_HASH" && \
167+
echo "Current date: $$(date '+%Y-%m-%d %H:%M:%S')" && \
168+
echo "Generated version: $$VERSION" && \
169+
echo "Release branch: $$BRANCH_NAME" && \
170+
echo "Release tag: $$TAG_NAME"
171+
@echo "============================================="
172+
173+
validate-server-release: ## Validate prerequisites for llama-server release
174+
@$(call validate_release_prerequisites)
175+
@echo "llama-server release validation completed successfully"
176+
177+
clean-server-release: ## Remove local llama-server release tags (interactive)
178+
@echo "Cleaning up local llama-server tags..."
179+
@git tag -l "llama-server/v*" | while read tag; do \
180+
read -p "Delete local tag $$tag? [y/N] " confirm && \
181+
if [ "$$confirm" = "y" ]; then \
182+
git tag -d "$$tag" && echo "Deleted: $$tag"; \
183+
fi \
184+
done
185+
186+
sync-upstream-check: ## Check what would be synced from upstream (dry-run)
187+
@echo "=== Upstream Sync Check ==="
188+
@$(call validate_sync_prerequisites)
189+
@echo "Fetching latest from upstream (gg)..."
190+
@git fetch gg
191+
@echo ""
192+
@echo "Commits in upstream (gg/master) not in our master:"
193+
@git log --oneline master..gg/master | head -10 || echo " (none - we are up to date)"
194+
@echo ""
195+
@echo "Our commits that will be rebased on top of upstream:"
196+
@git log --oneline --grep="\[Amir\]" gg/master..master || echo " (none - no custom commits)"
197+
@echo ""
198+
@echo "Total upstream commits ahead: $$(git rev-list --count master..gg/master)"
199+
@echo "Total our commits to rebase: $$(git rev-list --count gg/master..master)"
200+
@echo ""
201+
@echo "To proceed with sync: make sync-upstream"
202+
203+
sync-upstream: ## Fetch upstream and rebase master preserving our changes (does not push)
204+
@echo "=== Syncing with Upstream ==="
205+
@$(call validate_sync_prerequisites)
206+
@echo "Fetching latest from upstream (gg)..."
207+
@git fetch gg
208+
@echo "Rebasing master onto gg/master..."
209+
@if git rebase gg/master; then \
210+
echo "Rebase completed successfully!"; \
211+
echo ""; \
212+
echo "Summary:"; \
213+
echo " Master branch rebased onto latest upstream"; \
214+
echo " Your changes preserved on top"; \
215+
echo ""; \
216+
echo "Next steps:"; \
217+
echo " 1. Review the rebased commits"; \
218+
echo " 2. Test your changes"; \
219+
echo " 3. Push to origin when ready: git push origin master --force-with-lease"; \
220+
else \
221+
echo ""; \
222+
echo "Rebase failed due to conflicts."; \
223+
echo "Please resolve conflicts manually:"; \
224+
echo " 1. Edit conflicted files"; \
225+
echo " 2. git add <resolved-files>"; \
226+
echo " 3. git rebase --continue"; \
227+
echo " 4. Or abort: git rebase --abort"; \
228+
exit 1; \
229+
fi
230+
231+
# Show BodhiApp-specific targets
232+
help-bodhiapp: ## Show BodhiApp release targets
233+
@echo ''
234+
@echo 'BodhiApp Release Targets:'
235+
@echo ' make release-server - Release llama-server binaries (creates branch + tag)'
236+
@echo ' make release-base-images - Release Docker base images (creates branch + tag)'
237+
@echo ' make show-server-git-info - Show version info for releases'
238+
@echo ' make validate-server-release - Validate release prerequisites'
239+
@echo ' make clean-server-release - Clean local release tags'
240+
@echo ''
241+
@echo 'BodhiApp Upstream Sync Targets:'
242+
@echo ' make sync-upstream-check - Check what would be synced (dry-run)'
243+
@echo ' make sync-upstream - Rebase master on upstream (does not push)'
244+
@echo ''
245+
@echo 'BodhiApp Help:'
246+
@echo ' make help-bodhiapp - Show this help message'
247+
@echo ''
248+
@echo 'For more details, see README-bodhiapp.md'

0 commit comments

Comments
 (0)