From ae8a2487cf90ef28054b0eab96ab7a0f4eeefcb9 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 Aug 2025 03:18:17 +0000 Subject: [PATCH 1/3] Initial plan From f3f1385284f1a97d141165207d1043de0748c0e2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 Aug 2025 03:22:40 +0000 Subject: [PATCH 2/3] Add GitHub workflows for automated building and packaging Co-authored-by: Lingwuxin <57278566+Lingwuxin@users.noreply.github.com> --- .github/workflows/README.md | 59 +++++++++++++++++ .github/workflows/build-and-package.yml | 85 +++++++++++++++++++++++++ .github/workflows/ci.yml | 40 ++++++++++++ 3 files changed, 184 insertions(+) create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/build-and-package.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000..ea001ed --- /dev/null +++ b/.github/workflows/README.md @@ -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) \ No newline at end of file diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml new file mode 100644 index 0000000..b4f1a6d --- /dev/null +++ b/.github/workflows/build-and-package.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f1a7593 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file From f35f92614da2ea3ff7dd3d5f553715b1f579740f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 Aug 2025 03:23:57 +0000 Subject: [PATCH 3/3] Add documentation for auto-packaging workflows and version file Co-authored-by: Lingwuxin <57278566+Lingwuxin@users.noreply.github.com> --- README.md | 16 ++++++++++++++++ VERSION | 1 + 2 files changed, 17 insertions(+) create mode 100644 VERSION diff --git a/README.md b/README.md index 307a8ea..d8c4abf 100644 --- a/README.md +++ b/README.md @@ -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的架构开发,导致项目结构混乱,将在功能完成后逐步对各个页面进行重构。 \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..afaf360 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file