-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaperkit-dev
More file actions
executable file
·702 lines (639 loc) · 21.1 KB
/
Copy pathpaperkit-dev
File metadata and controls
executable file
·702 lines (639 loc) · 21.1 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
#!/bin/bash
# -*- mode: sh -*-
# vim: set filetype=sh :
# PaperKit Developer Command Line Interface
# Version: $VERSION
# Development and maintenance commands (requires authorization)
#
# AUTHORIZATION: Two-layer approach
# 1. Local checks (this script) - prevents accidents, can be bypassed by editing
# 2. Service-side enforcement (GitHub Actions) - cannot be bypassed
#
# This script provides local authorization checks for developer convenience.
# However, the actual release process is enforced server-side by GitHub Actions
# using protected environments. Even if these local checks are bypassed, releases
# cannot be published without approval from authorized GitHub users.
#
# See dev-docs/service-side-authorization.md for setup details.
# Get version from YAML config, fallback to VERSION file for backwards compatibility
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Get version from YAML config (get-version.sh handles VERSION file fallback if needed)
if [ -f "$SCRIPT_DIR/.paperkit/tools/get-version.sh" ]; then
VERSION=$("$SCRIPT_DIR/.paperkit/tools/get-version.sh" 2>/dev/null || echo "unknown")
else
VERSION="unknown"
fi
# Get titles from YAML config
if [ -f "$SCRIPT_DIR/.paperkit/tools/get-title.sh" ]; then
TITLE_SHORT=$("$SCRIPT_DIR/.paperkit/tools/get-title.sh" short 2>/dev/null || echo "PaperKit")
TITLE_LONG=$("$SCRIPT_DIR/.paperkit/tools/get-title.sh" long 2>/dev/null || echo "Research Paper Assistant")
else
TITLE_SHORT="PaperKit"
TITLE_LONG="Research Paper Assistant"
fi
# Color codes
BLUE='\033[0;34m'
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Authorized owners (add git config emails here)
# NOTE: This is a local check only. Service-side authorization is enforced by
# GitHub Actions using protected environments. See dev-docs/service-side-authorization.md
AUTHORIZED_OWNERS=(
)
# Check if current user is authorized
check_authorization() {
local current_email
current_email=$(git config user.email 2>/dev/null)
if [ -z "$current_email" ]; then
echo -e "${RED}Error: Git user.email not configured.${NC}"
echo "Configure with: git config user.email 'your@email.com'"
return 1
fi
for authorized in "${AUTHORIZED_OWNERS[@]}"; do
if [ "$current_email" = "$authorized" ]; then
return 0
fi
done
echo -e "${RED}Error: Unauthorized user.${NC}"
echo "Current git user: $current_email"
echo "Authorized users: ${AUTHORIZED_OWNERS[*]}"
echo ""
echo "Only repository owners can run development commands."
return 1
}
# Show version
show_version() {
echo -e "${YELLOW}${TITLE_SHORT}${NC} ${GREEN}Current Version${NC} $VERSION"
}
# Main help
show_help() {
echo ""
echo -e "${BLUE}════════════════════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e " ${YELLOW}${TITLE_SHORT}${NC} ${TITLE_LONG} Developer CLI. ${GREEN}Version${NC} $VERSION"
echo ""
echo -e "${BLUE}════════════════════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "${YELLOW}USAGE${NC}"
echo " paperkit-dev <command> [options]"
echo ""
echo -e "${YELLOW}DEVELOPER COMMANDS${NC}"
echo -e " ${GREEN}release${NC} Create release tags and distribution bundles"
echo -e " ${GREEN}version${NC} Manage version (bump, set, view)"
echo -e " ${GREEN}help${NC} Show this help message"
echo ""
echo -e "${YELLOW}AUTHORIZATION${NC}"
echo " Local checks: Based on git user.email (can be bypassed)"
echo " Service-side: GitHub Actions with protected environments (enforced)"
echo " Current user: $(git config user.email 2>/dev/null || echo 'not configured')"
echo ""
echo " Note: Releases require approval on GitHub even if local checks pass."
echo " See: dev-docs/service-side-authorization.md"
echo ""
echo -e "${YELLOW}EXAMPLES${NC}"
echo -e " ${BLUE}#${NC} Create a new release"
echo " paperkit-dev release --full"
echo ""
echo -e " ${BLUE}#${NC} Bump patch version"
echo " paperkit-dev version --bump patch"
echo ""
echo -e " ${BLUE}#${NC} Set specific version"
echo " paperkit-dev version --set alpha-1.3.0"
echo ""
echo "For detailed help on a command, use: paperkit-dev <command> --help"
echo ""
}
# Version command (supports flags for update/info)
version_usage() {
echo ""
echo -e "${BLUE}════════════════════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e " ${YELLOW}${TITLE_SHORT}${NC} Version Management. ${GREEN}Current Version${NC} $VERSION"
echo ""
echo -e "${BLUE}════════════════════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "${YELLOW}USAGE${NC}"
echo " paperkit-dev version [options]"
echo ""
echo -e "${YELLOW}OPTIONS${NC}"
echo -e " ${GREEN}(no flags)${NC} Show current version"
echo -e " ${GREEN}--get${NC} Show current version"
echo -e " ${GREEN}--info${NC} Show full version info (JSON)"
echo -e " ${GREEN}--set${NC} <version> Set version (e.g., alpha-1.3.0 or 1.3.0+45)"
echo -e " ${GREEN}--bump${NC} <part> Bump semver part: ${CYAN}major${NC}, ${CYAN}minor${NC}, or ${CYAN}patch${NC}"
echo -e " ${GREEN}--build${NC} <value> Set build metadata (appends +value)"
echo -e " ${GREEN}--clear-build${NC} Remove build metadata"
echo -e " ${GREEN}--test${NC} Run version system tests"
echo ""
echo -e "${YELLOW}AUTHORIZATION${NC}"
echo " Version modification commands (--set, --bump, --build) require authorization."
echo ""
echo -e "${YELLOW}EXAMPLES${NC}"
echo -e " ${BLUE}#${NC} Show current version"
echo " paperkit-dev version"
echo ""
echo -e " ${BLUE}#${NC} Bump to next patch version"
echo " paperkit-dev version --bump patch"
echo ""
echo -e " ${BLUE}#${NC} Set specific version with build metadata"
echo " paperkit-dev version --set 1.2.3+build.456"
echo ""
}
version_command() {
local action=""
local setval=""
local bumpval=""
local buildval=""
local clear_build=false
local run_tests=false
local needs_auth=false
local bump_requested=false
local set_requested=false
local build_requested=false
while [[ $# -gt 0 ]]; do
case "$1" in
--get)
action="get"
shift
;;
--info)
action="info"
shift
;;
--set)
needs_auth=true
set_requested=true
if [[ -n "${2:-}" && ! "$2" =~ ^-- ]]; then
setval="$2"
shift 2
else
shift
fi
;;
--bump)
needs_auth=true
bump_requested=true
if [[ -n "${2:-}" && ! "$2" =~ ^-- ]]; then
bumpval="$2"
shift 2
else
shift
fi
;;
--build)
needs_auth=true
build_requested=true
if [[ -n "${2:-}" && ! "$2" =~ ^-- ]]; then
buildval="$2"
shift 2
else
shift
fi
;;
--clear-build)
needs_auth=true
clear_build=true
shift
;;
--test)
run_tests=true
shift
;;
-h|--help)
version_usage
return 0
;;
bump|set|build|major|minor|patch)
# Catch common mistake of omitting -- prefix
echo -e "${RED}Error: Invalid syntax - did you mean --${1}?${NC}"
echo ""
echo "Correct usage:"
echo -e " ${CYAN}./paperkit-dev version --bump <major|minor|patch>${NC}"
echo -e " ${CYAN}./paperkit-dev version --set <version>${NC}"
echo -e " ${CYAN}./paperkit-dev version --build <metadata>${NC}"
echo ""
echo "For more help: paperkit-dev version --help"
return 1
;;
*)
# Ignore unknown args and continue
shift
;;
esac
done
# Check authorization for modification operations
if $needs_auth; then
check_authorization || return 1
fi
# If no flags were requested, just show version (no auth needed)
if [[ -z "$action" ]] && ! $set_requested && ! $bump_requested && ! $build_requested && ! $clear_build && ! $run_tests; then
show_version
return 0
fi
local VM_SCRIPT="$SCRIPT_DIR/.paperkit/tools/version-manager.py"
local PYTHON_BIN="python3"
if [ -x "$SCRIPT_DIR/.venv/bin/python" ]; then
PYTHON_BIN="$SCRIPT_DIR/.venv/bin/python"
fi
if [ ! -f "$VM_SCRIPT" ]; then
echo -e "${RED}Error: version-manager.py not found.${NC}"
return 1
fi
# Ensure PyYAML is available for update operations
if ! "$PYTHON_BIN" -c "import yaml" 2>/dev/null; then
echo -e "${YELLOW}PyYAML is required for version updates.${NC}"
echo "Install: pip install pyyaml"
return 1
fi
if [[ "$action" == "get" ]]; then
show_version
return 0
fi
if [[ "$action" == "info" ]]; then
"$PYTHON_BIN" "$VM_SCRIPT" info
return $?
fi
# Check if --set was requested but no value provided
if $set_requested && [[ -z "$setval" ]]; then
echo -e "${RED}Error: --set requires a version value${NC}"
echo ""
echo "Examples:"
echo -e " ${CYAN}./paperkit-dev version --set alpha-1.3.0${NC}"
echo -e " ${CYAN}./paperkit-dev version --set 2.0.0${NC}"
echo -e " ${CYAN}./paperkit-dev version --set 1.2.3+build.456${NC}"
echo ""
echo "For more help: paperkit-dev version --help"
return 1
fi
if [[ -n "$setval" ]]; then
"$PYTHON_BIN" "$VM_SCRIPT" set "$setval"
return $?
fi
# Check if --bump was requested but no value provided
if $bump_requested && [[ -z "$bumpval" ]]; then
echo -e "${RED}Error: --bump requires a value${NC}"
echo ""
echo "Valid values for --bump:"
echo -e " ${CYAN}major${NC} - Bump major version (e.g., 1.2.3 → 2.0.0)"
echo -e " ${CYAN}minor${NC} - Bump minor version (e.g., 1.2.3 → 1.3.0)"
echo -e " ${CYAN}patch${NC} - Bump patch version (e.g., 1.2.3 → 1.2.4)"
echo ""
echo "Usage: paperkit-dev version --bump <major|minor|patch>"
echo "For more help: paperkit-dev version --help"
return 1
fi
if [[ -n "$bumpval" ]]; then
if [[ "$bumpval" != "major" && "$bumpval" != "minor" && "$bumpval" != "patch" ]]; then
echo -e "${RED}Error: Invalid bump value '${bumpval}'${NC}"
echo ""
echo "Valid values for --bump:"
echo -e " ${CYAN}major${NC} - Bump major version (e.g., 1.2.3 → 2.0.0)"
echo -e " ${CYAN}minor${NC} - Bump minor version (e.g., 1.2.3 → 1.3.0)"
echo -e " ${CYAN}patch${NC} - Bump patch version (e.g., 1.2.3 → 1.2.4)"
echo ""
echo "Usage: paperkit-dev version --bump <major|minor|patch>"
echo "For more help: paperkit-dev version --help"
return 1
fi
"$PYTHON_BIN" "$VM_SCRIPT" bump "$bumpval"
return $?
fi
# Check if --build was requested but no value provided
if $build_requested && [[ -z "$buildval" ]]; then
echo -e "${RED}Error: --build requires a value${NC}"
echo ""
echo "Example:"
echo -e " ${CYAN}./paperkit-dev version --build 456${NC} # Adds +456 to current version"
echo ""
echo "For more help: paperkit-dev version --help"
return 1
fi
if [[ -n "$buildval" ]]; then
local cur
cur=$("$PYTHON_BIN" "$VM_SCRIPT" get 2>/dev/null || echo "")
if [ -z "$cur" ] || [ "$cur" = "unknown" ]; then
cur=$("$SCRIPT_DIR/.paperkit/tools/get-version.sh" 2>/dev/null || echo "unknown")
fi
# Strip existing +build if present
local base_no_build="${cur%%+*}"
"$PYTHON_BIN" "$VM_SCRIPT" set "${base_no_build}+${buildval}"
return $?
fi
if $clear_build; then
local cur
cur=$("$PYTHON_BIN" "$VM_SCRIPT" get 2>/dev/null || echo "")
if [ -z "$cur" ] || [ "$cur" = "unknown" ]; then
cur=$("$SCRIPT_DIR/.paperkit/tools/get-version.sh" 2>/dev/null || echo "unknown")
fi
local base_no_build="${cur%%+*}"
"$PYTHON_BIN" "$VM_SCRIPT" set "$base_no_build"
return $?
fi
if $run_tests; then
"$PYTHON_BIN" "$VM_SCRIPT" test
return $?
fi
}
# Release management
release_usage() {
echo ""
echo -e "${BLUE}════════════════════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e " ${YELLOW}${TITLE_SHORT}${NC} Release Management"
echo ""
echo -e "${BLUE}════════════════════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "${YELLOW}USAGE${NC}"
echo " paperkit-dev release [options]"
echo ""
echo -e "${YELLOW}OPTIONS${NC}"
echo -e " ${GREEN}--tag${NC} Create and push git tag only"
echo -e " ${GREEN}--bundle${NC} Create distribution bundle only"
echo -e " ${GREEN}--full${NC} Create tag + bundle + push (complete release)"
echo -e " ${GREEN}--dry-run${NC} Show what would happen without making changes"
echo ""
echo -e "${YELLOW}AUTHORIZATION${NC}"
echo " Release commands require authorization."
echo ""
echo -e "${YELLOW}EXAMPLES${NC}"
echo -e " ${BLUE}#${NC} Complete release (recommended)"
echo " paperkit-dev release --full"
echo ""
echo -e " ${BLUE}#${NC} Preview release actions"
echo " paperkit-dev release --full --dry-run"
echo ""
echo -e " ${BLUE}#${NC} Create tag only"
echo " paperkit-dev release --tag"
echo ""
}
release_command() {
# Check authorization first
check_authorization || return 1
local do_tag=false
local do_bundle=false
local dry_run=false
while [[ $# -gt 0 ]]; do
case "$1" in
--tag)
do_tag=true
;;
--bundle)
do_bundle=true
;;
--full)
do_tag=true
do_bundle=true
;;
--dry-run)
dry_run=true
;;
-h|--help)
release_usage
return 0
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
release_usage
return 1
;;
esac
shift
done
# If no flags, show usage
if ! $do_tag && ! $do_bundle; then
release_usage
return 1
fi
# Check for uncommitted changes (unless dry-run)
if ! $dry_run; then
if ! git diff-index --quiet HEAD --; then
echo ""
echo -e "${YELLOW}⚠️ Warning: You have uncommitted changes!${NC}"
echo ""
echo "Changed files:"
git status -s
echo ""
echo "Options:"
echo -e " ${CYAN}1)${NC} Commit changes and proceed with release"
echo -e " ${CYAN}2)${NC} Ignore and proceed with release as-is"
echo -e " ${CYAN}3)${NC} Cancel release"
echo ""
read -p "Selection [3]: " change_choice
change_choice=${change_choice:-3}
case $change_choice in
1)
echo ""
read -p "Commit message: " commit_msg
if [ -z "$commit_msg" ]; then
echo -e "${RED}Error: Commit message is required.${NC}"
return 1
fi
if ! git add -A; then
echo -e "${RED}Error: Failed to stage changes.${NC}"
return 1
fi
if ! git commit -m "$commit_msg"; then
echo -e "${RED}Error: Failed to commit changes.${NC}"
return 1
fi
echo -e "${GREEN}✓${NC} Changes committed"
if ! git push origin HEAD; then
echo -e "${YELLOW}⚠️ Failed to push changes automatically.${NC}"
echo "You can push manually with: git push origin master"
fi
echo ""
;;
2)
echo -e "${YELLOW}Proceeding with uncommitted changes...${NC}"
echo ""
;;
3)
echo "Release cancelled."
return 0
;;
*)
echo -e "${RED}Invalid selection.${NC}"
return 1
;;
esac
fi
fi
# Get current version
local CURRENT_VERSION
CURRENT_VERSION=$("$SCRIPT_DIR/.paperkit/tools/get-version.sh" 2>/dev/null || echo "unknown")
if [ "$CURRENT_VERSION" = "unknown" ]; then
echo -e "${RED}Error: Unable to determine current version.${NC}"
return 1
fi
echo ""
echo -e "${BLUE}════════════════════════════════════════════════════════════════════════════${NC}"
echo -e " ${YELLOW}Release Management${NC}"
echo -e "${BLUE}════════════════════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "${GREEN}Current Version:${NC} $CURRENT_VERSION"
if $dry_run; then
echo -e "${YELLOW}Mode: DRY RUN (no changes will be made)${NC}"
fi
echo ""
# Create git tag
if $do_tag; then
echo -e "${YELLOW}Creating git tag: ${CURRENT_VERSION}${NC}"
if $dry_run; then
echo " [dry-run] Would create annotated tag: $CURRENT_VERSION"
echo " [dry-run] Would push tag to origin"
else
# Check if tag already exists
if git rev-parse "$CURRENT_VERSION" >/dev/null 2>&1; then
echo -e "${RED}Error: Tag $CURRENT_VERSION already exists.${NC}"
echo "Use 'paperkit-dev version --bump <part>' to create a new version first."
return 1
fi
# Create annotated tag
if git tag -a "$CURRENT_VERSION" -m "Release $CURRENT_VERSION"; then
echo -e "${GREEN}✓${NC} Created tag: $CURRENT_VERSION"
# Push tag to remote
if git push origin "$CURRENT_VERSION"; then
echo -e "${GREEN}✓${NC} Pushed tag to origin"
else
echo -e "${RED}Error: Failed to push tag to origin.${NC}"
return 1
fi
else
echo -e "${RED}Error: Failed to create tag.${NC}"
return 1
fi
fi
echo ""
fi
# Create distribution bundle
if $do_bundle; then
echo -e "${YELLOW}Creating distribution bundle${NC}"
local BUNDLE_SCRIPT="$SCRIPT_DIR/.paperkit/tools/bundle.sh"
if [ ! -f "$BUNDLE_SCRIPT" ]; then
echo -e "${RED}Error: bundle.sh not found at $BUNDLE_SCRIPT${NC}"
return 1
fi
if $dry_run; then
echo " [dry-run] Would run: $BUNDLE_SCRIPT"
echo " [dry-run] Would create: paperkit-${CURRENT_VERSION}.tar.gz"
else
if bash "$BUNDLE_SCRIPT"; then
echo -e "${GREEN}✓${NC} Created distribution bundle"
else
echo -e "${RED}Error: Failed to create distribution bundle.${NC}"
return 1
fi
fi
echo ""
fi
# Create GitHub release (if both tag and bundle were created)
if $do_tag && $do_bundle && ! $dry_run; then
echo -e "${YELLOW}Creating GitHub release${NC}"
# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
echo -e "${RED}Error: GitHub CLI (gh) is not installed.${NC}"
echo "Install it from: https://cli.github.com/"
echo ""
echo "Manual steps required:"
echo " 1. Go to GitHub releases page"
echo " 2. Draft a new release from tag: ${CURRENT_VERSION}"
echo " 3. Upload the distribution bundle"
echo " 4. Publish the release"
echo ""
return 1
fi
# Check if authenticated
if ! gh auth status &> /dev/null; then
echo -e "${RED}Error: Not authenticated with GitHub CLI.${NC}"
echo "Run: gh auth login"
echo ""
echo "Manual steps required:"
echo " 1. Go to GitHub releases page"
echo " 2. Draft a new release from tag: ${CURRENT_VERSION}"
echo " 3. Upload the distribution bundle"
echo " 4. Publish the release"
echo ""
return 1
fi
local BUNDLE_FILE="$SCRIPT_DIR/paperkit-${CURRENT_VERSION}.tar.gz"
if [ ! -f "$BUNDLE_FILE" ]; then
echo -e "${RED}Error: Bundle file not found: $BUNDLE_FILE${NC}"
return 1
fi
# Generate release notes
local RELEASE_NOTES="Release $CURRENT_VERSION
**Installation:**
\`\`\`bash
tar -xzf paperkit-${CURRENT_VERSION}.tar.gz
cd paperkit-${CURRENT_VERSION}
./paperkit init
\`\`\`
**What's Changed:**
See [CHANGELOG.md](https://github.com/peternicholls/PaperKit/blob/master/CHANGELOG.md) for details.
"
# Create release with bundle
if gh release create "$CURRENT_VERSION" \
"$BUNDLE_FILE" \
--title "$CURRENT_VERSION" \
--notes "$RELEASE_NOTES"; then
echo -e "${GREEN}✓${NC} Created GitHub release"
echo -e "${GREEN}✓${NC} Uploaded distribution bundle"
# Clean up the bundle file after successful upload
if rm "$BUNDLE_FILE" 2>/dev/null; then
echo -e "${GREEN}✓${NC} Cleaned up local bundle file"
fi
else
echo -e "${RED}Error: Failed to create GitHub release.${NC}"
echo ""
echo "Manual steps required:"
echo " 1. Go to GitHub releases page"
echo " 2. Draft a new release from tag: ${CURRENT_VERSION}"
echo " 3. Upload: $BUNDLE_FILE"
echo " 4. Publish the release"
echo ""
return 1
fi
echo ""
elif $dry_run && $do_tag && $do_bundle; then
echo -e "${YELLOW}Creating GitHub release${NC}"
echo " [dry-run] Would create GitHub release: $CURRENT_VERSION"
echo " [dry-run] Would upload: paperkit-${CURRENT_VERSION}.tar.gz"
echo ""
fi
# Summary
echo -e "${GREEN}Release process complete!${NC}"
echo ""
if $do_tag && $do_bundle && ! $dry_run; then
echo "GitHub release: https://github.com/peternicholls/PaperKit/releases/tag/${CURRENT_VERSION}"
echo ""
elif $do_bundle && ! $dry_run; then
# Only show bundle path if it still exists (wasn't cleaned up)
if [ -f "$SCRIPT_DIR/paperkit-${CURRENT_VERSION}.tar.gz" ]; then
echo "Distribution bundle created:"
echo " paperkit-${CURRENT_VERSION}.tar.gz"
echo ""
fi
fi
}
# Main command dispatcher
case "${1:-help}" in
release)
shift
release_command "$@"
;;
version|--version|-v)
shift
version_command "$@"
;;
help|--help|-h|"")
show_help
;;
*)
echo -e "${RED}Unknown command: $1${NC}"
echo ""
show_help
exit 1
;;
esac