Skip to content

Commit

Permalink
feat: github action, by win gui
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Jun 26, 2024
1 parent fa6e7f6 commit 8895b2f
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/dotnet-win-gui-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release Windows GUI x64 .NET Application

on:
release:
types: [published]

permissions:
contents: write # 确保有写入发布的权限

jobs:
build_and_release:
name: 构建并发布 .NET 应用程序
runs-on: windows-latest

steps:
- name: 检出仓库代码
uses: actions/checkout@v3 # 使用最新稳定版本

- name: 设置 .NET 环境
uses: actions/setup-dotnet@v3 # 使用最新稳定版本
with:
dotnet-version: '8.0.x' # 确保使用的 .NET 版本与你的项目版本匹配

- name: 还原 NuGet 包
run: dotnet restore src/MDriveSync.Client.WinFormAPI

- name: 列出目录内容 (调试步骤)
run: |
echo "PublishProfiles 目录内容:"
dir src/MDriveSync.Client.WinFormAPI/Properties/PublishProfiles
- name: 构建并发布 .NET 应用程序
run: dotnet publish src/MDriveSync.Client.WinFormAPI -c Release /p:PublishProfile=Client.Publish.SelfContained.win.gui.x64.pubxml

- name: 列出发布目录内容 (调试步骤)
run: |
echo "发布目录内容:"
dir src/MDriveSync.Client.WinFormAPI/bin/Release/net8.0/win-x64/publish
# - name: 删除 PDB 和部分 XML 文件
# run: |
# # 删除目录中的 .pdb 和部分 .xml 文件(如果存在)
# Remove-Item src/MDriveSync.Client.WinFormAPI/bin/Release/net8.0/win-x64/publish/*.pdb -Force -ErrorAction SilentlyContinue

- name: 条件性删除 PDB 文件
run: |
$tagName = "${{ github.event.release.tag_name }}"
if (-not ($tagName -match "beta|rc|alpha")) {
echo "Deleting .pdb files..."
Remove-Item src/MDriveSync.Client.WinFormAPI/bin/Release/net8.0/win-x64/publish/*.pdb -Force -ErrorAction SilentlyContinue
} else {
echo "Preserving .pdb files for pre-release versions..."
}
- name: 压缩构建产物
run: |
# 将发布目录中的文件压缩为 zip 文件
Compress-Archive -Path src/MDriveSync.Client.WinFormAPI/bin/Release/net8.0/win-x64/publish/* -DestinationPath "MDrive-win-gui-x64-${{ github.event.release.tag_name }}.zip"
- name: 检查 ZIP 文件
run: |
echo "生成的 ZIP 文件:"
dir MDrive-win-gui-x64-${{ github.event.release.tag_name }}.zip
- name: 上传 ZIP 文件到 release
uses: actions/upload-release-asset@v1 # 使用最新稳定版本
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "MDrive-win-gui-x64-${{ github.event.release.tag_name }}.zip"
asset_name: "MDrive-win-gui-x64-${{ github.event.release.tag_name }}.zip"
asset_content_type: application/zip
73 changes: 73 additions & 0 deletions .github/workflows/dotnet-win-gui-x86.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release Windows GUI x86 .NET Application

on:
release:
types: [published]

permissions:
contents: write # 确保有写入发布的权限

jobs:
build_and_release:
name: 构建并发布 .NET 应用程序
runs-on: windows-latest

steps:
- name: 检出仓库代码
uses: actions/checkout@v3 # 使用最新稳定版本

- name: 设置 .NET 环境
uses: actions/setup-dotnet@v3 # 使用最新稳定版本
with:
dotnet-version: '8.0.x' # 确保使用的 .NET 版本与你的项目版本匹配

- name: 还原 NuGet 包
run: dotnet restore src/MDriveSync.Client.WinFormAPI

- name: 列出目录内容 (调试步骤)
run: |
echo "PublishProfiles 目录内容:"
dir src/MDriveSync.Client.WinFormAPI/Properties/PublishProfiles
- name: 构建并发布 .NET 应用程序
run: dotnet publish src/MDriveSync.Client.WinFormAPI -c Release /p:PublishProfile=Client.Publish.SelfContained.win.gui.x86.pubxml

- name: 列出发布目录内容 (调试步骤)
run: |
echo "发布目录内容:"
dir src/MDriveSync.Client.WinFormAPI/bin/Release/net8.0/win-x86/publish
# - name: 删除 PDB 和部分 XML 文件
# run: |
# # 删除目录中的 .pdb 和部分 .xml 文件(如果存在)
# Remove-Item src/MDriveSync.Client.WinFormAPI/bin/Release/net8.0/win-x86/publish/*.pdb -Force -ErrorAction SilentlyContinue

- name: 条件性删除 PDB 文件
run: |
$tagName = "${{ github.event.release.tag_name }}"
if (-not ($tagName -match "beta|rc|alpha")) {
echo "Deleting .pdb files..."
Remove-Item src/MDriveSync.Client.WinFormAPI/bin/Release/net8.0/win-x86/publish/*.pdb -Force -ErrorAction SilentlyContinue
} else {
echo "Preserving .pdb files for pre-release versions..."
}
- name: 压缩构建产物
run: |
# 将发布目录中的文件压缩为 zip 文件
Compress-Archive -Path src/MDriveSync.Client.WinFormAPI/bin/Release/net8.0/win-x86/publish/* -DestinationPath "MDrive-win-gui-x86-${{ github.event.release.tag_name }}.zip"
- name: 检查 ZIP 文件
run: |
echo "生成的 ZIP 文件:"
dir MDrive-win-gui-x86-${{ github.event.release.tag_name }}.zip
- name: 上传 ZIP 文件到 release
uses: actions/upload-release-asset@v1 # 使用最新稳定版本
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "MDrive-win-gui-x86-${{ github.event.release.tag_name }}.zip"
asset_name: "MDrive-win-gui-x86-${{ github.event.release.tag_name }}.zip"
asset_content_type: application/zip

0 comments on commit 8895b2f

Please sign in to comment.