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