Skip to content

Commit 1204cf5

Browse files
authored
Update dotnet-desktop.yml
1 parent 709e1d8 commit 1204cf5

1 file changed

Lines changed: 156 additions & 43 deletions

File tree

Lines changed: 156 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,165 @@
1-
name: Build Avalonia Desktop App
1+
name: Publish
22

33
on:
4+
workflow_dispatch:
45
push:
5-
branches: [ "master" ] # 修改为你使用的分支
6-
pull_request:
7-
branches: [ "master" ]
6+
branches: ["master"]
87

98
jobs:
10-
build:
11-
runs-on: windows-latest
12-
9+
time:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
v: ${{ steps.date.outputs.time }}
13+
y: ${{ steps.date.outputs.y }}
14+
md: ${{ steps.date.outputs.md }}
15+
hm: ${{ steps.date.outputs.hm }}
1316
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v4
16-
17-
- name: 安装 .NET SDK
18-
uses: actions/setup-dotnet@v4
19-
with:
20-
dotnet-version: '8.0.x' # 根据你的项目需求调整 .NET 版本
21-
22-
- name: 构建
23-
run: dotnet build --configuration Release
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Time
22+
id: date
23+
run: |
24+
echo "::set-output name=time::$(date +'%Y.%m.%d.%H.%M')"
25+
echo "::set-output name=y::$(date +'%Y')"
26+
echo "::set-output name=md::$(date +'%m%d')"
27+
echo "::set-output name=hm::$(date +'%H%M')"
28+
- name: EchoTime
29+
run: |
30+
echo "The current time is: ${{ steps.date.outputs.time }}"
2431
25-
- name: 打包输出目录
26-
run: |
27-
$sourceDir = "./Round.NET.AvaloniaApp.EncodeCalculator.Desktop/bin/Release"
28-
$zipFile = "./release-artifact.zip"
29-
if (Test-Path $zipFile) { Remove-Item $zipFile } # 如果文件已存在,先删除
30-
Compress-Archive -Path $sourceDir -DestinationPath $zipFile
31-
shell: pwsh
32+
linux:
33+
runs-on: ubuntu-20.04
34+
needs: time
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 0
40+
# - name: Time
41+
# id: date
42+
# run: |
43+
# echo "${{ needs.time.outputs.v }}" > ./YMCL/Public/Texts/DateTime.txt
44+
# echo "Version is ${{ needs.time.outputs.v }}"
45+
- name: Dependency
46+
run: |
47+
dotnet tool install -g KuiperZone.PupNet
48+
sudo apt-get update
49+
sudo apt-get install fuse
50+
- name: Build-AppImage
51+
run: |
52+
cd ./Round.NET.AvaloniaApp.EncodeCalculator.Desktop
53+
sudo su
54+
pupnet --runtime linux-x64 --kind appimage -o Round.NET.AvaloniaApp.EncodeCalculator.Desktop.linux.x64.AppImage -y --app-version ${{ needs.time.outputs.y }}.${{ needs.time.outputs.md }}.${{ needs.time.outputs.hm }}
55+
pupnet --runtime linux-arm --kind appimage -o Round.NET.AvaloniaApp.EncodeCalculator.Desktop.linux.arm.AppImage -y --app-version ${{ needs.time.outputs.y }}.${{ needs.time.outputs.md }}.${{ needs.time.outputs.hm }}
56+
pupnet --runtime linux-arm64 --kind appimage -o Round.NET.AvaloniaApp.EncodeCalculator.Desktop.linux.arm64.AppImage -y --app-version ${{ needs.time.outputs.y }}.${{ needs.time.outputs.md }}.${{ needs.time.outputs.hm }}
57+
- name: Build-MacOsApp
58+
run: |
59+
cd ./Round.NET.AvaloniaApp.EncodeCalculator.Desktop
60+
sudo su
61+
dotnet restore -r osx-x64
62+
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-x64 -property:Configuration=Release -p:SelfContained=true
63+
dotnet restore -r osx-arm64
64+
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-arm64 -property:Configuration=Release -p:SelfContained=true
65+
cd ./bin/Release/net8.0/
66+
cd ./osx-x64/publish/
67+
zip -9 -r ../../Round.NET.AvaloniaApp.EncodeCalculator.Desktop.osx.mac.x64.app.zip ./REC.app
68+
cd ../../
69+
cd ./osx-arm64/publish/
70+
zip -9 -r ../../Round.NET.AvaloniaApp.EncodeCalculator.Desktop.osx.mac.arm64.app.zip ./REC.app
71+
- name: Build-WinExe
72+
run: |
73+
cd ./Round.NET.AvaloniaApp.EncodeCalculator.Desktop
74+
sudo su
75+
dotnet publish -r win-x86 --self-contained true -p:PublishSingleFile=true
76+
dotnet publish -r win-x64 --self-contained true -p:PublishSingleFile=true
77+
dotnet publish -r win-arm64 --self-contained true -p:PublishSingleFile=true
78+
mv ./bin/Release/net8.0/win-x86/publish/Round.NET.AvaloniaApp.EncodeCalculator.Desktop.exe ./bin/Release/net8.0/win-x86/publish/Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.x86.exe
79+
mv ./bin/Release/net8.0/win-x64/publish/Round.NET.AvaloniaApp.EncodeCalculator.Desktop.exe ./bin/Release/net8.0/win-x64/publish/Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.x64.exe
80+
mv ./bin/Release/net8.0/win-arm64/publish/Round.NET.AvaloniaApp.EncodeCalculator.Desktop.exe ./bin/Release/net8.0/win-arm64/publish/Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.arm64.exe
81+
cd ./bin/Release/net8.0/
82+
cd ./win-x86/publish/
83+
zip -9 -r "../../Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.x86.exe.zip" "./Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.x86.exe"
84+
cd ../../
85+
cd ./win-x64/publish/
86+
zip -9 -r "../../Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.x64.exe.zip" "./Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.x64.exe"
87+
cd ../../
88+
cd ./win-arm64/publish/
89+
zip -9 -r "../../Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.arm64.exe.zip" "./Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win7.arm64.exe"
90+
- name: UploadArtifacts
91+
uses: actions/upload-artifact@v3
92+
with:
93+
name: linux-artifacts
94+
path: |
95+
/Round.NET.AvaloniaApp.EncodeCalculator.Desktop/Deploy/OUT/*
96+
/Round.NET.AvaloniaApp.EncodeCalculator.Desktop/bin/Release/net8.0/*.zip
3297

33-
- name: 创建并发布 Release
34-
id: create_release
35-
uses: actions/create-release@v1
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
with:
39-
tag_name: testbuild # 使用分支名或自定义版本号
40-
release_name: Release testbuild
41-
draft: false
42-
prerelease: false
98+
win:
99+
runs-on: windows-latest
100+
needs: time
101+
steps:
102+
- name: Checkout code
103+
uses: actions/checkout@v3
104+
- name: Dependency-InnoSetup
105+
uses: ConorMacBride/install-package@v1
106+
with:
107+
choco: innosetup
108+
- name: Chinesize-InnoSetup
109+
run: |
110+
Copy-Item "./Round.NET.AvaloniaApp.EncodeCalculator/Public/Default.isl" "C:\Program Files (x86)\Inno Setup 6\Default.isl" -Force
111+
- name: Dependency-Pupnet
112+
run: |
113+
dotnet tool install -g KuiperZone.PupNet
114+
- name: Time
115+
id: date
116+
run: |
117+
echo "${{ needs.time.outputs.v }}" > ./Round.NET.AvaloniaApp.EncodeCalculator/Public/DateTime.txt
118+
echo "Version is ${{ needs.time.outputs.v }}"
119+
shell: bash
120+
- name: Build
121+
run: |
122+
cd ./Round.NET.AvaloniaApp.EncodeCalculator.Desktop
123+
pupnet -r win-x64 -k setup -y -o Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win.x64.installer.exe --app-version ${{ needs.time.outputs.y }}.${{ needs.time.outputs.md }}.${{ needs.time.outputs.hm }}
124+
pupnet -r win-x86 -k setup -y -o Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win.x86.installer.exe --app-version ${{ needs.time.outputs.y }}.${{ needs.time.outputs.md }}.${{ needs.time.outputs.hm }}
125+
pupnet -r win-arm64 -k setup -y -o Round.NET.AvaloniaApp.EncodeCalculator.Desktop.win.arm64.installer.exe --app-version ${{ needs.time.outputs.y }}.${{ needs.time.outputs.md }}.${{ needs.time.outputs.hm }}
126+
- name: UploadArtifacts
127+
uses: actions/upload-artifact@v3
128+
with:
129+
name: win-artifacts
130+
path: |
131+
./Round.NET.AvaloniaApp.EncodeCalculator.Desktop/Deploy/OUT/*
43132
44-
- name: 上传打包文件到 Release
45-
uses: actions/upload-release-asset@v1
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
with:
49-
upload_url: ${{ steps.create_release.outputs.upload_url }} # 从创建 Release 的步骤获取上传 URL
50-
asset_path: ./release-artifact.zip # 打包后的文件路径
51-
asset_name: release-artifact.zip # 上传后的文件名
52-
asset_content_type: application/zip
133+
publish:
134+
needs: [linux, win, time]
135+
runs-on: ubuntu-latest
136+
steps:
137+
- name: Time
138+
id: gdate
139+
run: |
140+
echo "date=$(date +'%Y-%m-%d.%H-%M-%S')" >> $GITHUB_OUTPUT
141+
echo "title=$(date +'%Y.%m.%d.%H.%M')" >> $GITHUB_OUTPUT
142+
- name: Download-LinuxArtifacts
143+
uses: actions/download-artifact@v3
144+
with:
145+
name: linux-artifacts
146+
path: ./Round.NET.AvaloniaApp.EncodeCalculator/Release/
147+
- name: Download-WindowsArtifacts
148+
uses: actions/download-artifact@v3
149+
with:
150+
name: win-artifacts
151+
path: ./Round.NET.AvaloniaApp.EncodeCalculator/Release/
152+
- name: List Files
153+
run: |
154+
ls -la ./Round.NET.AvaloniaApp.EncodeCalculator/Release/
155+
- name: Publish Release
156+
uses: marvinpinto/action-automatic-releases@latest
157+
with:
158+
repo_token: "${{ secrets.TOKEN }}"
159+
title: "v${{ needs.time.outputs.v }}"
160+
automatic_release_tag: "AutoPublish-${{ steps.gdate.outputs.date }}"
161+
prerelease: false
162+
files: |
163+
Round.NET.AvaloniaApp.EncodeCalculator/Release/*.exe
164+
Round.NET.AvaloniaApp.EncodeCalculator/Release/Deploy/OUT/*.AppImage
165+
Round.NET.AvaloniaApp.EncodeCalculator/Release/bin/Release/net8.0/*.zip

0 commit comments

Comments
 (0)