-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·81 lines (74 loc) · 1.94 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·81 lines (74 loc) · 1.94 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
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$SCRIPT_DIR"
cd "$ROOT_DIR"
# 使用 nvm 切换 Node.js 版本
use_nvm() {
if [ -f .nvmrc ]; then
local NVM_VERSION=$(cat .nvmrc | tr -d '\n')
echo "Using Node.js version from .nvmrc: $NVM_VERSION"
# 检查 nvm 是否安装
if command -v nvm &> /dev/null || [ -n "$NVM_DIR" ]; then
nvm use "$NVM_VERSION" 2>/dev/null || {
echo "Warning: nvm version '$NVM_VERSION' not installed, using current version"
}
else
echo "Warning: nvm not installed, skipping version switch"
fi
fi
}
# 检查 npm token
check_npm_token() {
if [ "$1" = "publish" ]; then
if [ -z "$NPM_TOKEN" ]; then
echo "Error: NPM_TOKEN environment variable is not set"
echo ""
echo "To fix this, run:"
echo " export NPM_TOKEN='npm_xxxxxxxxxxxxxxxxxxxxx'"
echo ""
echo "Or login to npm:"
echo " npm login"
echo ""
exit 1
fi
echo "NPM token found, authentication configured"
fi
}
case "$1" in
version)
echo "Applying version changes..."
pnpm changeset version "${@:2}"
echo "Installing dependencies..."
pnpm install
;;
publish)
check_npm_token publish
use_nvm
echo "Publishing packages..."
pnpm changeset publish "${@:2}"
;;
add)
echo "Adding changeset..."
pnpm changeset add "${@:2}"
;;
pre)
echo "Entering pre-release mode..."
pnpm changeset pre "${@:2}"
;;
status)
echo "Checking changeset status..."
pnpm changeset status "${@:2}"
;;
*)
echo "Usage: ./release.sh <command>"
echo ""
echo "Commands:"
echo " version - Apply version changes from changesets"
echo " publish - Publish packages to npm"
echo " add - Add a new changeset"
echo " pre - Enter pre-release mode (pre major/minor/patch)"
echo " status - Check the status of changesets"
exit 1
;;
esac