Skip to content

Commit b123bb6

Browse files
committed
chore: refactor workflow name and improve formatting in c-cpp.yml
1 parent 93e911d commit b123bb6

File tree

1 file changed

+173
-173
lines changed

1 file changed

+173
-173
lines changed

.github/workflows/c-cpp.yml

Lines changed: 173 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1,188 @@
1-
name: Parallax Windows Build
1+
name: Prakasa Windows Build
22

33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ main ]
6+
branches: [main]
77
tags:
8-
- 'v*.*.*' # 匹配版本标签如 v1.0.0, v2.1.3 等
8+
- "v*.*.*" # 匹配版本标签如 v1.0.0, v2.1.3 等
99
pull_request:
10-
branches: [ main ]
10+
branches: [main]
1111

1212
jobs:
1313
build:
1414
runs-on: windows-latest
15-
15+
1616
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
19-
20-
- name: Setup Visual Studio environment
21-
uses: microsoft/setup-msbuild@v1.1
22-
23-
- name: Setup CMake
24-
uses: lukka/get-cmake@latest
25-
26-
- name: Create build directory
27-
run: |
28-
cd src
29-
mkdir build
30-
cd build
31-
32-
- name: Configure CMake
33-
run: |
34-
cd src/build
35-
cmake ../parallax -A x64 -DCMAKE_BUILD_TYPE=Release
36-
37-
- name: Build project
38-
run: |
39-
cd src/build
40-
cmake --build . --config Release
41-
42-
- name: Verify build output
43-
run: |
44-
if (Test-Path "src\build\x64\Release\parallax.exe") {
45-
Write-Host "Build successful: parallax.exe found"
46-
Get-Item "src\build\x64\Release\parallax.exe" | Select-Object Name, Length, LastWriteTime
47-
} else {
48-
Write-Host "Build failed: parallax.exe not found"
49-
exit 1
50-
}
51-
52-
- name: Prepare installer files
53-
run: |
54-
# Create installer files directory
55-
if (Test-Path "installer\FilesToInstall") {
56-
Remove-Item "installer\FilesToInstall" -Recurse -Force
57-
}
58-
New-Item -ItemType Directory -Path "installer\FilesToInstall" -Force
59-
60-
# Copy executable to installer directory
61-
Copy-Item "src\build\x64\Release\parallax.exe" "installer\FilesToInstall\"
62-
63-
Write-Host "Files prepared for installer:"
64-
Get-ChildItem "installer\FilesToInstall" | Select-Object Name, Length
65-
66-
- name: Build installer
67-
run: |
68-
cd installer
69-
cmd /c "build-nim-nozip.bat"
70-
shell: cmd
71-
72-
- name: Verify installer output
73-
run: |
74-
$installerPath = "installer\Output\Gradient_Parallax_PC_Setup_v1.0.0.0.exe"
75-
if (Test-Path $installerPath) {
76-
Write-Host "Installer created successfully"
77-
Get-Item $installerPath | Select-Object Name, Length, LastWriteTime
78-
} else {
79-
Write-Host "Installer creation failed"
80-
Write-Host "Available files in installer\Output:"
81-
if (Test-Path "installer\Output") {
82-
Get-ChildItem "installer\Output" | Select-Object Name, Length
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Visual Studio environment
21+
uses: microsoft/setup-msbuild@v1.1
22+
23+
- name: Setup CMake
24+
uses: lukka/get-cmake@latest
25+
26+
- name: Create build directory
27+
run: |
28+
cd src
29+
mkdir build
30+
cd build
31+
32+
- name: Configure CMake
33+
run: |
34+
cd src/build
35+
cmake ../parallax -A x64 -DCMAKE_BUILD_TYPE=Release
36+
37+
- name: Build project
38+
run: |
39+
cd src/build
40+
cmake --build . --config Release
41+
42+
- name: Verify build output
43+
run: |
44+
if (Test-Path "src\build\x64\Release\parallax.exe") {
45+
Write-Host "Build successful: parallax.exe found"
46+
Get-Item "src\build\x64\Release\parallax.exe" | Select-Object Name, Length, LastWriteTime
47+
} else {
48+
Write-Host "Build failed: parallax.exe not found"
49+
exit 1
8350
}
84-
exit 1
85-
}
86-
87-
- name: Collect PDB files
88-
run: |
89-
# Create PDB directory
90-
New-Item -ItemType Directory -Path "pdbs" -Force
91-
92-
# Find and copy all PDB files from build directory
93-
Write-Host "Searching for PDB files..."
94-
$pdbFiles = Get-ChildItem -Path "src\build" -Filter "*.pdb" -Recurse
95-
96-
if ($pdbFiles.Count -gt 0) {
97-
Write-Host "Found PDB files:"
98-
foreach ($pdb in $pdbFiles) {
99-
Write-Host "- $($pdb.FullName)"
100-
Copy-Item $pdb.FullName "pdbs\"
51+
52+
- name: Prepare installer files
53+
run: |
54+
# Create installer files directory
55+
if (Test-Path "installer\FilesToInstall") {
56+
Remove-Item "installer\FilesToInstall" -Recurse -Force
57+
}
58+
New-Item -ItemType Directory -Path "installer\FilesToInstall" -Force
59+
60+
# Copy executable to installer directory
61+
Copy-Item "src\build\x64\Release\parallax.exe" "installer\FilesToInstall\"
62+
63+
Write-Host "Files prepared for installer:"
64+
Get-ChildItem "installer\FilesToInstall" | Select-Object Name, Length
65+
66+
- name: Build installer
67+
run: |
68+
cd installer
69+
cmd /c "build-nim-nozip.bat"
70+
shell: cmd
71+
72+
- name: Verify installer output
73+
run: |
74+
$installerPath = "installer\Output\Prakasa_Setup_v1.0.0.0.exe"
75+
if (Test-Path $installerPath) {
76+
Write-Host "Installer created successfully"
77+
Get-Item $installerPath | Select-Object Name, Length, LastWriteTime
78+
} else {
79+
Write-Host "Installer creation failed"
80+
Write-Host "Available files in installer\Output:"
81+
if (Test-Path "installer\Output") {
82+
Get-ChildItem "installer\Output" | Select-Object Name, Length
83+
}
84+
exit 1
85+
}
86+
87+
- name: Collect PDB files
88+
run: |
89+
# Create PDB directory
90+
New-Item -ItemType Directory -Path "pdbs" -Force
91+
92+
# Find and copy all PDB files from build directory
93+
Write-Host "Searching for PDB files..."
94+
$pdbFiles = Get-ChildItem -Path "src\build" -Filter "*.pdb" -Recurse
95+
96+
if ($pdbFiles.Count -gt 0) {
97+
Write-Host "Found PDB files:"
98+
foreach ($pdb in $pdbFiles) {
99+
Write-Host "- $($pdb.FullName)"
100+
Copy-Item $pdb.FullName "pdbs\"
101+
}
102+
} else {
103+
Write-Host "No PDB files found"
101104
}
102-
} else {
103-
Write-Host "No PDB files found"
104-
}
105-
106-
Write-Host "PDB files collected:"
107-
Get-ChildItem "pdbs" | Select-Object Name, Length
108-
109-
- name: Create release package
110-
run: |
111-
# Get current date for versioning
112-
$date = Get-Date -Format "yyyyMMdd"
113-
$time = Get-Date -Format "HHmm"
114-
$datetime = "${date}_${time}"
115-
116-
# Get version from git tag or use default
117-
$gitTag = git describe --tags --exact-match HEAD 2>$null
118-
if ($gitTag -and $gitTag -match '^v?(.+)$') {
119-
$version = $matches[1]
120-
Write-Host "Using version from git tag: $version"
121-
} else {
122-
$version = "1.0.0"
123-
Write-Host "No git tag found, using default version: $version"
124-
}
125-
126-
# Create package directory
127-
New-Item -ItemType Directory -Path "release" -Force
128-
129-
# Copy executable
130-
Copy-Item "src\build\x64\Release\parallax.exe" "release\"
131-
132-
# Create program tar.gz package
133-
$packageName = "Parallax_Win-v${version}_${datetime}.tar.gz"
134-
tar -czf $packageName -C release .
135-
136-
# Create PDB tar.gz package
137-
$pdbPackageName = "Parallax_Pdb-v${version}_${datetime}.tar.gz"
138-
if (Test-Path "pdbs" -PathType Container) {
139-
$pdbCount = (Get-ChildItem "pdbs").Count
140-
if ($pdbCount -gt 0) {
141-
tar -czf $pdbPackageName -C pdbs .
142-
Write-Host "PDB package created: $pdbPackageName"
105+
106+
Write-Host "PDB files collected:"
107+
Get-ChildItem "pdbs" | Select-Object Name, Length
108+
109+
- name: Create release package
110+
run: |
111+
# Get current date for versioning
112+
$date = Get-Date -Format "yyyyMMdd"
113+
$time = Get-Date -Format "HHmm"
114+
$datetime = "${date}_${time}"
115+
116+
# Get version from git tag or use default
117+
$gitTag = git describe --tags --exact-match HEAD 2>$null
118+
if ($gitTag -and $gitTag -match '^v?(.+)$') {
119+
$version = $matches[1]
120+
Write-Host "Using version from git tag: $version"
143121
} else {
144-
Write-Host "No PDB files to package"
122+
$version = "1.0.0"
123+
Write-Host "No git tag found, using default version: $version"
145124
}
146-
}
147-
148-
# Rename installer with timestamp
149-
$installerName = "Parallax_Win_Setup_v${version}_${datetime}.exe"
150-
Copy-Item "installer\Output\Gradient_Parallax_PC_Setup_v1.0.0.0.exe" $installerName
151-
152-
Write-Host "Release packages created:"
153-
Write-Host "- Program package: $packageName"
154-
Write-Host "- PDB package: $pdbPackageName"
155-
Write-Host "- Installer: $installerName"
156-
157-
- name: Upload program package artifact
158-
uses: actions/upload-artifact@v4
159-
with:
160-
name: parallax-win-package
161-
path: Parallax_Win-v*.tar.gz
162-
163-
- name: Upload PDB package artifact
164-
uses: actions/upload-artifact@v4
165-
with:
166-
name: parallax-win-pdbs
167-
path: Parallax_Pdb-v*.tar.gz
168-
169-
- name: Upload installer artifact
170-
uses: actions/upload-artifact@v4
171-
with:
172-
name: parallax-win-installer
173-
path: Parallax_Win_Setup_v*.exe
174-
175-
- name: Create GitHub release
176-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
177-
uses: softprops/action-gh-release@v1
178-
with:
179-
files: |
180-
Parallax_Win-v*.tar.gz
181-
Parallax_Pdb-v*.tar.gz
182-
Parallax_Win_Setup_v*.exe
183-
name: Parallax Windows Release ${{ github.ref_name }}
184-
tag_name: ${{ github.ref_name }}
185-
draft: false
186-
prerelease: false
187-
env:
188-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
126+
# Create package directory
127+
New-Item -ItemType Directory -Path "release" -Force
128+
129+
# Copy executable
130+
Copy-Item "src\build\x64\Release\parallax.exe" "release\"
131+
132+
# Create program tar.gz package
133+
$packageName = "Prakasa_Win-v${version}_${datetime}.tar.gz"
134+
tar -czf $packageName -C release .
135+
136+
# Create PDB tar.gz package
137+
$pdbPackageName = "Prakasa_Pdb-v${version}_${datetime}.tar.gz"
138+
if (Test-Path "pdbs" -PathType Container) {
139+
$pdbCount = (Get-ChildItem "pdbs").Count
140+
if ($pdbCount -gt 0) {
141+
tar -czf $pdbPackageName -C pdbs .
142+
Write-Host "PDB package created: $pdbPackageName"
143+
} else {
144+
Write-Host "No PDB files to package"
145+
}
146+
}
147+
148+
# Rename installer with timestamp
149+
$installerName = "Prakasa_Win_Setup_v${version}_${datetime}.exe"
150+
Copy-Item "installer\Output\Prakasa_Setup_v1.0.0.0.exe" $installerName
151+
152+
Write-Host "Release packages created:"
153+
Write-Host "- Program package: $packageName"
154+
Write-Host "- PDB package: $pdbPackageName"
155+
Write-Host "- Installer: $installerName"
156+
157+
- name: Upload program package artifact
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: prakasa-win-package
161+
path: Prakasa_Win-v*.tar.gz
162+
163+
- name: Upload PDB package artifact
164+
uses: actions/upload-artifact@v4
165+
with:
166+
name: prakasa-win-pdbs
167+
path: Prakasa_Pdb-v*.tar.gz
168+
169+
- name: Upload installer artifact
170+
uses: actions/upload-artifact@v4
171+
with:
172+
name: prakasa-win-installer
173+
path: Prakasa_Win_Setup_v*.exe
174+
175+
- name: Create GitHub release
176+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
177+
uses: softprops/action-gh-release@v1
178+
with:
179+
files: |
180+
Prakasa_Win-v*.tar.gz
181+
Prakasa_Pdb-v*.tar.gz
182+
Prakasa_Win_Setup_v*.exe
183+
name: Prakasa Windows Release ${{ github.ref_name }}
184+
tag_name: ${{ github.ref_name }}
185+
draft: false
186+
prerelease: false
187+
env:
188+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)