@@ -25,58 +25,77 @@ jobs:
2525 - name : Restore dependencies
2626 run : dotnet restore
2727
28- - name : Publish Project
28+ - name : Build Project
2929 if : github.event_name == 'push'
3030 run : |
31- dotnet publish `
31+ dotnet build `
3232 --configuration Release `
33- --output ./publish `
34- --self-contained false `
33+ --no-restore `
3534 /p:Platform=x64
3635
3736 - name : Package Output
3837 if : github.event_name == 'push'
3938 id : package
4039 shell : pwsh
4140 run : |
42- $publishPath = "${{ github.workspace }}\publish "
41+ $buildOutput = "${{ github.workspace }}\bin\x64\Release\net8.0-windows "
4342
44- # 验证输出目录存在
45- if (-not (Test-Path $publishPath)) {
46- Write-Error "Publish 目录不存在: $publishPath"
43+ if (-not (Test-Path $buildOutput)) {
44+ Write-Error "构建输出目录不存在: $buildOutput"
4745 exit 1
4846 }
4947
50- Write-Host "=== 打包目录内容 === "
51- Get-ChildItem -Path $publishPath -Recurse | Select-Object FullName, Length | Format-Table -AutoSize
48+ $tempPath = "${{ github.workspace }}\temp_package "
49+ New-Item -ItemType Directory -Force -Path $tempPath | Out-Null
5250
53- # 生成带版本号的文件名
54- $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
55- $commitSha = "${{ github.sha }}".Substring(0, 7)
56- $artifactName = "build-${timestamp}-${commitSha}"
51+ $includePatterns = @(
52+ "SystemTools.dll",
53+ "SystemTools.pdb",
54+ SystemTools.deps.json",
55+ "manifest.yml",
56+ "version.json",
57+ "icon.png",
58+ "black.html",
59+ "README.md",
60+ "README-1.md",
61+ "README-2.md",
62+ "Lyricify Lite - README.md",
63+ "*.bat",
64+ "*.ps1"
65+ )
5766
58- # 打包为 zip 然后重命名为 .cipx
67+ foreach ($pattern in $includePatterns) {
68+ $files = Get-ChildItem -Path $buildOutput -Filter $pattern -ErrorAction SilentlyContinue
69+ foreach ($file in $files) {
70+ Copy-Item -Path $file.FullName -Destination $tempPath -Force
71+ Write-Host "复制: $($file.Name)"
72+ }
73+ }
74+
75+ Write-Host "=== 打包文件列表 ==="
76+ Get-ChildItem -Path $tempPath | Select-Object Name, Length | Format-Table -AutoSize
77+
78+ $buildDate = Get-Date -Format "yyyyMMdd"
79+ $artifactName = "SystemTools - build at ${buildDate}"
5980 $zipPath = "${{ github.workspace }}\${artifactName}.zip"
6081 $cipxPath = "${{ github.workspace }}\${artifactName}.cipx"
6182
62- # 压缩 publish 文件夹下的所有内容(包括 dll、配置文件、资源文件等)
63- Compress-Archive -Path "$publishPath\*" -DestinationPath $zipPath -Force
83+ Compress-Archive -Path "$tempPath\*" -DestinationPath $zipPath -Force
6484 Rename-Item -Path $zipPath -NewName $cipxPath
6585
86+ Remove-Item -Path $tempPath -Recurse -Force
87+
6688 Write-Output "artifact_name=$artifactName" >> $env:GITHUB_OUTPUT
6789 Write-Output "artifact_path=$cipxPath" >> $env:GITHUB_OUTPUT
68- Write-Output "Created: $cipxPath"
69-
70- Write-Host "=== 最终产物信息 ==="
71- Get-Item $cipxPath | Select-Object Name, Length, LastWriteTime | Format-List
90+ Write-Host "Created: $cipxPath"
7291
7392 - name : Cleanup Old Artifacts
7493 if : github.event_name == 'push'
7594 uses : actions/github-script@v7
7695 with :
7796 script : |
7897 const keepCount = 6;
79- const artifactPrefix = 'build- ';
98+ const artifactPrefix = 'SystemTools - build at ';
8099
81100 const { data: artifacts } = await github.rest.actions.listArtifactsForRepo({
82101 owner: context.repo.owner,
92111
93112 const toDelete = buildArtifacts.slice(keepCount);
94113 for (const artifact of toDelete) {
95- console.log(`Deleting old artifact: ${artifact.name} (ID: ${artifact.id}, created: ${artifact.created_at} )`);
114+ console.log(`Deleting old artifact: ${artifact.name} (ID: ${artifact.id})`);
96115 await github.rest.actions.deleteArtifact({
97116 owner: context.repo.owner,
98117 repo: context.repo.repo,
0 commit comments