Skip to content

Commit 2de6187

Browse files
committed
add Create Release and Publish.yml
1 parent 635be7f commit 2de6187

File tree

2 files changed

+132
-35
lines changed

2 files changed

+132
-35
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Create Release and Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # 觸發條件:建立新 tag,例如 v1.0.0
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
publish:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout main repo
17+
uses: actions/checkout@v4
18+
with:
19+
repository: gpmagvs/VMSystem
20+
path: VMSystem
21+
ref: develop # 指定 branch 或 tag
22+
23+
- name: Checkout AGVSystemCommonNet6 repo
24+
uses: actions/checkout@v4
25+
with:
26+
repository: gpmagvs/AGVSystemCommonNet6 # 這裡換成你需要拉取的 repo
27+
path: AGVSystemCommonNet6
28+
ref: develop # 指定 branch 或 tag
29+
30+
- name: Checkout EquipmentManagment repo
31+
uses: actions/checkout@v4
32+
with:
33+
repository: gpmagvs/EquipmentManagment # 這裡換成你需要拉取的 repo
34+
path: EquipmentManagment
35+
ref: develop # 指定 branch 或 tag
36+
37+
- name: Checkout RosBridgeClient repo
38+
uses: actions/checkout@v4
39+
with:
40+
repository: gpmagvs/RosBridgeClient # 這裡換成你需要拉取的 repo
41+
path: RosBridgeClient
42+
ref: master # 指定 branch 或 tag
43+
44+
- name: Checkout KGSWebAGVSystemAPI repo
45+
uses: actions/checkout@v4
46+
with:
47+
repository: gpmagvs/KGSWebAGVSystemAPI # 這裡換成你需要拉取的 repo
48+
path: KGSWebAGVSystemAPI
49+
ref: master # 指定 branch 或 tag
50+
51+
- name: Setup .NET
52+
uses: actions/setup-dotnet@v4
53+
with:
54+
dotnet-version: 8.0.414 # 跟 GW(Gin-Wei) 開發環境一致
55+
include-prerelease: false
56+
57+
- name: Restore dependencies
58+
run: dotnet restore VMSystem/VMSystem.csproj -r win-x64
59+
60+
- name: Build project
61+
run: dotnet build VMSystem/VMSystem.csproj -c Release -r win-x64 --no-restore
62+
63+
- name: Publish project
64+
run: dotnet publish VMSystem/VMSystem.csproj -c Release -r win-x64 --no-build --self-contained true -o VMSystem-publish --force
65+
66+
# 如果有多個設定檔,可以換成你需要的 pubxml
67+
68+
- name: Compress output
69+
run: |
70+
$tag = "${{ github.ref_name }}"
71+
$publishPath = Join-Path $PWD "VMSystem-publish"
72+
$zipPath = Join-Path $PWD "VMSystem-publish-$tag.zip"
73+
$zipPath_use_for_patch = Join-Path $PWD "VMSystem-publish-${tag}_patch.zip"
74+
Compress-Archive -Path "$publishPath\*" -DestinationPath $zipPath -Force
75+
76+
# 要壓縮的檔案列表
77+
$files = @(
78+
"${publishPath}\version.json",
79+
"${publishPath}\web.config",
80+
"${publishPath}\VMSystem.deps.json",
81+
"${publishPath}\VMSystem.exe",
82+
"${publishPath}\VMSystem.dll",
83+
"${publishPath}\VMSystem.pdb",
84+
"${publishPath}\VMSystem.xml",
85+
"${publishPath}\VMSystem.staticwebassets.endpoints.json",
86+
"${publishPath}\AGVSystemCommonNet6.dll",
87+
"${publishPath}\AGVSystemCommonNet6.pdb",
88+
"${publishPath}\KGSWebAGVSystemAPI.dll",
89+
"${publishPath}\KGSWebAGVSystemAPI.pdb",
90+
"${publishPath}\RosBridgeClient.dll",
91+
"${publishPath}\RosBridgeClient.pdb",
92+
"${publishPath}\EquipmentManagment.dll",
93+
"${publishPath}\EquipmentManagment.pdb",
94+
"${publishPath}\Polly.Core.dll",
95+
"${publishPath}\Polly.dll",
96+
"${publishPath}\INIFileParser.dll",
97+
"${publishPath}\Swashbuckle.AspNetCore.SwaggerUI.dll",
98+
"${publishPath}\Swashbuckle.AspNetCore.SwaggerGen.dll",
99+
"${publishPath}\Swashbuckle.AspNetCore.Swagger.dll"
100+
)
101+
102+
# 只保留存在的檔案
103+
$existingFiles = $files | Where-Object { Test-Path $_ }
104+
105+
if ($existingFiles.Count -gt 0) {
106+
Compress-Archive -Path $existingFiles -DestinationPath $zipPath_use_for_patch -Force
107+
} else {
108+
Write-Host "⚠️ 沒有找到任何檔案,跳過壓縮"
109+
}
110+
111+
- name: Create GitHub Release
112+
uses: softprops/action-gh-release@v2
113+
with:
114+
body: |
115+
## 🚀 What's Changed
116+
- something changed
117+
118+
## 🐞 What's Fixed
119+
- something fixed
120+
121+
## 📦 HeadCommit Message
122+
123+
${{ github.event.head_commit.message }}
124+
125+
## 🔗 Full Changelog
126+
${{ github.server_url }}/${{ github.repository }}/compare/${{ github.event.release.tag_name }}^...${{ github.event.release.tag_name }}
127+
128+
files: |
129+
VMSystem-publish-${{ github.ref_name }}.zip
130+
VMSystem-publish-${{ github.ref_name }}_patch.zip
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/Create Release.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)