designpaca/build/ci/publish-npm.sh
Yun Chan 9bcb45cbd3 feat(core,cli): harden install engine and extend skill lint and interview eval
- update only touches the recorded project root; project installs do not
  follow symlinks or junctions; repeated --force rotates .orig backups;
  uninstall never deletes outside the recorded root
- run npm/npx without a shell on Windows and pin optional tool versions
- skip the update check in CI and non-interactive output
- lint: cross-document section pointers, preflight row ids, gate rule
  numbers, per-document size budgets, gate copy equality
- eval: scenarios S19-S21, route and read-cost rejudging, interpretation
  card judging, temp-dir previews and table-form cards no longer fail
2026-10-06 16:55:38 +09:00

72 lines
2.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# designpaca 패키지를 npmjs 에 배포하고 Forgejo 사설 레지스트리에 미러링한다.
#
# 필요 환경:
# NPM_TOKEN npmjs 자동화 토큰 (필수)
# 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}"
published() { # <registry-url>
npm view "${name}@${version}" version --registry "$1" >/dev/null 2>&1
}
# ── 1) npmjs ──
if [ -z "${NPM_TOKEN:-}" ]; then
echo "NPM_TOKEN 이 없다 — npmjs 배포를 건너뛴다" >&2
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"