-
Notifications
You must be signed in to change notification settings - Fork 0
188 lines (158 loc) · 5.94 KB
/
c-cpp.yml
File metadata and controls
188 lines (158 loc) · 5.94 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Parallax Windows Build
on:
workflow_dispatch:
push:
branches: [ main ]
tags:
- 'v*.*.*' # 匹配版本标签如 v1.0.0, v2.1.3 等
pull_request:
branches: [ main ]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Visual Studio environment
uses: microsoft/setup-msbuild@v1.1
- name: Setup CMake
uses: lukka/get-cmake@latest
- name: Create build directory
run: |
cd src
mkdir build
cd build
- name: Configure CMake
run: |
cd src/build
cmake ../parallax -A x64 -DCMAKE_BUILD_TYPE=Release
- name: Build project
run: |
cd src/build
cmake --build . --config Release
- name: Verify build output
run: |
if (Test-Path "src\build\x64\Release\parallax.exe") {
Write-Host "Build successful: parallax.exe found"
Get-Item "src\build\x64\Release\parallax.exe" | Select-Object Name, Length, LastWriteTime
} else {
Write-Host "Build failed: parallax.exe not found"
exit 1
}
- name: Prepare installer files
run: |
# Create installer files directory
if (Test-Path "installer\FilesToInstall") {
Remove-Item "installer\FilesToInstall" -Recurse -Force
}
New-Item -ItemType Directory -Path "installer\FilesToInstall" -Force
# Copy executable to installer directory
Copy-Item "src\build\x64\Release\parallax.exe" "installer\FilesToInstall\"
Write-Host "Files prepared for installer:"
Get-ChildItem "installer\FilesToInstall" | Select-Object Name, Length
- name: Build installer
run: |
cd installer
cmd /c "build-nim-nozip.bat"
shell: cmd
- name: Verify installer output
run: |
$installerPath = "installer\Output\Gradient_Parallax_PC_Setup_v1.0.0.0.exe"
if (Test-Path $installerPath) {
Write-Host "Installer created successfully"
Get-Item $installerPath | Select-Object Name, Length, LastWriteTime
} else {
Write-Host "Installer creation failed"
Write-Host "Available files in installer\Output:"
if (Test-Path "installer\Output") {
Get-ChildItem "installer\Output" | Select-Object Name, Length
}
exit 1
}
- name: Collect PDB files
run: |
# Create PDB directory
New-Item -ItemType Directory -Path "pdbs" -Force
# Find and copy all PDB files from build directory
Write-Host "Searching for PDB files..."
$pdbFiles = Get-ChildItem -Path "src\build" -Filter "*.pdb" -Recurse
if ($pdbFiles.Count -gt 0) {
Write-Host "Found PDB files:"
foreach ($pdb in $pdbFiles) {
Write-Host "- $($pdb.FullName)"
Copy-Item $pdb.FullName "pdbs\"
}
} else {
Write-Host "No PDB files found"
}
Write-Host "PDB files collected:"
Get-ChildItem "pdbs" | Select-Object Name, Length
- name: Create release package
run: |
# Get current date for versioning
$date = Get-Date -Format "yyyyMMdd"
$time = Get-Date -Format "HHmm"
$datetime = "${date}_${time}"
# Get version from git tag or use default
$gitTag = git describe --tags --exact-match HEAD 2>$null
if ($gitTag -and $gitTag -match '^v?(.+)$') {
$version = $matches[1]
Write-Host "Using version from git tag: $version"
} else {
$version = "1.0.0"
Write-Host "No git tag found, using default version: $version"
}
# Create package directory
New-Item -ItemType Directory -Path "release" -Force
# Copy executable
Copy-Item "src\build\x64\Release\parallax.exe" "release\"
# Create program tar.gz package
$packageName = "Parallax_Win-v${version}_${datetime}.tar.gz"
tar -czf $packageName -C release .
# Create PDB tar.gz package
$pdbPackageName = "Parallax_Pdb-v${version}_${datetime}.tar.gz"
if (Test-Path "pdbs" -PathType Container) {
$pdbCount = (Get-ChildItem "pdbs").Count
if ($pdbCount -gt 0) {
tar -czf $pdbPackageName -C pdbs .
Write-Host "PDB package created: $pdbPackageName"
} else {
Write-Host "No PDB files to package"
}
}
# Rename installer with timestamp
$installerName = "Parallax_Win_Setup_v${version}_${datetime}.exe"
Copy-Item "installer\Output\Gradient_Parallax_PC_Setup_v1.0.0.0.exe" $installerName
Write-Host "Release packages created:"
Write-Host "- Program package: $packageName"
Write-Host "- PDB package: $pdbPackageName"
Write-Host "- Installer: $installerName"
- name: Upload program package artifact
uses: actions/upload-artifact@v4
with:
name: parallax-win-package
path: Parallax_Win-v*.tar.gz
- name: Upload PDB package artifact
uses: actions/upload-artifact@v4
with:
name: parallax-win-pdbs
path: Parallax_Pdb-v*.tar.gz
- name: Upload installer artifact
uses: actions/upload-artifact@v4
with:
name: parallax-win-installer
path: Parallax_Win_Setup_v*.exe
- name: Create GitHub release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
with:
files: |
Parallax_Win-v*.tar.gz
Parallax_Pdb-v*.tar.gz
Parallax_Win_Setup_v*.exe
name: Parallax Windows Release ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}