Add release workflow

This commit is contained in:
Ke Yan 2025-03-08 23:46:55 +08:00
parent b8e2e0db6a
commit 050dccde1c
2 changed files with 72 additions and 0 deletions

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

@ -0,0 +1,38 @@
name: Release Obsidian plugin
on:
push:
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Build plugin
run: |
npm install
npm run build
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
mkdir ${{ github.event.repository.name }}
cp main.js manifest.json README.md LICENSE ${{ github.event.repository.name }}
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
gh release create "$tag" \
--title "$tag" \
--notes "Release $tag" \
${{ github.event.repository.name }}.zip main.js manifest.json

34
release.bat Normal file
View file

@ -0,0 +1,34 @@
@echo off
setlocal
echo Obsidian插件发布助手
set /p VERSION="请输入新版本号 (例如 1.0.1): "
echo.
echo 正在更新版本号到 %VERSION%...
call npm version %VERSION% --no-git-tag-version
echo.
echo 正在运行版本更新脚本...
node version-bump.mjs %VERSION%
echo.
echo 正在提交更改...
git add .
git commit -m "版本 %VERSION%"
echo.
echo 正在创建标签...
git tag -a "%VERSION%" -m "版本 %VERSION%"
echo.
echo 正在推送更改和标签到GitHub...
git push
git push --tags
echo.
echo 完成GitHub Actions将自动构建并发布版本 %VERSION%
echo 请访问GitHub仓库查看发布状态。
pause