Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# GitHub Workflows

This directory contains GitHub Actions workflows for automated building and packaging of the ScreenSoundSwitch application.

## Workflows

### 1. Build and Package (`build-and-package.yml`)

This workflow automatically builds and packages the ScreenSoundSwitch WinUI application for distribution.

**Triggers:**
- When a tag starting with `v` is pushed (e.g., `v1.0.0`)
- When a release is published
- Manual trigger via GitHub UI with configurable build configuration

**Features:**
- Builds for multiple architectures: x86, x64, ARM64
- Creates MSIX packages for easy installation
- Uploads build artifacts for each platform
- Automatically creates GitHub releases for tagged versions
- Supports Release, Debug, and Nightly build configurations

**Usage:**
1. Create a tag: `git tag v1.0.0 && git push origin v1.0.0`
2. Or manually trigger from GitHub Actions tab

### 2. Continuous Integration (`ci.yml`)

This workflow runs on every push and pull request to ensure code quality.

**Triggers:**
- Push to main/master/develop branches
- Pull requests targeting main/master/develop branches

**Features:**
- Quick build verification for x64 platform
- Runs available tests
- Provides fast feedback for development

## Build Artifacts

The workflows generate the following artifacts:

- **MSIX Packages**: Ready-to-install packages for Windows
- **Executable Files**: Standalone executables for each platform
- **Retention**: Artifacts are kept for 30 days

## Requirements

- Windows runner (for building Windows-specific applications)
- .NET 8.0 SDK
- MSBuild tools
- MSIX tooling enabled

## Notes

- The application requires Windows 10 version 17763 or later
- ARM64 builds are included for modern Windows devices
- All packages are created as sideload-only (no Microsoft Store submission)
85 changes: 85 additions & 0 deletions .github/workflows/build-and-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build and Package

on:
push:
tags:
- 'v*'
release:
types: [published]
workflow_dispatch:
inputs:
build_configuration:
description: 'Build configuration'
required: false
default: 'Release'
type: choice
options:
- Release
- Debug
- Nightly

env:
SOLUTION_FILE_PATH: ScreenSoundSwitch.sln
BUILD_CONFIGURATION: ${{ github.event.inputs.build_configuration || 'Release' }}

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
platform: [x86, x64, ARM64]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Restore NuGet packages
run: dotnet restore ${{ env.SOLUTION_FILE_PATH }}

- name: Build solution
run: msbuild ${{ env.SOLUTION_FILE_PATH }} /p:Configuration=${{ env.BUILD_CONFIGURATION }} /p:Platform=${{ matrix.platform }} /p:EnableMsixTooling=true /p:UapAppxPackageBuildMode=SideloadOnly

- name: Create package (MSIX)
run: msbuild ScreenSoundSwitch.WinUI/ScreenSoundSwitch.WinUI.csproj /p:Configuration=${{ env.BUILD_CONFIGURATION }} /p:Platform=${{ matrix.platform }} /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxBundle=Never /p:GenerateAppxPackageOnBuild=true

- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: ScreenSoundSwitch-${{ matrix.platform }}-${{ env.BUILD_CONFIGURATION }}
path: |
ScreenSoundSwitch.WinUI/AppPackages/**/*.msix
ScreenSoundSwitch.WinUI/AppPackages/**/*.msixbundle
ScreenSoundSwitch.WinUI/bin/${{ matrix.platform }}/${{ env.BUILD_CONFIGURATION }}/**/*.exe
retention-days: 30

create-release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/**/*.msix
artifacts/**/*.msixbundle
artifacts/**/*.exe
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Continuous Integration

on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]

env:
SOLUTION_FILE_PATH: ScreenSoundSwitch.sln
BUILD_CONFIGURATION: Release

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
platform: [x64] # Only test x64 for CI to save build time

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Restore NuGet packages
run: dotnet restore ${{ env.SOLUTION_FILE_PATH }}

- name: Build solution
run: msbuild ${{ env.SOLUTION_FILE_PATH }} /p:Configuration=${{ env.BUILD_CONFIGURATION }} /p:Platform=${{ matrix.platform }} /p:EnableMsixTooling=true

- name: Run tests (if any)
run: dotnet test --no-restore --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }}
continue-on-error: true # Continue even if no tests are found
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,21 @@
![alt text](image-6.png)
音乐播放
![alt text](image.png)
## 构建和发布

项目已配置GitHub Actions自动化工作流程:

### 自动打包
- 推送版本标签时自动构建和打包:`git tag v1.0.0 && git push origin v1.0.0`
- 支持x86、x64、ARM64多架构构建
- 自动生成MSIX安装包
- 自动创建GitHub发布版本

### 持续集成
- 每次推送和Pull Request都会自动验证构建
- 确保代码质量和构建稳定性

详见 [.github/workflows/README.md](.github/workflows/README.md)

## 当前存在的问题
- 项目初期并未按照MVVM的架构开发,导致项目结构混乱,将在功能完成后逐步对各个页面进行重构。
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
Loading