Move directory
This commit is contained in:
Executable
+198
@@ -0,0 +1,198 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# 이 스크립트가 위치한 디렉토리 기준으로 프로젝트 루트를 설정
|
||||
UPDATE_CATALOG_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
# dip-catalog 레포 경로 (환경변수로 오버라이드 가능)
|
||||
CATALOG_ROOT="${CATALOG_ROOT:-/Users/songwonbin/openclaw-workspace/dip-catalog}"
|
||||
|
||||
CHART="${CHART:-airflow}"
|
||||
DEFAULT_BRANCH="${DEFAULT_BRANCH:-main}"
|
||||
OUT_DIR="${OUT_DIR:-$(pwd)/update_catalog}"
|
||||
|
||||
# 차트별 하위 디렉토리로 격리 → 다중 차트 동시 실행 시 충돌 방지
|
||||
CHART_OUT_DIR="$OUT_DIR/$CHART"
|
||||
mkdir -p "$CHART_OUT_DIR"
|
||||
|
||||
# 이전 실행의 임시 마커 파일 정리
|
||||
rm -f "$CHART_OUT_DIR/no_update"
|
||||
|
||||
VERSION_JSON="$CHART_OUT_DIR/chart_version.json"
|
||||
CHART_UPDATE_JSON="$CHART_OUT_DIR/chart_update.json"
|
||||
DIFF_JSON="$CHART_OUT_DIR/helm_diff.json"
|
||||
BREAKING_JSON="$CHART_OUT_DIR/breaking.json"
|
||||
UPGRADE_DOC_JSON="$CHART_OUT_DIR/upgrade_doc.json"
|
||||
UPDATE_DOCS_JSON="$CHART_OUT_DIR/update_docs.json"
|
||||
PR_JSON="$CHART_OUT_DIR/pr.json"
|
||||
|
||||
# dip-catalog main 브랜치 최신화 (create_pr이 브랜치를 main에서 분기하므로 선행 필요)
|
||||
git -C "$CATALOG_ROOT" checkout "$DEFAULT_BRANCH"
|
||||
git -C "$CATALOG_ROOT" pull origin "$DEFAULT_BRANCH"
|
||||
|
||||
# 0) chart_version_detector: FROM_VERSION / TO_VERSION / REPO 자동 감지
|
||||
python3 "$UPDATE_CATALOG_ROOT/skills/chart_version_detector/scripts/run.py" \
|
||||
--catalog-root "$CATALOG_ROOT" --chart "$CHART" \
|
||||
> "$VERSION_JSON"
|
||||
|
||||
python3 - <<PY
|
||||
import json, sys
|
||||
from pathlib import Path
|
||||
d = json.loads(Path("$VERSION_JSON").read_text())
|
||||
if d.get("error"):
|
||||
print(f"ERROR: {d['error']['message']}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
from_v = d.get("current_version") or ""
|
||||
to_v = d.get("latest_version") or ""
|
||||
repo = d.get("repo") or ""
|
||||
if not from_v:
|
||||
print("ERROR: current_version not detected", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if not to_v or from_v == to_v:
|
||||
Path("$CHART_OUT_DIR/no_update").write_text(from_v)
|
||||
sys.exit(0)
|
||||
Path("$CHART_OUT_DIR/versions.env").write_text(
|
||||
f"FROM_VERSION={from_v}\n"
|
||||
f"TO_VERSION={to_v}\n"
|
||||
f"REPO={repo}\n"
|
||||
)
|
||||
PY
|
||||
|
||||
if [[ -f "$CHART_OUT_DIR/no_update" ]]; then
|
||||
echo "No update: $CHART is already at latest ($(cat "$CHART_OUT_DIR/no_update"))"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "$CHART_OUT_DIR/versions.env"
|
||||
|
||||
CHART_PATH="${CHART_PATH:-$CATALOG_ROOT/manifests/helm/$CHART/$FROM_VERSION}"
|
||||
|
||||
echo "Detected: $CHART $FROM_VERSION → $TO_VERSION (repo: $REPO)"
|
||||
|
||||
# 1) chart_updater: TO_VERSION 차트 pull → manifests/helm/<chart>/<to_version>/ 생성
|
||||
# + FROM_VERSION에서 BUILD-README.md(버전 치환), CUSTOM-README.md, custom-values.yaml 복사
|
||||
python3 "$UPDATE_CATALOG_ROOT/skills/chart_updater/scripts/run.py" \
|
||||
--catalog-root "$CATALOG_ROOT" \
|
||||
--chart "$CHART" \
|
||||
--repo "$REPO" \
|
||||
--version "$TO_VERSION" \
|
||||
--from-version "$FROM_VERSION" \
|
||||
> "$CHART_UPDATE_JSON"
|
||||
|
||||
python3 - <<PY
|
||||
import json
|
||||
from pathlib import Path
|
||||
r = json.loads(Path("$CHART_UPDATE_JSON").read_text())
|
||||
status = "already existed" if r.get("already_existed") else "pulled"
|
||||
copied = r.get("copied_files", [])
|
||||
print(f"chart_updater: {r.get('dest_dir')} [{status}]")
|
||||
if copied:
|
||||
print(f" copied from $FROM_VERSION: {', '.join(copied)}")
|
||||
PY
|
||||
|
||||
# 2) helm_diff
|
||||
python3 "$UPDATE_CATALOG_ROOT/skills/helm_diff/scripts/run.py" \
|
||||
--chart "$CHART" --repo "$REPO" \
|
||||
--chart-path "$CHART_PATH" \
|
||||
--from-version "$FROM_VERSION" --to-version "$TO_VERSION" \
|
||||
> "$DIFF_JSON"
|
||||
|
||||
# 3) breaking_change_check
|
||||
# FROM_VERSION의 custom-values.yaml을 기준으로 실제 사용 key만 breaking 판단
|
||||
CUSTOM_VALUES_PATH="$CATALOG_ROOT/manifests/helm/$CHART/$FROM_VERSION/custom-values.yaml"
|
||||
CUSTOM_VALUES_ARG=""
|
||||
if [[ -f "$CUSTOM_VALUES_PATH" ]]; then
|
||||
CUSTOM_VALUES_ARG="--custom-values $CUSTOM_VALUES_PATH"
|
||||
fi
|
||||
python3 "$UPDATE_CATALOG_ROOT/skills/breaking_change_check/scripts/run.py" \
|
||||
--diff-file "$DIFF_JSON" \
|
||||
$CUSTOM_VALUES_ARG \
|
||||
> "$BREAKING_JSON"
|
||||
|
||||
python3 - <<PY
|
||||
import json
|
||||
from pathlib import Path
|
||||
b = json.loads(Path("$BREAKING_JSON").read_text())
|
||||
breaking = b.get("breaking", False)
|
||||
severity = b.get("severity", "warning")
|
||||
reasons = b.get("reasons", [])
|
||||
warnings = b.get("warnings", [])
|
||||
print(f"breaking_check: breaking={breaking}, severity={severity}, reasons={len(reasons)}, warnings={len(warnings)}")
|
||||
PY
|
||||
|
||||
# 4) generate_upgrade_doc: 항상 실행
|
||||
# breaking=true → USE_CLAUDE_CLI=1 시 LLM 상세 가이드
|
||||
# breaking=false → 템플릿 기반 간단 요약
|
||||
CUSTOM_README_FROM="$CATALOG_ROOT/manifests/helm/$CHART/$FROM_VERSION/CUSTOM-README.md"
|
||||
DOCS_CONTEXT_ARG=""
|
||||
if [[ -f "$CUSTOM_README_FROM" ]]; then
|
||||
DOCS_CONTEXT_ARG="--docs-context $CUSTOM_README_FROM"
|
||||
fi
|
||||
|
||||
python3 "$UPDATE_CATALOG_ROOT/skills/generate_upgrade_doc/scripts/run.py" \
|
||||
--diff-file "$DIFF_JSON" \
|
||||
--breaking-file "$BREAKING_JSON" \
|
||||
$DOCS_CONTEXT_ARG \
|
||||
> "$UPGRADE_DOC_JSON"
|
||||
|
||||
python3 - <<PY
|
||||
import json
|
||||
from pathlib import Path
|
||||
d = json.loads(Path("$UPGRADE_DOC_JSON").read_text())
|
||||
truncated = d.get("truncated", False)
|
||||
print(f"generate_upgrade_doc: markdown generated (truncated={truncated})")
|
||||
PY
|
||||
|
||||
# 5) update_docs_file: TO_VERSION의 CUSTOM-README.md에 업그레이드 주의사항 추가
|
||||
CUSTOM_README_TO_RELATIVE="manifests/helm/$CHART/$TO_VERSION/CUSTOM-README.md"
|
||||
|
||||
python3 - <<PY
|
||||
import json, subprocess, sys
|
||||
from pathlib import Path
|
||||
|
||||
upgrade_doc = json.loads(Path("$UPGRADE_DOC_JSON").read_text())
|
||||
markdown = upgrade_doc.get("markdown", "")
|
||||
|
||||
payload = {
|
||||
"repo_path": "$CATALOG_ROOT",
|
||||
"docs_file": "$CUSTOM_README_TO_RELATIVE",
|
||||
"version": "$FROM_VERSION → $TO_VERSION",
|
||||
"content": markdown,
|
||||
"overwrite": False,
|
||||
}
|
||||
|
||||
import sys
|
||||
sys.path.insert(0, "$UPDATE_CATALOG_ROOT/src")
|
||||
from update_catalog.update_docs_file import update_docs_file
|
||||
result = update_docs_file(payload)
|
||||
import json as _json
|
||||
Path("$UPDATE_DOCS_JSON").write_text(_json.dumps(result))
|
||||
status = "already existed" if result.get("already_existed") else "updated"
|
||||
print(f"update_docs_file: {result.get('file_path')} [{status}]")
|
||||
PY
|
||||
|
||||
# # 6) create_pr: 브랜치 생성 → 커밋 → 푸시 → PR 생성 (항상 실행)
|
||||
# python3 "$UPDATE_CATALOG_ROOT/skills/create_pr/scripts/run.py" \
|
||||
# --repo-path "$CATALOG_ROOT" \
|
||||
# --chart "$CHART" \
|
||||
# --from-version "$FROM_VERSION" \
|
||||
# --to-version "$TO_VERSION" \
|
||||
# --breaking-file "$BREAKING_JSON" \
|
||||
# > "$PR_JSON"
|
||||
|
||||
# python3 - <<PY
|
||||
# import json
|
||||
# from pathlib import Path
|
||||
# pr = json.loads(Path("$PR_JSON").read_text())
|
||||
# b = json.loads(Path("$BREAKING_JSON").read_text())
|
||||
# labels = pr.get("labels", [])
|
||||
# print(f"PR: {pr.get('pr_url')} [{', '.join(labels)}]")
|
||||
# if b.get("breaking"):
|
||||
# print(" → custom-values.yaml 수정 필요. 담당자 확인 후 merge 하세요. (needs-review)")
|
||||
# else:
|
||||
# print(" → 주의사항만 있음. CUSTOM-README.md 확인 후 merge 가능. (auto-update)")
|
||||
# PY
|
||||
|
||||
# echo "Done. Chart updated: $CATALOG_ROOT/manifests/helm/$CHART/$TO_VERSION"
|
||||
# exit 0
|
||||
Reference in New Issue
Block a user