Skip to content

version:升级到1.1.1 #18

version:升级到1.1.1

version:升级到1.1.1 #18

Workflow file for this run

name: Release FluxBrowser
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: windows-latest
permissions:
contents: write # 必须赋予写入权限,否则无法创建 Release
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install Dependencies
run: npm install
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
# 1. 安全地获取提交范围
$currentTag = "${{ github.ref_name }}"
# 使用引号包裹变量和 ^,防止 PowerShell 解析错误
$prevTag = git describe --tags --abbrev=0 "$currentTag^" 2>$null
# 2. 根据是否有上一个标签决定 log 范围
if ($prevTag) {
$range = "$prevTag..$currentTag"
$commits = git log $range --pretty=format:"%s"
} else {
$commits = git log --pretty=format:"%s"
}
# 3. 定义提取函数 (增加对空提交记录的防御)
function Get-Group($prefix, $title) {
if (-not $commits) { return "" }
$pattern = "^$prefix[:\(]"
$matched = $commits | Where-Object { $_ -match $pattern }
if ($matched) {
$lines = $matched | ForEach-Object { "* $_" }
return "### $title`n$($lines -join "`n")`n`n"
}
return ""
}
# 4. 拼装内容
$body = "## 📝 更新日志 ($currentTag)`n`n"
$body += Get-Group "feat" "🚀 新特性"
$body += Get-Group "improve" "⚡ 改进"
$body += Get-Group "fix" "🐛 修复"
$body += Get-Group "refactor" "🛠️ 重构"
$body += Get-Group "chore" "🧹 琐事"
$body += Get-Group "version" "🔖 版本更新"
# 5. 兜底:抓取不符合规范的提交
if ($commits) {
$others = $commits | Where-Object {
$_ -notmatch "^(feat|fix|improve|chore|refactor|version)[:\(]"
}
if ($others) {
$otherLines = $others | ForEach-Object { "* $_" }
$body += "### 🔍 其他改动`n$($otherLines -join "`n")"
}
}
# 6. 写入文件 (强制 UTF-8 无 BOM)
$path = "$PWD/release_notes.md"
[System.IO.File]::WriteAllText($path, $body, [System.Text.Encoding]::UTF8)
# 7. 创建 Release
gh release create $currentTag --title "Release $currentTag" --notes-file $path --latest
- name: Build and Publish Electron App
run: npm run build -- --publish always
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}