hf-papers / scripts /publish_space.sh
evalstate's picture
evalstate HF Staff
sync: promote hf_hub_community prompt v3 + add prompt/coverage harness
bba4fab verified
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
SPACE_REPO="${SPACE_REPO:-evalstate/hf-papers}"
COMMIT_MSG="${COMMIT_MSG:-sync: update community prompt v3 + eval harness}"
DRY_RUN="${DRY_RUN:-0}"
hf auth whoami >/dev/null
mapfile -t MODIFIED < <(git diff --name-only)
mapfile -t UNTRACKED < <(git ls-files --others --exclude-standard)
mapfile -t DELETED < <(git diff --name-only --diff-filter=D)
# Build unique include list
ALL=()
for f in "${MODIFIED[@]}" "${UNTRACKED[@]}"; do
[[ -z "$f" ]] && continue
# Skip noisy/local artifacts by default
if [[ "$f" == *"/__pycache__/"* ]]; then
continue
fi
if [[ "$f" == docs/hf_hub_prompt_ab/*/gpt-oss/raw/* ]]; then
continue
fi
if [[ "$f" == .fast-agent/sessions/* ]]; then
continue
fi
ALL+=("$f")
done
if [[ ${#ALL[@]} -eq 0 && ${#DELETED[@]} -eq 0 ]]; then
echo "[info] nothing to publish"
exit 0
fi
cmd=(hf upload "$SPACE_REPO" . --repo-type space --commit-message "$COMMIT_MSG")
for f in "${ALL[@]}"; do
cmd+=(--include "$f")
done
for f in "${DELETED[@]}"; do
cmd+=(--delete "$f")
done
echo "[info] repo=$SPACE_REPO"
echo "[info] includes=${#ALL[@]} deletes=${#DELETED[@]}"
printf ' + %s\n' "${ALL[@]:0:20}"
if [[ ${#ALL[@]} -gt 20 ]]; then
echo " ..."
fi
if [[ "$DRY_RUN" == "1" ]]; then
echo "[dry-run] ${cmd[*]}"
exit 0
fi
"${cmd[@]}"
echo "[done] published to https://huggingface.co/spaces/${SPACE_REPO}"