-
Notifications
You must be signed in to change notification settings - Fork 10
94 lines (80 loc) · 2.7 KB
/
Copy pathdotnet-ci.yaml
File metadata and controls
94 lines (80 loc) · 2.7 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Release Win/Linux Packages
on:
push:
branches: [main, master]
workflow_dispatch:
jobs:
build-packages:
runs-on: windows-latest
strategy:
matrix:
runtime: [win-x64, linux-x64]
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 安装 .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
cache: false
- name: 还原依赖
run: dotnet restore ./src/GeneralUpdate.Tool.Avalonia.sln
- name: 发布应用
run: dotnet publish ./src/GeneralUpdate.Tool.Avalonia.sln `
-c Release `
-r ${{ matrix.runtime }} `
-o ./publish/${{ matrix.runtime }} `
--self-contained true `
/p:PublishSingleFile=true `
/p:DebugType=None
- name: 打包压缩包
run: |
$date = Get-Date -Format "yyyyMMdd"
$zipName = "GeneralUpdate.Tool.Avalonia_${{ matrix.runtime }}_$date.zip"
Compress-Archive -Path ./publish/${{ matrix.runtime }}/* -DestinationPath $zipName -Force
echo "zip_file=$zipName" >> $env:GITHUB_ENV
- name: 上传压缩包
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime }}-package
path: ${{ env.zip_file }}
create-release:
needs: build-packages
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# 关键修复:先检出代码,获取.git目录
- name: 检出代码(用于Git Tag操作)
uses: actions/checkout@v4
with:
fetch-depth: 0 # 拉取完整历史,包含Tag信息
- name: 下载所有压缩包
uses: actions/download-artifact@v4
with:
path: ./packages
- name: 生成日期Tag并推送
id: gen-tag
run: |
TAG_NAME="v$(date +%Y%m%d)"
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git fetch --tags origin # 显式拉取远程Tag
if ! git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
echo "✅ 创建Tag: $TAG_NAME"
else
echo "ℹ️ Tag $TAG_NAME 已存在"
fi
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
- name: 发布到Releases
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.gen-tag.outputs.tag_name }}
name: Release ${{ steps.gen-tag.outputs.tag_name }}
files: ./packages/**/*.zip
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}