add github action

This commit is contained in:
delphi 2025-03-19 12:40:27 +08:00
parent 3ede3699e8
commit b74cf44450

46
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,46 @@
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: "18.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