修改天气组件,ci工作流
This commit is contained in:
lincube
2026-03-04 02:02:34 +08:00
parent 094745122e
commit e8276c4d1e
58 changed files with 7941 additions and 1499 deletions

24
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,24 @@
# CODEOWNERS for LanMontainDesktop
# Default owners for everything
* @
# Desktop UI & Components
/LanMontainDesktop/Views/ @
/LanMontainDesktop/ViewModels/ @
/LanMontainDesktop/ComponentSystem/ @
/LanMontainDesktop/Styles/ @
/LanMontainDesktop/Controls/ @
# Backend Services
/LanMontainDesktop/Services/ @
/LanMontainDesktop.RecommendationBackend/ @
# Documentation
/docs/ @
/README.md @
# Build & CI/CD
/.github/ @
/scripts/ @
/LanMontainDesktop/LanMontainDesktop.csproj @

34
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,34 @@
---
name: Bug Report
about: Create a report to help us improve
title: "[BUG] "
labels: bug
assignees: ''
---
## Describe the bug
A clear and concise description of what the bug is.
## Expected behavior
What did you expect to happen?
## Actual behavior
What actually happened?
## Steps to reproduce
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Environment
- OS: [e.g. Windows 10, Windows 11]
- Version: [e.g. 1.0.0]
- .NET Version: [e.g. 10.0]
## Screenshots
If applicable, add screenshots to help explain your problem.
## Additional context
Add any other context about the problem here.

36
.github/ISSUE_TEMPLATE/config_issue.md vendored Normal file
View File

@@ -0,0 +1,36 @@
---
name: Config Issue
about: Report configuration or build issues
title: "[CONFIG] "
labels: configuration
assignees: ''
---
## Describe the configuration issue
A clear description of the configuration or build problem.
## Environment Details
- OS: [e.g. Windows 10/11, Linux, macOS]
- .NET SDK Version: [output of `dotnet --version`]
- Visual Studio Version: [if applicable]
- Project Configuration: [e.g., Debug/Release]
## Steps to reproduce
1. ...
2. ...
## Expected result
What should happen?
## Actual result
What actually happens?
## Configuration files
If applicable, share relevant configuration:
- `.csproj` settings (without sensitive data)
- Build parameters
- Environment variables set
## Additional context
Add any other relevant information.

View File

@@ -0,0 +1,25 @@
---
name: Feature Request
about: Suggest an idea for this project
title: "[FEATURE] "
labels: enhancement
assignees: ''
---
## Is your feature request related to a problem?
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
## Describe the solution you'd like
A clear and concise description of what you want to happen.
## Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
## Additional context
Add any other context or screenshots about the feature request here.
## Priority
- [ ] Low - Nice to have
- [ ] Medium - Would improve usability
- [ ] High - Essential feature

295
.github/MULTIPLATFORM_BUILD.md vendored Normal file
View File

