@@ -127,29 +127,46 @@ build-charts-site: helm-package ## Create charts directory for GitHub Pages
127127 CHARTS_DIR=" charts-site" ; \
128128 echo " 📦 Preparing charts site..." ; \
129129 mkdir -p " $$ CHARTS_DIR"
130- @echo " 📥 Fetching existing charts from GitHub Pages..."
131- @if curl -fsSL https://forkspacer.github.io/api-server/index.yaml -o /tmp/current-index.yaml 2> /dev/null; then \
132- echo " ✅ Found existing Helm repository" ; \
133- else \
134- echo " ℹ️ No existing charts found (first deployment)" ; \
135- fi
136- @CHART_VERSION=$$(grep '^version:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'" ) ; \
130+ @echo " 📥 Fetching existing charts from GitHub Releases..."
131+ @REPO_OWNER=" forkspacer" ; \
132+ REPO_NAME=" api-server" ; \
133+ CHART_VERSION=$$(grep '^version:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'" ) ; \
137134 CHART_FILE=" api-server-$$ CHART_VERSION.tgz" ; \
138135 CHARTS_DIR=" charts-site" ; \
139- if [ -f /tmp/current-index.yaml ]; then \
140- grep -oP ' https://forkspacer\.github\.io/api-server/api-server-[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?\.tgz' /tmp/current-index.yaml | sort -u | while read url; do \
141- filename=$$(basename "$$url") ; \
142- if [ " $$ filename" = " $$ CHART_FILE" ]; then \
143- echo " ⏭️ Skipping $$ filename (will be replaced)" ; \
144- continue ; \
145- fi ; \
146- echo " 📥 Downloading $$ filename..." ; \
147- if curl -fsSL " $$ url" -o " $$ CHARTS_DIR/$$ filename" ; then \
148- echo " ✅ Downloaded $$ filename" ; \
149- else \
150- echo " ⚠️ Failed to download $$ filename" ; \
151- fi ; \
152- done ; \
136+ if curl -fsSL " https://api.github.com/repos/$$ REPO_OWNER/$$ REPO_NAME/releases" -o /tmp/releases.json 2> /dev/null; then \
137+ echo " ✅ Found GitHub releases" ; \
138+ if command -v jq > /dev/null 2>&1 ; then \
139+ echo " 🔍 Using jq for JSON parsing..." ; \
140+ cat /tmp/releases.json | jq -r ' .[] | select(.assets[].name | test("api-server-.*\\.tgz")) | .assets[] | select(.name | test("api-server-.*\\.tgz")) | .browser_download_url' | sort -u | while read url; do \
141+ filename=$$(basename "$$url") ; \
142+ if [ " $$ filename" = " $$ CHART_FILE" ]; then \
143+ echo " ⏭️ Skipping $$ filename (will be replaced)" ; \
144+ continue ; \
145+ fi ; \
146+ echo " 📥 Downloading $$ filename from GitHub Releases..." ; \
147+ if curl -fsSL " $$ url" -o " $$ CHARTS_DIR/$$ filename" ; then \
148+ echo " ✅ Downloaded $$ filename" ; \
149+ else \
150+ echo " ⚠️ Failed to download $$ filename" ; \
151+ fi ; \
152+ done ; \
153+ else \
154+ echo " ⚠️ jq not available, using manual parsing..." ; \
155+ grep -o ' "browser_download_url": "[^"]*api-server-[^"]*\.tgz"' /tmp/releases.json | cut -d' "' -f4 | sort -u | while read url; do \
156+ filename=$$(basename "$$url") ; \
157+ if [ " $$ filename" != " $$ CHART_FILE" ]; then \
158+ echo " 📥 Downloading $$ filename from GitHub Releases..." ; \
159+ if curl -fsSL " $$ url" -o " $$ CHARTS_DIR/$$ filename" ; then \
160+ echo " ✅ Downloaded $$ filename" ; \
161+ else \
162+ echo " ⚠️ Failed to download $$ filename" ; \
163+ fi ; \
164+ fi ; \
165+ done ; \
166+ fi ; \
167+ rm -f /tmp/releases.json; \
168+ else \
169+ echo " ℹ️ No GitHub releases found or API unavailable (first deployment)" ; \
153170 fi
154171 @CHART_VERSION=$$(grep '^version:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'" ) ; \
155172 CHART_FILE=" api-server-$$ CHART_VERSION.tgz" ; \
@@ -158,8 +175,12 @@ build-charts-site: helm-package ## Create charts directory for GitHub Pages
158175 cp " $$ CHART_FILE" " $$ CHARTS_DIR/" ; \
159176 echo " ✅ Added new chart: $$ CHART_FILE"
160177 @CHARTS_DIR=" charts-site" ; \
161- echo " 📄 Generating Helm repo index..." ; \
162- helm repo index " $$ CHARTS_DIR" --url https://forkspacer.github.io/api-server
178+ echo " 📄 Generating Helm repo index with GitHub Releases URLs..." ; \
179+ CHART_VERSION=$$(grep '^version:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'" ) ; \
180+ APP_VERSION=$$(grep '^appVersion:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'" ) ; \
181+ helm repo index " $$ CHARTS_DIR" --url " https://github.com/forkspacer/api-server/releases/download" ; \
182+ sed -i.bak " s|https://github.com/forkspacer/api-server/releases/download/api-server-\([0-9]\+\.[0-9]\+\.[0-9]\+\)\.tgz|https://github.com/forkspacer/api-server/releases/download/v\1/api-server-\1.tgz|g" " $$ CHARTS_DIR/index.yaml" ; \
183+ rm -f " $$ CHARTS_DIR/index.yaml.bak"
163184 @CHARTS_DIR=" charts-site" ; \
164185 if [ -f " .github/templates/helm-page.html" ]; then \
165186 cp .github/templates/helm-page.html " $$ CHARTS_DIR/index.html" ; \
0 commit comments