Skip to content

.NET Publish and Release #7

.NET Publish and Release

.NET Publish and Release #7

name: .NET Publish and Release
on:
push:
tags:
- 'v*' # 当匹配 'v*.*.*' 格式的标签被推送时触发
workflow_dispatch: # 允许手动触发
jobs:
build-and-release:
name: Build and Release
runs-on: windows-latest # 使用 Windows 环境
permissions:
contents: write # 需要写入权限来创建 Release 和上传构建产物
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Build and publish for win-x64
run: dotnet publish DocTransform.csproj -c Release -r win-x64 --output ./publish-x64
- name: Rename win-x64 executable
run: ren publish-x64\DocTransform.exe DocTransform-x64.exe
- name: Archive win-x64 artifact
uses: actions/upload-artifact@v4
with:
name: DocTransform-win-x64-files
path: ./publish-x64
- name: Build and publish for win-x86
run: dotnet publish DocTransform.csproj -c Release -r win-x86 --output ./publish-x86
- name: Rename win-x86 executable
run: ren publish-x86\DocTransform.exe DocTransform-x86.exe
- name: Archive win-x86 artifact
uses: actions/upload-artifact@v4
with:
name: DocTransform-win-x86-files
path: ./publish-x86
- name: Create Release and Upload Assets
if: startsWith(github.ref, 'refs/tags/') # 仅当事件是标签推送时执行
uses: softprops/action-gh-release@v2
with:
files: |
./publish-*/*.exe