designpaca/build/ci/publish-npm.sh
Yun Chan 97f2c241e4 fix(eval,ci): isolate interview eval and harden skill lint and design gate
- Run eval sessions in a temp dir outside the repo so Codex no longer reads the root AGENTS.md; empty streams, timeouts and crashes judge as ERROR instead of PASS
- Close interview-gate lint gaps: softening phrases hidden on allowed lines, reordered phrasing, sibling-anchor bypass
- design-gate: bold threshold 700, axe incomplete reported as manual checks, follow @import with query strings, report unverified color literals; keep site copy in sync via test
- publish-npm.sh fails without NPM_TOKEN; CI requires Node 22.6+; ignore outputs/
2026-10-09 18:18:41 +09:00

86 lines
3.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# designpaca 패키지를 npmjs 에 배포하고 Forgejo 사설 레지스트리에 미러링한다.
#
# 필요 환경:
# NPM_TOKEN npmjs 자동화 토큰 (필수 — 없으면 exit 1)
# FORGEJO_NPM_TOKEN Forgejo 개인 액세스 토큰 (선택 — 없으면 미러를 건너뛴다)
# FORGEJO_NPM_OWNER Forgejo 패키지 소유자 (기본: yunchan)
# GITHUB_SERVER_URL Forgejo 주소 (Actions 가 준다)
#
# 이미 배포된 버전이면 조용히 건너뛴다 — 워크플로 재실행이 실패로 끝나지 않게.
set -euo pipefail
PKG_DIR="${1:-packages/cli}"
# set -e 로 중간에 죽어도 토큰을 담은 임시 npmrc 가 /tmp 에 남지 않게 한다
npmrc=""
cleanup() { if [ -n "$npmrc" ]; then rm -f "$npmrc"; fi; }
trap cleanup EXIT
cd "$PKG_DIR"
name="$(node -p 'require("./package.json").name')"
version="$(node -p 'require("./package.json").version')"
echo "배포 대상: ${name}@${version}"
# 배포 여부. E404 만 "아직 안 올라감"으로 본다. 네트워크·인증·레지스트리 장애를 미배포로 읽으면
# 이미 올라간 버전에 npm publish 를 시도해 403 으로 죽어 재실행 멱등성이 깨진다.
published() { # <registry-url>
local out
if out="$(npm view "${name}@${version}" version --registry "$1" 2>&1)"; then
return 0
fi
if printf '%s' "$out" | grep -q 'E404'; then
return 1
fi
echo "npm view 가 E404 가 아닌 오류로 실패했다 — 배포 여부를 알 수 없어 멈춘다:" >&2
echo "$out" >&2
exit 1
}
# ── 1) npmjs ──
if [ -z "${NPM_TOKEN:-}" ]; then
# 이 스크립트는 태그 릴리스(DO_PUBLISH=1)에서만 호출된다. 토큰 없이 초록으로 끝나면
# npm 에는 아무것도 안 올라간 채 draft 릴리스와 사이트 배포가 이어진다.
echo "NPM_TOKEN 이 없다 — 태그 릴리스에는 필수 시크릿이라 실패시킨다" >&2
exit 1
else
npmrc="$(mktemp)"
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > "$npmrc"
export NPM_CONFIG_USERCONFIG="$npmrc"
if published "https://registry.npmjs.org/"; then
echo "npmjs: ${version} 은 이미 배포돼 있다 — 건너뛴다"
else
npm publish --access public --registry "https://registry.npmjs.org/" --provenance=false
echo "npmjs 배포 완료: ${name}@${version}"
fi
rm -f "$npmrc"
unset NPM_CONFIG_USERCONFIG
fi
# ── 2) Forgejo 미러 ──
if [ -z "${FORGEJO_NPM_TOKEN:-}" ]; then
echo "FORGEJO_NPM_TOKEN 이 없다 — 사설 레지스트리 미러를 건너뛴다"
exit 0
fi
owner="${FORGEJO_NPM_OWNER:-yunchan}"
server="${GITHUB_SERVER_URL:-https://git.chanpaca.net}"
host="${server#*://}"; host="${host%/}"
registry="${server%/}/api/packages/${owner}/npm/"
npmrc="$(mktemp)"
{
echo "registry=${registry}"
# 스킴을 뺀 형태로 적어야 Forgejo 가 인증을 인식한다
echo "//${host}/api/packages/${owner}/npm/:_authToken=${FORGEJO_NPM_TOKEN}"
} > "$npmrc"
export NPM_CONFIG_USERCONFIG="$npmrc"
if published "$registry"; then
echo "Forgejo: ${version} 은 이미 미러돼 있다 — 건너뛴다"
else
npm publish --registry "$registry"
echo "Forgejo 미러 완료: ${registry}"
fi
rm -f "$npmrc"