mirror of
https://github.com/olcubo/obsidian-cubox.git
synced 2026-07-22 12:20:33 +00:00
129 lines
No EOL
4.1 KiB
YAML
129 lines
No EOL
4.1 KiB
YAML
name: Release Obsidian plugin
|
||
|
||
on:
|
||
push:
|
||
tags:
|
||
- "*"
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-latest
|
||
permissions:
|
||
contents: write
|
||
steps:
|
||
- uses: actions/checkout@v3
|
||
with:
|
||
fetch-depth: 0 # 获取完整历史以确保版本信息正确
|
||
|
||
- name: Use Node.js
|
||
uses: actions/setup-node@v3
|
||
with:
|
||
node-version: "22.x"
|
||
cache: 'npm'
|
||
|
||
- name: Build plugin
|
||
run: |
|
||
npm install
|
||
npm run build
|
||
|
||
- name: Create release
|
||
env:
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||
run: |
|
||
tag="${GITHUB_REF#refs/tags/}"
|
||
|
||
# 确保版本号一致
|
||
plugin_version=$(grep '"version"' manifest.json | cut -d'"' -f4)
|
||
if [ "$tag" != "$plugin_version" ]; then
|
||
echo "Error: Tag version ($tag) does not match plugin version ($plugin_version) in manifest.json"
|
||
exit 1
|
||
fi
|
||
|
||
# 创建发布
|
||
gh release create "$tag" \
|
||
--title="$tag" \
|
||
--draft \
|
||
main.js manifest.json styles.css
|
||
|
||
- name: Send Notification
|
||
if: always()
|
||
env:
|
||
NOTIFY_WEBHOOK: ${{ vars.NOTIFY_WEBHOOK }}
|
||
run: |
|
||
tag="${GITHUB_REF#refs/tags/}"
|
||
repo_name="${GITHUB_REPOSITORY#*/}"
|
||
|
||
# 根据任务状态设置消息内容
|
||
if [ "${{ job.status }}" = "success" ]; then
|
||
status_emoji="✅"
|
||
status_text="成功"
|
||
button_text="🔍 确认发布"
|
||
header_emoji="🎉"
|
||
template_color="blue"
|
||
action_url="https://github.com/$GITHUB_REPOSITORY/releases/tag/$tag"
|
||
else
|
||
status_emoji="❌"
|
||
status_text="失败"
|
||
button_text="🔍 查看失败详情"
|
||
header_emoji="⚠️"
|
||
template_color="red"
|
||
action_url="https://github.com/$GITHUB_REPOSITORY/actions/runs/${{ github.run_id }}"
|
||
fi
|
||
|
||
# 构建飞书消息
|
||
curl -X POST -H "Content-Type: application/json" -d "{
|
||
\"msg_type\": \"interactive\",
|
||
\"card\": {
|
||
\"schema\": \"2.0\",
|
||
\"config\": {
|
||
\"update_multi\": true,
|
||
\"style\": {
|
||
\"text_size\": {
|
||
\"normal_v2\": {
|
||
\"default\": \"normal\",
|
||
\"pc\": \"normal\",
|
||
\"mobile\": \"heading\"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
\"body\": {
|
||
\"direction\": \"vertical\",
|
||
\"padding\": \"12px 12px 12px 12px\",
|
||
\"elements\": [
|
||
{
|
||
\"tag\": \"markdown\",
|
||
\"content\": \"📦 **${repo_name}** 新版本 **${tag}** 构建${status_text}\\n构建状态:${status_emoji} ${status_text}\",
|
||
\"text_align\": \"left\",
|
||
\"text_size\": \"normal_v2\",
|
||
\"margin\": \"0px 0px 0px 0px\"
|
||
},
|
||
{
|
||
\"tag\": \"button\",
|
||
\"text\": {
|
||
\"tag\": \"plain_text\",
|
||
\"content\": \"${button_text}\"
|
||
},
|
||
\"type\": \"default\",
|
||
\"width\": \"default\",
|
||
\"size\": \"medium\",
|
||
\"behaviors\": [
|
||
{
|
||
\"type\": \"open_url\",
|
||
\"default_url\": \"${action_url}\"
|
||
}
|
||
],
|
||
\"margin\": \"0px 0px 0px 0px\"
|
||
}
|
||
]
|
||
},
|
||
\"header\": {
|
||
\"title\": {
|
||
\"tag\": \"plain_text\",
|
||
\"content\": \"${header_emoji} 插件构建通知\"
|
||
},
|
||
\"template\": \"${template_color}\",
|
||
\"padding\": \"12px 12px 12px 12px\"
|
||
}
|
||
}
|
||
}" "$NOTIFY_WEBHOOK" |