@@ -0,0 +1,295 @@
# Multi-Platform Build Guide
This document explains how to build LanMontainDesktop for Windows, Linux, and macOS.
## Overview
LanMontainDesktop supports self-contained builds for:
- **Windows**: x64 (64-bit) and x86 (32-bit)
- **Linux**: x64 only (AppImage/snap support planned)
- **macOS**: x64 (Intel) and arm64 (Apple Silicon M1/M2/M3)
## Build Matrices in CI
The GitHub Actions workflow uses a build matrix to automatically build all combinations:
```yaml
Windows builds: win-x64, win-x86 (on windows-latest)
Linux builds: linux-x64 (on ubuntu-latest)
macOS builds: osx-x64, osx-arm64 (on macos-latest)
```
Each build:
- ✅ Restores dependencies
- ✅ Updates version in csproj
- ✅ Publishes with optimizations
- ✅ Creates platform-specific packages
- ✅ Uploads to release artifacts
## Local Building
### Prerequisites
**All Platforms:**
```bash
# Install .NET 10 SDK
dotnet --version # Should show 10.0.x
```
**Linux (Debian/Ubuntu):**
```bash
# Install required dependencies
sudo apt-get update
sudo apt-get install -y \
libfontconfig1 \
libfreetype6 \
libx11-6 \
libxrandr2 \
libxinerama1 \
libxi6 \
libxcursor1 \
libxext6 \
libxrender1 \
libxkbcommon-x11-0
```
**macOS:**
```bash
# Xcode Command Line Tools required
xcode-select --install
# Or if you have Homebrew:
brew install dotnet
```
### Building Locally
**Windows (x64):**
```powershell
# Using the PowerShell script
.\LanMontainDesktop\scripts\package.ps1 `
-RuntimeIdentifier win-x64 `
-Version 1.0.0
# Or with dotnet directly
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj `
-c Release -r win-x64 -o ./publish/win-x64 `
--self-contained -p:PublishSingleFile=true
```
**Windows (x86):**
```powershell
.\LanMontainDesktop\scripts\package.ps1 `
-RuntimeIdentifier win-x86 `
-Version 1.0.0
```
**Linux (x64):**
```bash
# Make build script executable
chmod +x scripts/build.sh
# Build
./scripts/build.sh --rid linux-x64 --version 1.0.0
# Output: ./publish/linux-x64/
```
**macOS (Intel x64):**
```bash
chmod +x scripts/build.sh
./scripts/build.sh --rid osx-x64 --version 1.0.0
# Output: ./publish/osx-x64/
```
**macOS (Apple Silicon arm64):**
```bash
chmod +x scripts/build.sh
./scripts/build.sh --rid osx-arm64 --version 1.0.0
# Output: ./publish/osx-arm64/
```
## Build Output
After building, you'll have a self-contained directory with:
```
publish/[rid]/
├── LanMontainDesktop.exe (Windows)
├── LanMontainDesktop (Linux/macOS - executable)
├── libvlc/ (Windows/macOS only)
├── Localization/ (i18n files)
├── Extensions/ (Component extension manifests)
└── Assets/ (Fonts, weather icons, etc.)
```
### Package Creation
**For Windows:**
```bash
# Create zip package
$rid = "win-x64"
$version = "1.0.0"
$dir = "LanMontainDesktop-$version-$rid"
Copy-Item -Path "./publish/$rid" -Destination $dir -Recurse
Compress-Archive -Path $dir -DestinationPath "$dir.zip"
```
**For Linux/macOS:**
```bash
# Create tar.gz package
rid=linux-x64
version=1.0.0
dir="LanMontainDesktop-$version-$rid"
mkdir -p $dir
cp -r ./publish/$rid/* $dir/
tar -czf "$dir.tar.gz" $dir
```
## Cross-Compilation Considerations
### ⚠️ Limitations
- **Windows builds must run on Windows** (or in WSL2 with additional setup)
- libvlc has platform-specific native libraries
- Windows-specific dependencies in vcpkg
- **Linux builds must run on Linux**
- Different library paths and system dependencies
- **macOS builds must run on macOS**
- Code signing / notarization (if needed) requires macOS
### ✅ Workaround Options
1. **GitHub Actions** (Recommended)
- Automatically runs on the correct OS for each build
- No local cross-compilation needed
2. **Docker** (For Linux on any platform)
- Use container-based build environment
- Example: `ghcr.io/classisland/philia-build-image:main`
3. **CI/CD Pipeline**
- Let Actions handle all platform builds
- Download artifacts locally for testing
## Platform-Specific Notes
### Windows
- Supports both x64 and x86 architectures
- Uses libvlc from `VideoLAN.LibVLC.Windows` NuGet package
- Includes MSVC runtime if needed
**Unsupported:**
- ARM64 (would need separate toolchain)
### Linux
- Tested on Ubuntu 22.04+
- Requires X11 libraries (no Wayland support yet)
- Self-contained includes .NET runtime
- Uses libvlc system libraries or bundled version
**Planned:**
- AppImage format
- Snap package
- .deb packaging
### macOS
- Supports both Intel (x64) and Apple Silicon (arm64)
- Uses libvlc from `VideoLAN.LibVLC.Mac` NuGet package
- Universal binary support (both architectures in one file) - not yet implemented
**Planned:**
- DMG packaging
- Code signing & notarization
- App Store distribution
## Troubleshooting
### Windows Build Fails
```bash
# Clean and retry
dotnet clean LanMontainDesktop/LanMontainDesktop.csproj
dotnet restore
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj -c Release -r win-x64 --self-contained
```
### Linux Build Fails
```bash
# Check dependencies are installed
ldd ./publish/linux-x64/LanMontainDesktop | grep "not found"
# Install missing libraries
sudo apt-get install -y lib[missing-name]
```
### macOS Build Fails
```bash
# Ensure correct .NET version for ARM/Intel
dotnet --version
# Try specifying explicit SDK version
export DOTNET_ROOT=/usr/local/share/dotnet
./scripts/build.sh --rid osx-arm64 --version 1.0.0
```
## Performance & Size
| Platform | RID | Size | Notes |
|----------|-----|------|-------|
| Windows x64 | win-x64 | ~150-200 MB | Includes .NET + libvlc |
| Windows x86 | win-x86 | ~140-190 MB | Smaller footprint |
| Linux x64 | linux-x64 | ~120-170 MB | Minimal deps included |
| macOS Intel | osx-x64 | ~130-180 MB | Intel-optimized |
| macOS Silicon | osx-arm64 | ~120-170 MB | Apple Silicon native |
*Sizes vary based on trimming and included dependencies*
## Optimization Options
For smaller, faster builds, you can adjust publish settings:
```bash
# Aggressive trimming (may break reflection-based features)
-p:PublishTrimmed=true
# Embed debug symbols (larger, but better debugging)
-p:DebugType=embedded
# AOT compilation (Windows only, faster startup)
-p:PublishAot=true
# Single executable (already enabled in workflows)
-p:PublishSingleFile=true
```
## Distribution
After building, distribute the packages:
1. **Windows users**: Download `.zip`, extract, run executable
2. **Linux users**: Download `.tar.gz`, extract, run executable
3. **macOS users**: Download `.tar.gz`, extract, run executable
Plan for future:
- Installer generation (.exe for Windows, .deb for Linux)
- Code signing for macOS
- Auto-update mechanism
## References
- [.NET Runtime Identifiers](https://learn.microsoft.com/dotnet/core/rid-catalog)
- [dotnet publish options](https://learn.microsoft.com/dotnet/core/tools/dotnet-publish)
- [Avalonia Deployment](https://docs.avaloniaui.net/docs/deployment)
- [libvlc Bindings](https://github.com/videolan/libvlcsharp)

254
.github/WORKFLOWS_GUIDE.md vendored Normal file
View File

@@ -0,0 +1,254 @@
# GitHub CI/CD Workflow Setup Guide
## Overview
This document describes the CI/CD workflows configured for LanMontainDesktop. These workflows are designed to maintain code quality, automate testing, and streamline the release process.
## Workflows
### 1. Build & Test (`build.yml`)
**Trigger:** Every push/PR to main branches, or manual dispatch
**What it does:**
- Builds both LanMontainDesktop and RecommendationBackend in Debug and Release modes
- Runs unit tests (if available)
- Uploads build artifacts for inspection
- Runs on Windows (windows-latest)
**Branch Coverage:** main, master, dev, develop
### 2. Code Quality (`code-quality.yml`)
**Trigger:** Pull requests and pushes to main branches, or manual dispatch
**What it does:**
- Builds projects with analysis
- Checks code formatting using `dotnet format`
- (Optional) Can integrate with Qodana for professional code analysis
**Branch Coverage:** main, master, dev, develop
**Optional: Qodana Integration**
Uncomment the Qodana step in the workflow and add your token as a secret:
```bash
# In GitHub > Settings > Secrets > Actions
QODANA_TOKEN=your_token_here
QODANA_ENDPOINT=https://qodana.cloud
```
### 3. Release & Publish (`release.yml`)
**Trigger:** Push git tags (v1.0.0, release-1.0.0), or manual workflow dispatch
**What it does:**
- Builds for **Windows** (x64, x86) - self-contained executables
- Builds for **Linux** (x64) - tar.gz packages
- Builds for **macOS** (x64, arm64) - universal support
- Publishes optimized release builds for all platforms
- Generates GitHub Release with all platform artifacts
- Supports pre-release versions
**Supported Platforms:**
| Platform | Architectures | Output Format | Status |
|----------|---------------|---------------|--------|
| Windows | x64, x86 | .zip | ✅ Full support |
| Linux | x64 | .tar.gz | ✅ Full support |
| macOS | x64, arm64 (Apple Silicon) | .tar.gz | ✅ Full support |
**Build Scripts:**
- Windows: Uses PowerShell (`LanMontainDesktop\scripts\package.ps1`)
- Linux/macOS: Uses Bash (`scripts/build.sh`)
**Usage:**
*Create a full release for all platforms:*
```bash
git tag v1.0.0
git push origin v1.0.0
# Automatically triggers Windows + Linux + macOS builds
```
*Manual trigger with selective platforms:*
Go to GitHub > Actions > Release & Publish > Run workflow
- Specify version: `1.0.0`
- Toggle build targets as needed:
- ✅ Build Windows (x64/x86)
- ✅ Build Linux (x64)
- ✅ Build macOS (x64/arm64)
- Check pre-release option if needed
### 4. Issue Management (`issue-management.yml`)
**Trigger:** Daily at 1:30 AM UTC, or manual dispatch
**What it does:**
- Automatically marks inactive issues as "stale"
- Closes old stale issues/PRs after grace period
- Issues with `need-more-info` or `waiting-for-response` labels
- Grace period: 14 days to stale, 7 days before close
- PR grace period: 21 days to stale, 14 days before close
## Repository Secrets & Configuration
To enable all workflows, configure these GitHub secrets:
### Required
None - the workflows use default GitHub token
### Optional (for enhanced features)
1. **Qodana Integration**
- Go to GitHub Settings > Secrets > Actions
- Add `QODANA_TOKEN` from https://qodana.cloud
## Local Development Setup
To align with CI workflows, set up your local environment:
```bash
# Install .NET 10 SDK
# https://dotnet.microsoft.com/download/dotnet/10.0
# Restore dependencies
dotnet restore
# Build (like CI does)
dotnet build LanMontainDesktop/LanMontainDesktop.csproj
dotnet build LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj
# Format code locally (required by CI)
dotnet format
# Run tests
dotnet test LanMontainDesktop/LanMontainDesktop.csproj
dotnet test LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj
# Alternative: Use local build scripts (Linux/macOS)
./scripts/build.sh --rid linux-x64 --version 1.0.0
./scripts/build.sh --rid osx-x64 --version 1.0.0
# Or on Windows with the PowerShell script
./LanMontainDesktop/scripts/package.ps1 -RuntimeIdentifier win-x64 -Version 1.0.0
```
### Cross-Platform Build Scripts
**Linux / macOS:**
```bash
# Make script executable first
chmod +x scripts/build.sh
# Build for Linux
./scripts/build.sh --rid linux-x64 --version 1.0.0
# Build for macOS x64
./scripts/build.sh --rid osx-x64 --version 1.0.0
# Build for macOS ARM64 (Apple Silicon)
./scripts/build.sh --rid osx-arm64 --version 1.0.0
# Full help
./scripts/build.sh --help
```
**Windows:**
```powershell
# Using PowerShell script
.\LanMontainDesktop\scripts\package.ps1 -RuntimeIdentifier win-x64 -Version 1.0.0
# Or use dotnet directly
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj `
-c Release -r win-x64 -o ./publish/win-x64 `
-p:PublishSingleFile=true --self-contained
```
## Pull Request Process
1. **Create a branch** from `dev` or `develop`
```bash
git checkout -b feature/your-feature
```
2. **Make your changes** and test locally
```bash
dotnet build
dotnet format # Important!
dotnet test
```
3. **Push and create a PR**
- The PR template will guide you
- Fill out all required sections
- Link related issues
4. **Checks will run automatically:**
- CI builds in Debug & Release
- Code quality checks
- Code formatting validation
5. **Review and merge**
- Address any feedback
- Wait for all checks to pass
- Merge to `dev` or `main` as appropriate
## Release Process
### For Stable Releases
```bash
# On main branch
git tag v1.0.0
git push origin v1.0.0
# GitHub Actions will automatically create the release
```
### For Pre-releases
1. Go to Actions tab
2. Select "Release & Publish" workflow
3. Click "Run workflow"
4. Enter version (e.g., 1.0.0-beta)
5. Check "Mark as pre-release"
6. Click "Run workflow"
## Monitoring
### Status Badge
Add to your README.md:
```markdown
![Build Status](https://github.com/YOUR_ORG/LanMontainDesktop/workflows/Build%20&%20Test/badge.svg)
```
### Check Workflow Status
- GitHub > Actions tab
- View workflow runs and logs
- See build artifacts
## Troubleshooting
### Build Failures
1. Check the workflow logs in GitHub Actions
2. Try building locally with same .NET version
3. Ensure all submodules are initialized: `git clone --recursive`
### PR Checks Not Running
- Ensure branch is up-to-date with main
- Review branch protection rules in Settings
- Check if workflows are enabled in Actions
### Release Creation Failed
- Verify tag format (v*.* or release-*.*)
- Check that csproj files are in correct format
- Review workflow output for specific errors
## Future Enhancements
Consider adding:
- Test coverage reporting
- Performance benchmarking
- Automated versioning (CalVer/SemVer)
- Multi-platform builds (Linux, macOS)
- Installer generation (.exe, .msi)
- Automated changelog generation
- Docker images for backend
## References
- [GitHub Actions Documentation](https://docs.github.com/actions)
- [ClassIsland CI/CD Setup](https://github.com/ClassIsland/ClassIsland) (reference project)
- [.NET Build & Deploy](https://learn.microsoft.com/dotnet/devops/build-cross-platform)
- [Avalonia Desktop Deployment](https://docs.avaloniaui.net/docs/deployment)

34
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,34 @@
## Description
Please include a summary of the changes and related context. Describe the "why" behind your changes.
## Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation update
## Related Issues
Fixes #(issue number)
## Testing
Please describe the testing you've done to verify the changes:
- [ ] Built successfully
- [ ] Tested on Windows
- [ ] No new warnings or errors introduced
- [ ] Backward compatible
## Screenshots/Videos (if applicable)
If your changes include UI modifications, please attach screenshots or videos.
## Checklist
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have tested my changes thoroughly
- [ ] New and existing unit tests pass locally with my changes
- [ ] I have added tests that prove my fix is effective or that my feature works
## Additional context
Add any other context about the PR here.

56
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
name: Build & Test
on:
push:
branches: [ main, master, dev, develop ]
pull_request:
branches: [ main, master, dev, develop ]
workflow_dispatch:
env:
DOTNET_VERSION: '10.0.x'
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
configuration: [ Debug, Release ]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore
- name: Build LanMontainDesktop
run: dotnet build LanMontainDesktop/LanMontainDesktop.csproj -c ${{ matrix.configuration }} --no-restore
- name: Build RecommendationBackend
run: dotnet build LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj -c ${{ matrix.configuration }} --no-restore
- name: Test LanMontainDesktop
run: dotnet test LanMontainDesktop/LanMontainDesktop.csproj -c ${{ matrix.configuration }} --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" || true
- name: Test RecommendationBackend
run: dotnet test LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj -c ${{ matrix.configuration }} --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" || true
- name: Upload build artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: build-output-${{ matrix.configuration }}
path: |
LanMontainDesktop/bin/${{ matrix.configuration }}/
LanMontainDesktop.RecommendationBackend/bin/${{ matrix.configuration }}/
retention-days: 7

74
.github/workflows/code-quality.yml vendored Normal file
View File

@@ -0,0 +1,74 @@
name: Code Quality
on:
workflow_dispatch:
pull_request:
branches: [ main, master, dev, develop ]
push:
branches: [ main, master, dev, develop ]
env:
DOTNET_VERSION: '10.0.x'
jobs:
code-analysis:
runs-on: windows-latest
permissions:
contents: read
pull-requests: write
checks: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore
- name: Build projects
run: |
dotnet build LanMontainDesktop/LanMontainDesktop.csproj
dotnet build LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj
# 可以添加Qodana检查如果配置了token
# - name: Run Qodana Analysis
# uses: JetBrains/qodana-action@v2025.1
# with:
# pr-mode: true
# env:
# QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
# QODANA_ENDPOINT: 'https://qodana.cloud'
dotnet-format:
runs-on: windows-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore
- name: Check code formatting
run: |
dotnet format --verify-no-changes --verbosity diagnostic || (
echo "::warning::Code formatting issues detected. Please run 'dotnet format' locally."
exit 0
)

37
.github/workflows/issue-management.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: Issue Management
on:
workflow_dispatch:
schedule:
# Every day at 1:30 AM UTC
- cron: "30 1 * * *"
jobs:
close-stale-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Close stale issues
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
any-of-labels: 'need-more-info,waiting-for-response'
days-before-issue-stale: 14
days-before-issue-close: 7
days-before-pr-stale: 21
days-before-pr-close: 14
stale-issue-label: 'stale'
stale-pr-label: 'stale'
stale-issue-message: |
This issue has been inactive for 14 days.
It will be closed in 7 days if there's no activity.
Please comment to keep it open.
stale-pr-message: |
This PR has been inactive for 21 days.
It will be closed in 14 days if there's no activity.
Please comment or update the PR to keep it open.
close-issue-message: 'Closed due to inactivity. Feel free to reopen if needed.'
close-pr-message: 'Closed due to inactivity. Feel free to reopen if needed.'

348
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,348 @@
name: Release & Publish (Multi-Platform)
on:
push:
tags:
- 'v*'
- 'release-*'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.0.0)'
required: true
type: string
is_prerelease:
description: 'Mark as pre-release'
required: false
type: boolean
default: false
build_windows:
description: 'Build Windows (x64/x86)'
required: false
type: boolean
default: true
build_linux:
description: 'Build Linux (x64)'
required: false
type: boolean
default: true
build_macos:
description: 'Build macOS (x64/arm64)'
required: false
type: boolean
default: true
env:
DOTNET_VERSION: '10.0.x'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
is_prerelease: ${{ steps.version.outputs.is_prerelease }}
build_windows: ${{ steps.versions.outputs.build_windows }}
build_linux: ${{ steps.versions.outputs.build_linux }}
build_macos: ${{ steps.versions.outputs.build_macos }}
steps:
- name: Get version from tag or input
id: version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=${{ github.event.inputs.version }}
fi
VERSION=${VERSION#v}
IS_PRERELEASE=${{ github.event.inputs.is_prerelease }}
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "is_prerelease=${IS_PRERELEASE}" >> $GITHUB_OUTPUT
- name: Determine build targets
id: versions
shell: bash
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "build_windows=true" >> $GITHUB_OUTPUT
echo "build_linux=true" >> $GITHUB_OUTPUT
echo "build_macos=true" >> $GITHUB_OUTPUT
else
echo "build_windows=${{ github.event.inputs.build_windows }}" >> $GITHUB_OUTPUT
echo "build_linux=${{ github.event.inputs.build_linux }}" >> $GITHUB_OUTPUT
echo "build_macos=${{ github.event.inputs.build_macos }}" >> $GITHUB_OUTPUT
fi
build-windows:
if: needs.prepare.outputs.build_windows == 'true'
needs: prepare
runs-on: windows-latest
strategy:
matrix:
arch: [ x64, x86 ]
include:
- arch: x64
rid: win-x64
- arch: x86
rid: win-x86
name: Build Windows (${{ matrix.arch }})
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Update version in csproj
run: |
$version = "${{ needs.prepare.outputs.version }}"
(Get-Content LanMontainDesktop/LanMontainDesktop.csproj) -replace '(<Version>)[^<]*(</Version>)', "`$1$version`$2" | Set-Content LanMontainDesktop/LanMontainDesktop.csproj
(Get-Content LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj) -replace '(<Version>)[^<]*(</Version>)', "`$1$version`$2" | Set-Content LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj
shell: pwsh
- name: Restore dependencies
run: dotnet restore
- name: Publish LanMontainDesktop
run: |
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj `
-c Release `
-o ./publish/${{ matrix.rid }} `
-r ${{ matrix.rid }} `
--self-contained `
-p:PublishSingleFile=true `
-p:PublishTrimmed=false `
-p:IncludeNativeLibrariesForSelfExtract=true
shell: pwsh
- name: Create Windows package
run: |
$packageDir = "LanMontainDesktop-${{ needs.prepare.outputs.version }}-${{ matrix.rid }}"
New-Item -ItemType Directory -Path $packageDir -Force | Out-Null
Copy-Item "./publish/${{ matrix.rid }}/*" -Destination $packageDir -Recurse -Force
Compress-Archive -Path $packageDir -DestinationPath "$packageDir.zip" -Force
Write-Host "✅ Package created: $packageDir.zip"
shell: pwsh
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-windows-${{ matrix.arch }}
path: LanMontainDesktop-*.zip
retention-days: 30
build-linux:
if: needs.prepare.outputs.build_linux == 'true'
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ x64 ]
include:
- arch: x64
rid: linux-x64
name: Build Linux (${{ matrix.arch }})
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libfontconfig1 \
libfreetype6 \
libx11-6 \
libxrandr2 \
libxinerama1 \
libxi6 \
libxcursor1 \
libxext6 \
libxrender1 \
libxkbcommon-x11-0
- name: Update version in csproj
run: |
sed -i 's/<Version>[^<]*<\/Version>/<Version>${{ needs.prepare.outputs.version }}<\/Version>/g' LanMontainDesktop/LanMontainDesktop.csproj
sed -i 's/<Version>[^<]*<\/Version>/<Version>${{ needs.prepare.outputs.version }}<\/Version>/g' LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj
- name: Restore dependencies
run: dotnet restore
- name: Publish LanMontainDesktop
run: |
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj \
-c Release \
-o ./publish/${{ matrix.rid }} \
-r ${{ matrix.rid }} \
--self-contained \
-p:PublishSingleFile=true \
-p:PublishTrimmed=false
- name: Create Linux packages
run: |
PACKAGE_DIR="LanMontainDesktop-${{ needs.prepare.outputs.version }}-${{ matrix.rid }}"
mkdir -p "$PACKAGE_DIR"
cp -r "./publish/${{ matrix.rid }}"/* "$PACKAGE_DIR/"
# Create tar.gz
tar -czf "$PACKAGE_DIR.tar.gz" "$PACKAGE_DIR"
echo "✅ Created: $PACKAGE_DIR.tar.gz"
# Optional: Create AppImage (requires specific tools)
# This is commented out as it requires additional dependencies
# appimage-builder or similar tools would go here
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-linux-${{ matrix.arch }}
path: LanMontainDesktop-*.tar.gz
retention-days: 30
build-macos:
if: needs.prepare.outputs.build_macos == 'true'
needs: prepare
runs-on: macos-latest
strategy:
matrix:
arch: [ x64, arm64 ]
include:
- arch: x64
rid: osx-x64
- arch: arm64
rid: osx-arm64
name: Build macOS (${{ matrix.arch }})
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Update version in csproj
run: |
sed -i '' 's/<Version>[^<]*<\/Version>/<Version>${{ needs.prepare.outputs.version }}<\/Version>/g' LanMontainDesktop/LanMontainDesktop.csproj
sed -i '' 's/<Version>[^<]*<\/Version>/<Version>${{ needs.prepare.outputs.version }}<\/Version>/g' LanMontainDesktop.RecommendationBackend/LanMontainDesktop.RecommendationBackend.csproj
- name: Restore dependencies
run: dotnet restore
- name: Publish LanMontainDesktop
run: |
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj \
-c Release \
-o ./publish/${{ matrix.rid }} \
-r ${{ matrix.rid }} \
--self-contained \
-p:PublishSingleFile=true \
-p:PublishTrimmed=false
- name: Create macOS packages
run: |
PACKAGE_DIR="LanMontainDesktop-${{ needs.prepare.outputs.version }}-${{ matrix.rid }}"
mkdir -p "$PACKAGE_DIR"
cp -r "./publish/${{ matrix.rid }}"/* "$PACKAGE_DIR/"
# Create tar.gz
tar -czf "$PACKAGE_DIR.tar.gz" "$PACKAGE_DIR"
echo "✅ Created: $PACKAGE_DIR.tar.gz"
# Optional: Create DMG (requires additional tools)
# DMG creation would go here if needed
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-macos-${{ matrix.arch }}
path: LanMontainDesktop-*.tar.gz
retention-days: 30
create-release:
needs: prepare
if: always()
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./release-artifacts
pattern: release-*
- name: List downloaded artifacts
run: |
echo "📦 Downloaded artifacts:"
find ./release-artifacts -type f -name "*.zip" -o -name "*.tar.gz" | sort
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
release-artifacts/**/*.zip
release-artifacts/**/*.tar.gz
draft: false
prerelease: ${{ needs.prepare.outputs.is_prerelease }}
body: |
## Release ${{ needs.prepare.outputs.version }}
### 📥 Downloads
**Windows:**
- `LanMontainDesktop-${{ needs.prepare.outputs.version }}-win-x64.zip` - Windows 64-bit
- `LanMontainDesktop-${{ needs.prepare.outputs.version }}-win-x86.zip` - Windows 32-bit
**Linux:**
- `LanMontainDesktop-${{ needs.prepare.outputs.version }}-linux-x64.tar.gz` - Linux 64-bit
**macOS:**
- `LanMontainDesktop-${{ needs.prepare.outputs.version }}-osx-x64.tar.gz` - macOS Intel
- `LanMontainDesktop-${{ needs.prepare.outputs.version }}-osx-arm64.tar.gz` - macOS Apple Silicon
### 📝 Changes
See commits for detailed changes: ${{ github.event.compare || 'https://github.com/${{ github.repository }}/commits/${{ github.sha }}' }}
### 💾 Installation
**Windows:** Extract zip and run `LanMontainDesktop.exe`
**Linux:** Extract tar.gz and run `./LanMontainDesktop`
**macOS:** Extract tar.gz and run `./LanMontainDesktop`
### System Requirements
- .NET Runtime 10.0+ (included in self-contained builds)
- Windows 10+, macOS 10.15+, or modern Linux distribution
---
*Built by ${{ github.event.actor }} on ${{ github.event.head_commit.timestamp }}*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}