-
Notifications
You must be signed in to change notification settings - Fork 28
56 lines (47 loc) · 1.93 KB
/
windows-mdirve.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Build and Release .NET Application
on:
push:
branches:
- main # 修改为你的主分支名称
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: 构建并发布 .NET 应用程序
run: |
dotnet publish src/MDriveSync.Client.API/Properties/PublishProfiles/Client.Publish.SelfContained.win.x64.pubxml -c Release -o publish
- name: 删除 PDB 和 XML 文件
run: |
# 删除目录中的 .pdb 和 .xml 文件(如果存在)
Remove-Item publish/*.pdb -Force -ErrorAction SilentlyContinue
Remove-Item publish/*.xml -Force -ErrorAction SilentlyContinue
- name: 压缩构建产物
run: |
# 将发布目录中的文件压缩为 zip 文件
Compress-Archive -Path publish/* -DestinationPath "MDrive-win-x64-v${{ github.sha }}.zip"
- name: 创建 GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ github.sha }}"
release_name: "Release v${{ github.sha }}"
draft: false
prerelease: false
- name: 上传 ZIP 文件到 release
uses: actions/upload-release-asset@v1 # 使用最新稳定版本
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "MDrive-win-x64-v${{ github.sha }}.zip"
asset_name: "MDrive-win-x64-v${{ github.sha }}.zip"
asset_content_type: application/zip