mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-15 23:31:10 +00:00
chore(cli): update .npmignore and add release scripts
- Remove "还未发布" from .npmignore, add src/ to excludes - Add scripts/notify-feishu.sh for Feishu bot release notifications - Add scripts/release-cli.sh for one-click CLI release workflow
This commit is contained in:
parent
39db503700
commit
ea4e206ad6
3 changed files with 152 additions and 1 deletions
91
scripts/notify-feishu.sh
Executable file
91
scripts/notify-feishu.sh
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash
|
||||
# Send skillhub-cli release notification to Feishu group via bot webhook
|
||||
# Usage: FEISHU_WEBHOOK_URL=xxx ./scripts/notify-feishu.sh <version> [prev_version]
|
||||
set -euo pipefail
|
||||
|
||||
WEBHOOK_URL="${FEISHU_WEBHOOK_URL:-}"
|
||||
VERSION="${1:-}"
|
||||
PREV_VERSION="${2:-}"
|
||||
|
||||
if [ -z "$WEBHOOK_URL" ]; then
|
||||
echo "Error: FEISHU_WEBHOOK_URL is not set"
|
||||
echo "Usage: FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxx $0 <version> [prev_version]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Error: version is required"
|
||||
echo "Usage: $0 <version> [prev_version]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate changelog from git log
|
||||
if [ -n "$PREV_VERSION" ]; then
|
||||
RANGE="skillhub-cli/v${PREV_VERSION}..HEAD"
|
||||
else
|
||||
# If no prev version, use last 20 commits touching skillhub-cli/
|
||||
RANGE="HEAD~20..HEAD"
|
||||
fi
|
||||
|
||||
# Extract changelog lines, escape for JSON
|
||||
CHANGELOG=$(git log "$RANGE" --oneline --no-merges -- skillhub-cli/ 2>/dev/null | head -20 | \
|
||||
sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/' | tr -d '\n' | sed 's/\\n$//')
|
||||
|
||||
if [ -z "$CHANGELOG" ]; then
|
||||
CHANGELOG="详见 npm 页面"
|
||||
fi
|
||||
|
||||
BODY=$(cat <<EOF
|
||||
{
|
||||
"msg_type": "interactive",
|
||||
"card": {
|
||||
"header": {
|
||||
"title": {
|
||||
"tag": "plain_text",
|
||||
"content": "skillhub-cli v${VERSION} 发布"
|
||||
},
|
||||
"template": "green"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"tag": "div",
|
||||
"text": {
|
||||
"tag": "lark_md",
|
||||
"content": "**更新内容:**\n${CHANGELOG}\n\n**安装/更新:**\n\`npm install -g motovis-skillhub\`"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "action",
|
||||
"actions": [
|
||||
{
|
||||
"tag": "button",
|
||||
"text": {
|
||||
"tag": "plain_text",
|
||||
"content": "npm 页面"
|
||||
},
|
||||
"url": "https://www.npmjs.com/package/motovis-skillhub",
|
||||
"type": "primary"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$WEBHOOK_URL" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$BODY")
|
||||
|
||||
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
|
||||
BODY_RESPONSE=$(echo "$RESPONSE" | sed '$d')
|
||||
|
||||
if [ "$HTTP_CODE" -eq 200 ]; then
|
||||
echo "Feishu notification sent successfully"
|
||||
echo "$BODY_RESPONSE"
|
||||
else
|
||||
echo "Failed to send Feishu notification (HTTP $HTTP_CODE)"
|
||||
echo "$BODY_RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
60
scripts/release-cli.sh
Executable file
60
scripts/release-cli.sh
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
#!/bin/bash
|
||||
# Release skillhub-cli: build, test, version bump, publish, notify
|
||||
# Usage: ./scripts/release-cli.sh [patch|minor|major] [prev_version]
|
||||
# Examples:
|
||||
# ./scripts/release-cli.sh patch # 1.0.7 -> 1.0.8
|
||||
# ./scripts/release-cli.sh minor # 1.0.7 -> 1.1.0
|
||||
# ./scripts/release-cli.sh patch 1.0.6 # with prev_version for changelog
|
||||
set -euo pipefail
|
||||
|
||||
BUMP="${1:-patch}"
|
||||
PREV_VERSION="${2:-}"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
CLI_DIR="$PROJECT_DIR/skillhub-cli"
|
||||
|
||||
echo "=== skillhub-cli release ==="
|
||||
echo ""
|
||||
|
||||
# Step 1: Build
|
||||
echo "[1/5] Building..."
|
||||
cd "$CLI_DIR"
|
||||
pnpm build
|
||||
echo "Build OK"
|
||||
echo ""
|
||||
|
||||
# Step 2: Run tests
|
||||
echo "[2/5] Running tests..."
|
||||
if pnpm test; then
|
||||
echo "Tests OK"
|
||||
else
|
||||
echo "Tests FAILED. Aborting release."
|
||||
exit 1
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Step 3: Bump version
|
||||
OLD_VERSION=$(node -p "require('./package.json').version")
|
||||
npm version "$BUMP" --no-git-tag-version -m "chore(cli): release v%s"
|
||||
NEW_VERSION=$(node -p "require('./package.json').version")
|
||||
echo "[3/5] Version bumped: $OLD_VERSION -> $NEW_VERSION"
|
||||
echo ""
|
||||
|
||||
# Step 4: Publish
|
||||
echo "[4/5] Publishing to npm..."
|
||||
npm publish --access public
|
||||
echo "Published motovis-skillhub@$NEW_VERSION"
|
||||
echo ""
|
||||
|
||||
# Step 5: Notify via Feishu
|
||||
echo "[5/5] Sending Feishu notification..."
|
||||
if [ -n "${FEISHU_WEBHOOK_URL:-}" ]; then
|
||||
"$SCRIPT_DIR/notify-feishu.sh" "$NEW_VERSION" "$PREV_VERSION"
|
||||
else
|
||||
echo "FEISHU_WEBHOOK_URL not set, skipping notification"
|
||||
echo "To send manually: FEISHU_WEBHOOK_URL=xxx $SCRIPT_DIR/notify-feishu.sh $NEW_VERSION $PREV_VERSION"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "=== Release complete: v$NEW_VERSION ==="
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
tmp/
|
||||
还未发布
|
||||
tests/
|
||||
vitest.config.ts
|
||||
unbuild.config.ts
|
||||
tsconfig.json
|
||||
*.test.ts
|
||||
src/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue