Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ jobs:
run: |
make build-charts-site

- name: Upload chart to current release
run: |
CHART_VERSION="${GITHUB_REF#refs/tags/v}"
CHART_FILE="api-server-${CHART_VERSION}.tgz"

echo "📦 Uploading $CHART_FILE to release $VERSION..."
gh release upload $VERSION $CHART_FILE --clobber
echo "✅ Chart uploaded to GitHub Release"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Pages
uses: actions/configure-pages@v5

Expand Down
67 changes: 44 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,46 @@ build-charts-site: helm-package ## Create charts directory for GitHub Pages
CHARTS_DIR="charts-site"; \
echo "📦 Preparing charts site..."; \
mkdir -p "$$CHARTS_DIR"
@echo "📥 Fetching existing charts from GitHub Pages..."
@if curl -fsSL https://forkspacer.github.io/api-server/index.yaml -o /tmp/current-index.yaml 2>/dev/null; then \
echo "✅ Found existing Helm repository"; \
else \
echo "ℹ️ No existing charts found (first deployment)"; \
fi
@CHART_VERSION=$$(grep '^version:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'"); \
@echo "📥 Fetching existing charts from GitHub Releases..."
@REPO_OWNER="forkspacer"; \
REPO_NAME="api-server"; \
CHART_VERSION=$$(grep '^version:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'"); \
CHART_FILE="api-server-$$CHART_VERSION.tgz"; \
CHARTS_DIR="charts-site"; \
if [ -f /tmp/current-index.yaml ]; then \
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 \
filename=$$(basename "$$url"); \
if [ "$$filename" = "$$CHART_FILE" ]; then \
echo " ⏭️ Skipping $$filename (will be replaced)"; \
continue; \
fi; \
echo " 📥 Downloading $$filename..."; \
if curl -fsSL "$$url" -o "$$CHARTS_DIR/$$filename"; then \
echo " ✅ Downloaded $$filename"; \
else \
echo " ⚠️ Failed to download $$filename"; \
fi; \
done; \
if curl -fsSL "https://api.github.com/repos/$$REPO_OWNER/$$REPO_NAME/releases" -o /tmp/releases.json 2>/dev/null; then \
echo "✅ Found GitHub releases"; \
if command -v jq >/dev/null 2>&1; then \
echo "🔍 Using jq for JSON parsing..."; \
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 \
filename=$$(basename "$$url"); \
if [ "$$filename" = "$$CHART_FILE" ]; then \
echo " ⏭️ Skipping $$filename (will be replaced)"; \
continue; \
fi; \
echo " 📥 Downloading $$filename from GitHub Releases..."; \
if curl -fsSL "$$url" -o "$$CHARTS_DIR/$$filename"; then \
echo " ✅ Downloaded $$filename"; \
else \
echo " ⚠️ Failed to download $$filename"; \
fi; \
done; \
else \
echo "⚠️ jq not available, using manual parsing..."; \
grep -o '"browser_download_url": "[^"]*api-server-[^"]*\.tgz"' /tmp/releases.json | cut -d'"' -f4 | sort -u | while read url; do \
filename=$$(basename "$$url"); \
if [ "$$filename" != "$$CHART_FILE" ]; then \
echo " 📥 Downloading $$filename from GitHub Releases..."; \
if curl -fsSL "$$url" -o "$$CHARTS_DIR/$$filename"; then \
echo " ✅ Downloaded $$filename"; \
else \
echo " ⚠️ Failed to download $$filename"; \
fi; \
fi; \
done; \
fi; \
rm -f /tmp/releases.json; \
else \
echo "ℹ️ No GitHub releases found or API unavailable (first deployment)"; \
fi
@CHART_VERSION=$$(grep '^version:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'"); \
CHART_FILE="api-server-$$CHART_VERSION.tgz"; \
Expand All @@ -158,8 +175,12 @@ build-charts-site: helm-package ## Create charts directory for GitHub Pages
cp "$$CHART_FILE" "$$CHARTS_DIR/"; \
echo "✅ Added new chart: $$CHART_FILE"
@CHARTS_DIR="charts-site"; \
echo "📄 Generating Helm repo index..."; \
helm repo index "$$CHARTS_DIR" --url https://forkspacer.github.io/api-server
echo "📄 Generating Helm repo index with GitHub Releases URLs..."; \
CHART_VERSION=$$(grep '^version:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'"); \
APP_VERSION=$$(grep '^appVersion:' helm/Chart.yaml | awk '{print $$2}' | tr -d '"' | tr -d "'"); \
helm repo index "$$CHARTS_DIR" --url "https://github.com/forkspacer/api-server/releases/download"; \
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"; \
rm -f "$$CHARTS_DIR/index.yaml.bak"
@CHARTS_DIR="charts-site"; \
if [ -f ".github/templates/helm-page.html" ]; then \
cp .github/templates/helm-page.html "$$CHARTS_DIR/index.html"; \
Expand Down
Loading