diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c941eab..5d2abb9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,14 +38,32 @@ jobs: # Clean up old build artifacts - name: Clean up old build artifacts run: | - $latestTag = (Invoke-RestMethod -Uri https://api.github.com/repos/zed-industries/zed/releases | ForEach-Object { $_.tag_name } | Select-Object -First 1) - $oldArtifacts = Get-ChildItem -Path "target/release" -Filter "Zed-windows-amd64-*.exe" - foreach ($artifact in $oldArtifacts) { - if ($artifact.Name -ne "Zed-windows-amd64-$latestTag.exe") { - Remove-Item $artifact.FullName -Force - Write-Host "Removed old artifact: $($artifact.Name)" + $releasePath = "zed/target/release" + if (Test-Path $releasePath) { + # Clean up .exe files + Get-ChildItem -Path $releasePath -Filter "Zed*.exe" | + Where-Object { $_.Name -ne "Zed-windows-amd64-$env:LATEST_TAG.exe" -and $_.Name -ne "Zed.exe" } | + ForEach-Object { + Remove-Item $_.FullName -Force + Write-Host "Removed old artifact: $($_.Name)" } - } + if (Test-Path "$releasePath/Zed.exe") { + Remove-Item "$releasePath/Zed.exe" -Force + Write-Host "Removed Zed.exe" + } + if (Test-Path "$releasePath/Zed-windows-amd64-$env:LATEST_TAG.exe") { + Remove-Item "$releasePath/Zed-windows-amd64-$env:LATEST_TAG.exe" -Force + Write-Host "Removed Zed-windows-amd64-$env:LATEST_TAG.exe" + } + + # List remaining contents of the release directory + Write-Host "Remaining contents of ${releasePath}:" + Get-ChildItem -Path $releasePath | ForEach-Object { + Write-Host " $($_.Name)" + } + } else { + Write-Host "Release directory does not exist yet: ${releasePath}" + }y # Build Zed - run: cargo build --release -j 4 - run: copy target/release/Zed.exe target/release/Zed-windows-amd64.exe