Skip to content

修复 9 处 bug + 桌面显示修复,版本 2.4.0-beta #62

修复 9 处 bug + 桌面显示修复,版本 2.4.0-beta

修复 9 处 bug + 桌面显示修复,版本 2.4.0-beta #62

name: Build & Release (Avalonia)
on:
push:
branches: [ "main" ]
paths-ignore:
- '**.md'
- 'schedule_example.json'
- '.workbuddy/**'
- '.gitignore'
pull_request:
branches: [ "main" ]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
env:
Project_Path: StudyJourney.Avalonia/StudyJourney.Avalonia.csproj
Updater_Path: Updater/StudyJourney.Updater.csproj
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
# 读取版本号(支持 2.0.0-beta 这种预发布格式),并判断是否 prerelease
- name: Read version from csproj
id: version
shell: pwsh
run: |
$xml = [xml](Get-Content "${{ env.Project_Path }}")
$ver = [string]$xml.Project.PropertyGroup.Version
if ([string]::IsNullOrWhiteSpace($ver)) { $ver = "2.0.0-beta" }
$ver = $ver.Trim()
$isPre = $ver -match '(alpha|beta|rc|pre)'
echo "version=$ver" >> $env:GITHUB_OUTPUT
echo "prerelease=$isPre" >> $env:GITHUB_OUTPUT
Write-Host "Version: $ver (prerelease: $isPre)"
- name: Restore
run: dotnet restore ${{ env.Project_Path }}
- name: Build (Debug)
run: dotnet build ${{ env.Project_Path }} -c Debug --no-restore
# ── 发布主应用(自包含 + 框架依赖) ──
- name: Publish (Self-contained, x64)
run: dotnet publish ${{ env.Project_Path }} -c Release -r win-x64 --self-contained true -o publish/sc
- name: Publish (Framework-dependent, x64)
run: dotnet publish ${{ env.Project_Path }} -c Release -r win-x64 --self-contained false -o publish/fd
- name: Publish Updater (Self-contained)
run: dotnet publish ${{ env.Updater_Path }} -c Release -r win-x64 --self-contained true -o publish/updater-sc
- name: Publish Updater (Framework-dependent)
run: dotnet publish ${{ env.Updater_Path }} -c Release -r win-x64 --self-contained false -o publish/updater-fd
- name: Copy Updater to both outputs
shell: pwsh
run: |
Copy-Item -Path publish\updater-sc\* -Destination publish\sc\ -Recurse -Force
Copy-Item -Path publish\updater-fd\* -Destination publish\fd\ -Recurse -Force
# ── 打包(带版本号) ──
- name: Pack SC zip
shell: pwsh
run: |
cd publish\sc
powershell Compress-Archive -Path * -DestinationPath ..\..\StudyJourney-v${{ steps.version.outputs.version }}-win-x64.zip
- name: Pack FD zip
shell: pwsh
run: |
cd publish\fd
powershell Compress-Archive -Path * -DestinationPath ..\..\StudyJourney-v${{ steps.version.outputs.version }}-win-x64-fd.zip
- name: Create Release & Upload
if: github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
name: 学程 v${{ steps.version.outputs.version }}
tag_name: v${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
body: |
## 学程 v${{ steps.version.outputs.version }}(Avalonia 新框架)
**自包含版** (`-win-x64.zip`):无需安装 .NET,直接运行。体积较大。
**框架依赖版** (`-win-x64-fd.zip`):需安装 [.NET 10 桌面运行时](https://dotnet.microsoft.com/download/dotnet/10.0)。体积较小。
${{ steps.version.outputs.prerelease == 'true' && '> ⚠️ 这是预发布测试版,可能存在未修复的小问题。' || '' }}
> 自动构建 · `${{ github.sha }}`
> ${{ github.event.head_commit.message }}
files: |
StudyJourney-v${{ steps.version.outputs.version }}-win-x64.zip
StudyJourney-v${{ steps.version.outputs.version }}-win-x64-fd.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload SC artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: StudyJourney-v${{ steps.version.outputs.version }}-win-x64
path: publish/sc/
- name: Upload FD artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: StudyJourney-v${{ steps.version.outputs.version }}-win-x64-fd
path: publish/fd/