-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·67 lines (58 loc) · 2.7 KB
/
Copy pathpublish.sh
File metadata and controls
executable file
·67 lines (58 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# Publish NerGuard to PyPI.
#
# Prerequisites:
# 1. Create a PyPI account at https://pypi.org/account/register/
# 2. Generate an API token at https://pypi.org/manage/account/token/
# 3. Set the token: export UV_PUBLISH_TOKEN="pypi-..."
# (or add it to ~/.pypirc)
#
# Usage:
# export UV_PUBLISH_TOKEN="pypi-..."
# ./publish.sh # build + publish
# ./publish.sh --dry-run # build only, no upload
set -euo pipefail
BOLD='\033[1m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
RED='\033[0;31m'
NC='\033[0m'
DRY_RUN=false
for arg in "$@"; do
[[ "$arg" == "--dry-run" ]] && DRY_RUN=true
done
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
success() { echo -e "${GREEN}[OK]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; exit 1; }
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
# ── Check token ───────────────────────────────────────────────────────────────
if [[ "$DRY_RUN" == false ]]; then
if [[ -z "${UV_PUBLISH_TOKEN:-}" ]]; then
error "UV_PUBLISH_TOKEN is not set. Export it or use --dry-run.\n Get a token at: https://pypi.org/manage/account/token/"
fi
fi
# ── Build ─────────────────────────────────────────────────────────────────────
echo ""
echo -e "${BOLD}── nerguard ─────────────────────────────────────${NC}"
info "Building..."
rm -rf dist/
uv build --out-dir dist/
success "Built: $(ls dist/nerguard-*.whl dist/nerguard-*.tar.gz 2>/dev/null | tail -2 | tr '\n' ' ')"
# ── Publish ───────────────────────────────────────────────────────────────────
if [[ "$DRY_RUN" == false ]]; then
info "Publishing to PyPI..."
uv publish dist/nerguard-*.whl dist/nerguard-*.tar.gz
success "Published."
else
info "Dry run — skipping upload."
fi
# ── Done ──────────────────────────────────────────────────────────────────────
echo ""
echo -e "${GREEN}${BOLD}Done! Install with:${NC}"
echo -e " pip install nerguard"
echo -e ""
echo -e "${BOLD}CLI commands:${NC}"
echo -e " nerguard \"John Smith, email john@acme.com\""
echo -e " nerguard-rag \"John Smith, email john@acme.com\" # defaults to --rag output"
echo ""