Files
WeFlow/.github/workflows/release.yml
xuncha 2cfe0d8ee8 ee
2026-01-31 16:01:21 +08:00

84 lines
2.7 KiB
YAML

name: Build and Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
steps:
- name: Check out git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.20.0
cache: 'npm'
- name: Configure Windows SDK WinMD
shell: powershell
run: |
$sdkRoot = Join-Path ${env:ProgramFiles(x86)} "Windows Kits\\10"
$unionRoot = Join-Path $sdkRoot "UnionMetadata"
$refsRoot = Join-Path $sdkRoot "References"
if (!(Test-Path $unionRoot)) { throw "UnionMetadata not found at $unionRoot" }
$platformWinmd = Get-ChildItem $unionRoot -Recurse -Filter platform.winmd -ErrorAction SilentlyContinue |
Sort-Object FullName -Descending | Select-Object -First 1
if (!$platformWinmd) { throw "platform.winmd not found under $unionRoot" }
$platformDir = Split-Path $platformWinmd.FullName -Parent
$versionDir = $platformWinmd.Directory.Name
$refsDir = Join-Path $refsRoot $versionDir
if (!(Test-Path $refsDir)) {
$refsDir = Get-ChildItem $refsRoot -Directory | Sort-Object Name -Descending | Select-Object -First 1
}
if (!$refsDir) { throw "No References version directory found" }
$libPath = "$platformDir;$($refsDir.FullName)"
Add-Content -Path $env:GITHUB_ENV -Value "LIBPATH=$libPath" -Encoding utf8
Add-Content -Path $env:GITHUB_ENV -Value "WindowsSdkDir=$sdkRoot\\" -Encoding utf8
Add-Content -Path $env:GITHUB_ENV -Value "WindowsSdkVersion=$versionDir\\" -Encoding utf8
- name: Install Dependencies
run: npm ci
- name: Sync version with tag
shell: bash
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "Syncing package.json version to $VERSION"
npm version $VERSION --no-git-tag-version --allow-same-version
- name: Build Frontend & Type Check
run: |
npx tsc
npx vite build
- name: Package and Publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx electron-builder --publish always
- name: Update Release Notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
cat <<EOF > release_notes.md
## 更新日志
修复了一些已知问题
## 加入我们的群
[点击加入 Telegram 群](https://t.me/+hn3QzNc4DbA0MzNl)
EOF
gh release edit "$GITHUB_REF_NAME" --notes-file release_notes.md