Skip to content

Commit 3224b73

Browse files
committed
fix: windows artifact path issue
1 parent 18c759e commit 3224b73

File tree

1 file changed

+23
-4
lines changed
  • .github/workflows/actions/upload-archive

1 file changed

+23
-4
lines changed

.github/workflows/actions/upload-archive/action.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,30 @@ runs:
120120
}
121121
}
122122
123-
# Compress directories preserving structure
124-
# Use paths directly instead of individual files to maintain directory hierarchy
123+
# Compress directories preserving structure with normalized paths
124+
# Create a temporary directory with normalized paths to avoid backslash issues
125125
try {
126126
if ($paths.Count -gt 0) {
127-
Compress-Archive -Path $paths -DestinationPath "${{ inputs.output }}" -Force -ErrorAction Stop
127+
# Create a temporary directory with normalized paths
128+
$tempDir = Join-Path $env:TEMP "tauri-apps-normalized"
129+
if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force }
130+
New-Item -ItemType Directory -Path $tempDir | Out-Null
131+
132+
# Copy files with normalized paths (convert backslashes to forward slashes)
133+
foreach ($path in $paths) {
134+
if (Test-Path $path) {
135+
$relativePath = $path -replace [regex]::Escape(${{ github.workspace }}), ""
136+
$relativePath = $relativePath -replace "^\\", ""
137+
$destPath = Join-Path $tempDir $relativePath
138+
Copy-Item -Path $path -Destination $destPath -Recurse -Force
139+
}
140+
}
141+
142+
# Compress from normalized directory
143+
Compress-Archive -Path "$tempDir/*" -DestinationPath "${{ inputs.output }}" -Force -ErrorAction Stop
144+
145+
# Clean up temp directory
146+
Remove-Item $tempDir -Recurse -Force
128147
} else {
129148
# Create empty archive if no paths found
130149
Compress-Archive -Path @() -DestinationPath "${{ inputs.output }}" -Force -ErrorAction Stop
@@ -155,7 +174,7 @@ runs:
155174
156175
# Get archive size for reporting
157176
$fileSize = (Get-Item "${{ inputs.output }}").Length
158-
$humanSize = if ($fileSize -lt 1KB) { "$fileSize B" }
177+
$humanSize = if ($fileSize -lt 1KB) { "$fileSize B" }
159178
elseif ($fileSize -lt 1MB) { "{0:N1} KB" -f ($fileSize / 1KB) }
160179
elseif ($fileSize -lt 1GB) { "{0:N1} MB" -f ($fileSize / 1MB) }
161180
else { "{0:N1} GB" -f ($fileSize / 1GB) }

0 commit comments

Comments
 (0)