forked from mhdzumair/MediaFusion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
217 lines (192 loc) · 9.11 KB
/
Makefile
File metadata and controls
217 lines (192 loc) · 9.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# Makefile
# Image version
VERSION ?= latest
# Builder name
BUILDER_NAME ?= mediafusion-builder
# Docker image name
IMAGE_NAME = mediafusion
# Docker repository
DOCKER_REPO = mhdzumair
# Platforms to build for
PLATFORMS = linux/amd64,linux/arm64
# Docker image with version as tag
DOCKER_IMAGE = $(DOCKER_REPO)/$(IMAGE_NAME):$(VERSION)
# Proxy settings
HTTP_PROXY = http://172.17.0.1:1081
HTTPS_PROXY = http://172.17.0.1:1081
# Variables to hold version tags and contributor names
VERSION_OLD ?=
VERSION_NEW ?=
CONTRIBUTORS ?= $(shell git log --pretty=format:'%an' $(VERSION_OLD)..$(VERSION_NEW) | sort | uniq)
# Gemini API settings
GEMINI_MODEL ?= gemini-3-flash-preview
MAX_TOKENS ?= 4096
# Reddit post settings
SUBREDDIT ?= MediaFusion
REDDIT_POST_TITLE ?= "MediaFusion $(VERSION_NEW) Update - What's New?"
.PHONY: build tag push prompt update-version generate-notes generate-reddit-post frontend-install frontend-build frontend-dev dev backend-dev
build:
docker build --build-arg VERSION=$(VERSION) -t $(DOCKER_IMAGE) -f deployment/Dockerfile .
update-version:
ifndef VERSION_NEW
@echo "Error: VERSION_NEW is not set. Please set it like: make update-version VERSION_NEW=4.1.0"
@exit 1
endif
@echo "Updating version to $(VERSION_NEW)..."
# Update main addon.xml
@sed -i -e "/<addon\s*id=\"plugin\.video\.mediafusion\"/s/version=\"[^\"]*\"/version=\"$(VERSION_NEW)\"/" kodi/plugin.video.mediafusion/addon.xml
# Update repository addon.xml
@sed -i -e "/<addon\s*id=\"repository\.mediafusion\"/s/version=\"[^\"]*\"/version=\"$(VERSION_NEW)\"/" kodi/repository.mediafusion/addon.xml
# Update docker-compose.yml
@sed -i 's|image: $(DOCKER_REPO)/$(IMAGE_NAME):[0-9.]*|image: $(DOCKER_REPO)/$(IMAGE_NAME):$(VERSION_NEW)|g' deployment/docker-compose/docker-compose.yml
@sed -i 's|image: $(DOCKER_REPO)/$(IMAGE_NAME):[0-9.]*|image: $(DOCKER_REPO)/$(IMAGE_NAME):$(VERSION_NEW)|g' deployment/docker-compose/docker-compose-minimal.yml
# Update k8s deployment
@sed -i 's|image: $(DOCKER_REPO)/$(IMAGE_NAME):[0-9.]*|image: $(DOCKER_REPO)/$(IMAGE_NAME):$(VERSION_NEW)|g' deployment/k8s/local-deployment.yaml
# Update pyproject.toml
@sed -i -e "s/version = \"[0-9.]*\"/version = \"$(VERSION_NEW)\"/" pyproject.toml
@echo "Version updated to $(VERSION_NEW) in all files"
build-multi:
@if ! docker buildx ls | grep -q $(BUILDER_NAME); then \
echo "Creating new builder $(BUILDER_NAME)"; \
docker buildx create --name $(BUILDER_NAME) --use --driver-opt env.http_proxy=${HTTP_PROXY} --driver-opt env.https_proxy=${HTTPS_PROXY}; \
else \
echo "Using existing builder $(BUILDER_NAME)"; \
docker buildx use $(BUILDER_NAME); \
fi
docker buildx inspect --bootstrap
docker buildx build --platform $(PLATFORMS) --build-arg VERSION=$(VERSION) -t $(DOCKER_IMAGE) -f deployment/Dockerfile . --push
if [ "$(VERSION)" != "beta" ]; then \
docker buildx build --platform $(PLATFORMS) --build-arg VERSION=$(VERSION) -t $(DOCKER_REPO)/$(IMAGE_NAME):latest -f deployment/Dockerfile . --push; \
fi
push:
docker push $(DOCKER_IMAGE)
prompt:
ifndef VERSION_OLD
@echo "Error: VERSION_OLD is not set. Please set it like: make prompt VERSION_OLD=x.x.x VERSION_NEW=y.y.y CONTRIBUTORS='@user1, @user2'"
@exit 1
endif
ifndef VERSION_NEW
@echo "Error: VERSION_NEW is not set. Please set it like: make prompt VERSION_OLD=x.x.x VERSION_NEW=y.y.y CONTRIBUTORS='@user1, @user2'"
@exit 1
endif
@echo "You are a technical writer for MediaFusion, an open-source streaming addon for Stremio and Kodi.\n"
@echo "Generate a concise GitHub release note for version $(VERSION_NEW). Follow these rules:\n"
@echo "1. Start with: ## 🚀 MediaFusion $(VERSION_NEW) Released\n"
@echo "2. Organize by importance, NOT commit order. Lead with the most impactful changes.\n"
@echo "3. Only include sections that are relevant (pick from: New Features & Enhancements, Bug Fixes, Performance, Documentation). Do not create empty sections.\n"
@echo "4. Each item: start with a relevant emoji, write a single clear sentence explaining the user-facing change. Omit internal refactors unless they affect performance or reliability.\n"
@echo "5. End with a Contributors section and a Full Changelog link (both provided below).\n"
@echo "6. Output ONLY the release note in markdown. No preamble, no commentary.\n"
@echo "\n### Commit Messages and Descriptions:\n"
@git log --pretty=format:'%s%n%b' $(VERSION_OLD)..$(VERSION_NEW) | awk 'BEGIN {RS="\n\n"; FS="\n"} { \
message = $$1; \
description = ""; \
for (i=2; i<=NF; i++) { \
if ($$i ~ /^\*/) description = description " " $$i "\n"; \
else if ($$i != "") description = description " " $$i "\n"; \
} \
if (message != "") print "- " message; \
if (description != "") printf "%s", description; \
}'
@echo "--- \n### 🤝 Contributors: $(CONTRIBUTORS)\n\n### 📄 Full Changelog:\nhttps://github.com/mhdzumair/MediaFusion/compare/$(VERSION_OLD)...$(VERSION_NEW)";
prompt-reddit:
ifndef VERSION_OLD
@echo "Error: VERSION_OLD is not set. Please set it like: make prompt-reddit VERSION_OLD=x.x.x VERSION_NEW=y.y.y"
@exit 1
endif
ifndef VERSION_NEW
@echo "Error: VERSION_NEW is not set. Please set it like: make prompt-reddit VERSION_OLD=x.x.x VERSION_NEW=y.y.y"
@exit 1
endif
@echo "You are writing a Reddit post for r/$(SUBREDDIT) announcing MediaFusion $(VERSION_NEW).\n"
@echo "Follow these rules:\n"
@echo "1. Start with a **TL;DR** (2-3 bullet points summarizing the biggest changes).\n"
@echo "2. Write in a conversational, community-friendly tone. Avoid marketing speak.\n"
@echo "3. Organize into clear sections (e.g., What's New, Improvements, Bug Fixes) — only include sections that apply.\n"
@echo "4. Focus on user-facing benefits, not implementation details.\n"
@echo "5. End with a short note on how to update/install and a link to the full changelog.\n"
@echo "6. Output ONLY the Reddit post body in markdown. No preamble, no commentary.\n"
@echo "\n---\n"
@git log --pretty=format:'%s%n%b' $(VERSION_OLD)..$(VERSION_NEW) | awk 'BEGIN {RS="\n\n"; FS="\n"} { \
message = $$1; \
description = ""; \
for (i=2; i<=NF; i++) { \
if ($$i ~ /^\*/) description = description " " $$i "\n"; \
else if ($$i != "") description = description " " $$i "\n"; \
} \
if (message != "") print "- " message; \
if (description != "") printf "%s", description; \
}'
@echo "\n---\nFor the complete changelog, visit: https://github.com/mhdzumair/MediaFusion/compare/$(VERSION_OLD)...$(VERSION_NEW)"
generate-notes:
ifndef VERSION_OLD
@echo "Error: VERSION_OLD is not set"
@exit 1
endif
ifndef VERSION_NEW
@echo "Error: VERSION_NEW is not set"
@exit 1
endif
ifndef GEMINI_API_KEY
@echo "Error: GEMINI_API_KEY is not set"
@exit 1
endif
@PROMPT_CONTENT=$$(make prompt VERSION_OLD=$(VERSION_OLD) VERSION_NEW=$(VERSION_NEW) | jq -sRr @json); \
if [ -z "$$PROMPT_CONTENT" ]; then \
echo "Failed to generate release notes using Gemini AI, prompt content is empty"; \
exit 1; \
fi; \
temp_file=$$(mktemp); \
curl -s "https://generativelanguage.googleapis.com/v1beta/models/$(GEMINI_MODEL):generateContent" \
--header "x-goog-api-key: $(GEMINI_API_KEY)" \
--header "content-type: application/json" \
--data "{\"contents\":[{\"parts\":[{\"text\":$$PROMPT_CONTENT}]}],\"generationConfig\":{\"maxOutputTokens\":$(MAX_TOKENS)}}" > $$temp_file; \
RESULT=$$(jq -r '[.candidates[0].content.parts[] | select(.thought != true) | .text] | join("")' $$temp_file 2>/dev/null); \
if [ -z "$$RESULT" ] || [ "$$RESULT" = "null" ]; then \
echo "Failed to generate release notes using Gemini AI, response: $$(cat $$temp_file)"; rm $$temp_file; exit 1; \
fi; \
echo "$$RESULT"; \
rm $$temp_file
generate-reddit-post:
ifndef VERSION_OLD
@echo "Error: VERSION_OLD is not set"
@exit 1
endif
ifndef VERSION_NEW
@echo "Error: VERSION_NEW is not set"
@exit 1
endif
ifndef GEMINI_API_KEY
@echo "Error: GEMINI_API_KEY is not set"
@exit 1
endif
@PROMPT_CONTENT=$$(make prompt-reddit VERSION_OLD=$(VERSION_OLD) VERSION_NEW=$(VERSION_NEW) | jq -sRr @json); \
if [ -z "$$PROMPT_CONTENT" ]; then \
echo "Failed to generate Reddit post using Gemini AI, prompt content is empty"; \
exit 1; \
fi; \
temp_file=$$(mktemp); \
curl -s "https://generativelanguage.googleapis.com/v1beta/models/$(GEMINI_MODEL):generateContent" \
--header "x-goog-api-key: $(GEMINI_API_KEY)" \
--header "content-type: application/json" \
--data "{\"contents\":[{\"parts\":[{\"text\":$$PROMPT_CONTENT}]}],\"generationConfig\":{\"maxOutputTokens\":$(MAX_TOKENS)}}" > $$temp_file; \
RESULT=$$(jq -r '[.candidates[0].content.parts[] | select(.thought != true) | .text] | join("")' $$temp_file 2>/dev/null); \
if [ -z "$$RESULT" ] || [ "$$RESULT" = "null" ]; then \
echo "Failed to generate Reddit post using Gemini AI, response: $$(cat $$temp_file)"; rm $$temp_file; exit 1; \
fi; \
echo "$$RESULT"; \
rm $$temp_file
# Frontend build targets
frontend-install:
cd frontend && npm ci
frontend-build: frontend-install
cd frontend && npm run build
frontend-dev:
cd frontend && npm run dev
# Development targets
backend-dev:
uvicorn api.main:app --reload --port 8000
dev:
@echo "Starting backend and frontend in development mode..."
@echo "Run 'make backend-dev' in one terminal and 'make frontend-dev' in another"
all: build-multi