chore: another way to use release path #107
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Zed Windows Build | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- msix-build | |
permissions: | |
contents: write | |
jobs: | |
build-windows-amd64: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout Zed repository | |
uses: actions/checkout@v4 | |
with: | |
repository: zed-industries/zed | |
path: zed | |
- name: Checkout Yannou's build repository | |
uses: actions/checkout@v4 | |
with: | |
repository: yannouuuu/zed-windows-build | |
path: build-repo | |
fetch-depth: 0 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- run: rustup target add wasm32-wasi | |
- name: Setup MSVC | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: amd64 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
zed/target/ | |
C:/Users/runneradmin/.cargo/registry/ | |
C:/Users/runneradmin/.cargo/git/ | |
C:/Users/runneradmin/.rustup/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Cache Rust | |
uses: Swatinem/rust-cache@v2 | |
with: | |
cache-directories: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
zed/target/ | |
C:/Users/runneradmin/.cargo/registry/ | |
C:/Users/runneradmin/.cargo/git/ | |
C:/Users/runneradmin/.rustup/ | |
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }} | |
- name: Get latest release tag | |
id: get_latest_tag | |
run: | | |
$latestTag = (Invoke-RestMethod -Uri https://api.github.com/repos/zed-industries/zed/releases | ForEach-Object { $_.tag_name } | Select-Object -First 1) | |
if (-not $latestTag) { | |
$latestTag = "v0.0.0" | |
} | |
echo "LATEST_TAG=$latestTag" >> $env:GITHUB_ENV | |
echo "Latest tag: $latestTag" | |
- name: Debug - List directory structure | |
run: | | |
Write-Host "Current directory:" | |
Get-Location | |
Write-Host "Directory structure:" | |
Get-ChildItem -Recurse -Depth 3 | Select-Object FullName | |
- name: Clean up old build artifacts | |
run: | | |
$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" | |
} | |
# Clean up .msix files | |
Get-ChildItem -Path $releasePath -Filter "*.msix" | ForEach-Object { | |
Remove-Item $_.FullName -Force | |
Write-Host "Removed old .msix file: $($_.Name)" | |
} | |
# Clean up .msixbundle files | |
Get-ChildItem -Path $releasePath -Filter "*.msixbundle" | ForEach-Object { | |
Remove-Item $_.FullName -Force | |
Write-Host "Removed old .msixbundle file: $($_.Name)" | |
} | |
# Clean up .appinstaller files | |
Get-ChildItem -Path $releasePath -Filter "*.appinstaller" | ForEach-Object { | |
Remove-Item $_.FullName -Force | |
Write-Host "Removed old .appinstaller file: $($_.Name)" | |
} | |
# 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}" | |
} | |
- name: Build Zed | |
run: | | |
cd zed | |
cargo build --release -j 4 | |
- name: Verify Zed build | |
run: | | |
if (Test-Path "zed/target/release/Zed.exe") { | |
Write-Host "Zed.exe built successfully" | |
} else { | |
Write-Host "Zed.exe not found after build" | |
exit 1 | |
} | |
- name: Rename build output | |
run: | | |
$sourceDir = "zed/target/release" | |
$sourceName = "Zed.exe" | |
$newFileName = "Zed-windows-amd64-$env:LATEST_TAG.exe" | |
$sourcePath = Join-Path -Path $sourceDir -ChildPath $sourceName | |
$destinationPath = Join-Path -Path $sourceDir -ChildPath $newFileName | |
if (Test-Path -Path $sourcePath) { | |
Rename-Item -Path $sourcePath -NewName $newFileName -Force | |
Write-Host "File renamed successfully to $newFileName" | |
} else { | |
Write-Host "Error: Source file $sourcePath not found" | |
exit 1 | |
} | |
- name: Prepare App Installer package | |
run: | | |
cd zed | |
Copy-Item ../build-repo/AppxManifest.zed.xml . | |
if (Test-Path "../build-repo/assets") { | |
Copy-Item ../build-repo/assets ./ -Recurse -Force | |
Write-Host "Copied assets from build-repo" | |
} else { | |
Write-Host "Assets directory not found in build-repo." | |
} | |
if (-not (Test-Path "assets")) { | |
New-Item -Path "assets" -ItemType Directory | |
Write-Host "Created new assets directory" | |
} else { | |
Write-Host "Assets directory already exists" | |
} | |
# Check if Zed.exe exists before trying to extract icon | |
$zedExePath = "target/release/Zed.exe" | |
if (Test-Path $zedExePath) { | |
# Extract and convert icon | |
$iconPath = "zed_icon.ico" | |
Add-Type -AssemblyName System.Drawing | |
try { | |
$icon = [System.Drawing.Icon]::ExtractAssociatedIcon($zedExePath) | |
$icon.ToBitmap().Save($iconPath, [System.Drawing.Imaging.ImageFormat]::Png) | |
magick convert $iconPath -resize 44x44 assets/Square44x44Logo.png | |
magick convert $iconPath -resize 150x150 assets/Square150x150Logo.png | |
magick convert $iconPath -resize 310x310 assets/LargeTile.png | |
magick convert $iconPath -resize 71x71 assets/SmallTile.png | |
magick convert $iconPath -resize 50x50 assets/StoreLogo.png | |
} catch { | |
Write-Host "Error extracting or converting icon: $_" | |
# Use placeholder images if icon extraction fails | |
Copy-Item ../build-repo/placeholder_*.png assets/ | |
} | |
} else { | |
Write-Host "Zed.exe not found at $zedExePath. Using placeholder images." | |
# Use placeholder images | |
Copy-Item ../build-repo/placeholder_*.png assets/ | |
} | |
# Ensure all required assets exist | |
$requiredAssets = @( | |
"Square44x44Logo.png", | |
"Square150x150Logo.png", | |
"LargeTile.png", | |
"SmallTile.png", | |
"StoreLogo.png" | |
) | |
foreach ($asset in $requiredAssets) { | |
if (-not (Test-Path "assets/$asset")) { | |
Write-Host "Warning: $asset not found. Creating a blank image." | |
magick convert -size 44x44 xc:transparent "assets/$asset" | |
} | |
} | |
- name: Prepare App Installer manifest | |
run: | | |
cd zed | |
$version = $env:LATEST_TAG -replace '^v', '' -replace '-pre$', '' | |
$version = $version -replace '^(\d+\.\d+\.\d+).*$', '$1' # Keep only X.Y.Z | |
if ($version -notmatch '^\d+\.\d+\.\d+\.\d+$') { | |
$version = $version + '.0' # Add a fourth number if necessary | |
} | |
$appInstallerContent = @" | |
<?xml version="1.0" encoding="utf-8"?> | |
<AppInstaller Uri="https://github.com/${{ github.repository }}/releases/download/${{ env.LATEST_TAG }}/Zed.appinstaller" | |
Version="$version" | |
xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"> | |
<MainBundle Name="Zed" | |
Version="$version" | |
Publisher="CN=ZedIndustries" | |
Uri="https://github.com/${{ github.repository }}/releases/download/${{ env.LATEST_TAG }}/Zed-windows-amd64-${{ env.LATEST_TAG }}.msixbundle"/> | |
<UpdateSettings> | |
<OnLaunch HoursBetweenUpdateChecks="0"/> | |
</UpdateSettings> | |
</AppInstaller> | |
"@ | |
$appInstallerContent | Out-File -FilePath "Zed.appinstaller" -Encoding utf8 | |
Write-Host "Created Zed.appinstaller file" | |
- name: List directory contents | |
working-directory: ./zed | |
run: | | |
Write-Host "Current directory:" | |
Get-Location | |
Write-Host "Directory contents:" | |
Get-ChildItem -Recurse | Select-Object FullName, Length, CreationTime, LastWriteTime | |
- name: Copy Zed executable | |
run: | | |
$sourceExe = "zed\target\release\deps\zed.exe" | |
$destExe = "zed\target\release\Zed.exe" | |
if (Test-Path $sourceExe) { | |
Copy-Item $sourceExe $destExe -Force | |
Write-Host "Copied Zed.exe to $destExe" | |
} else { | |
Write-Host "Error: Source Zed.exe not found at $sourceExe" | |
exit 1 | |
} | |
- name: Create MSIX bundle | |
working-directory: ./zed | |
run: | | |
$outputBundle = "Zed-windows-amd64-$env:LATEST_TAG.msixbundle" | |
$mappingFile = "mapping.txt" | |
$zedExePath = "target\release\Zed.exe" | |
# Verify Zed.exe exists | |
if (-not (Test-Path $zedExePath)) { | |
Write-Host "Error: Zed.exe not found at $zedExePath" | |
Write-Host "Searching for Zed.exe:" | |
Get-ChildItem -Recurse -Filter Zed.exe | Select-Object FullName, Length, CreationTime, LastWriteTime | |
exit 1 | |
} | |
# Create mapping file with correct path | |
@" | |
[Files] | |
"$zedExePath" "Zed.exe" | |
"AppxManifest.xml" "AppxManifest.xml" | |
"assets\Square44x44Logo.png" "assets\Square44x44Logo.png" | |
"assets\Square150x150Logo.png" "assets\Square150x150Logo.png" | |
"assets\LargeTile.png" "assets\LargeTile.png" | |
"assets\SmallTile.png" "assets\SmallTile.png" | |
"assets\StoreLogo.png" "assets\StoreLogo.png" | |
"@ | Out-File -Encoding utf8 $mappingFile | |
# Display mapping file contents | |
Write-Host "Mapping file contents:" | |
Get-Content $mappingFile | |
# Verify all files in mapping exist | |
Get-Content $mappingFile | Select-String -Pattern '^"([^"]+)"' | ForEach-Object { | |
$file = $_.Matches.Groups[1].Value | |
if (Test-Path $file) { | |
Write-Host "File exists: $file" | |
} else { | |
Write-Host "Error: File not found: $file" | |
} | |
} | |
# Create the MSIX bundle | |
& "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\MakeAppx.exe" bundle /f $mappingFile /p $outputBundle | |
if (Test-Path $outputBundle) { | |
Write-Host "MSIX bundle created successfully: $outputBundle" | |
} else { | |
Write-Host "Error: Failed to create MSIX bundle" | |
exit 1 | |
} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Zed-windows-amd64-${{ env.LATEST_TAG }} | |
path: | | |
zed/target/release/Zed-windows-amd64-${{ env.LATEST_TAG }}.exe | |
zed/Zed-windows-amd64-${{ env.LATEST_TAG }}.msixbundle | |
zed/Zed.appinstaller | |
upload-to-release: | |
needs: [build-windows-amd64] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: Zed-windows-amd64-${{ env.LATEST_TAG }} | |
- name: Get latest release info | |
id: get_release_info | |
run: | | |
LATEST_TAG=$(curl -s https://api.github.com/repos/zed-industries/zed/releases | jq -r '.[0].tag_name') | |
LATEST_TAG=${LATEST_TAG:-v0.0.0} | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
RELEASE_BODY=$(curl -s https://api.github.com/repos/zed-industries/zed/releases | jq -r '.[0].body') | |
echo "RELEASE_BODY<<EOF" >> $GITHUB_OUTPUT | |
echo "$RELEASE_BODY" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Check existing release | |
id: check_release | |
run: | | |
RELEASE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.LATEST_TAG }}") | |
echo "RELEASE_EXISTS=$([[ $RELEASE_EXISTS == "200" ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT | |
- name: Create or update release | |
id: release | |
uses: actions/create-release@v1 | |
if: steps.check_release.outputs.RELEASE_EXISTS == 'false' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.LATEST_TAG }} | |
release_name: ${{ env.LATEST_TAG }} | |
body: ${{ steps.get_release_info.outputs.RELEASE_BODY }} | |
draft: false | |
prerelease: false | |
- name: Update existing release | |
if: steps.check_release.outputs.RELEASE_EXISTS == 'true' | |
run: | | |
curl -X PATCH \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.LATEST_TAG }}" \ | |
-d '{ | |
"tag_name": "${{ env.LATEST_TAG }}", | |
"name": "${{ env.LATEST_TAG }}", | |
"body": ${{ toJson(steps.get_release_info.outputs.RELEASE_BODY) }}, | |
"draft": false, | |
"prerelease": false | |
}' | |
- name: Upload release assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
upload_url=$(curl -sH "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.LATEST_TAG }}" \ | |
| jq -r .upload_url | sed 's/{?name,label}//') | |
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary @Zed-windows-amd64-${{ env.LATEST_TAG }}.exe \ | |
"$upload_url?name=Zed-windows-amd64-${{ env.LATEST_TAG }}.exe" | |
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary @Zed-windows-amd64-${{ env.LATEST_TAG }}.msixbundle \ | |
"$upload_url?name=Zed-windows-amd64-${{ env.LATEST_TAG }}.msixbundle" | |
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary @Zed.appinstaller \ | |
"$upload_url?name=Zed.appinstaller" | |
- name: Checkout build repository | |
uses: actions/checkout@v4 | |
with: | |
repository: yannouuuu/zed-windows-build | |
fetch-depth: 0 | |
- name: Commit version update | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
branch: update | |
file_pattern: build.md *-update.json | |
commit_message: Bump version ${{ env.LATEST_TAG }} |