chore: update branch name in build workflow #142
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 | |
release: | |
types: [released, published, prereleased] | |
permissions: | |
contents: write | |
jobs: | |
set-version: | |
runs-on: ubuntu-latest | |
outputs: | |
latest_tag: ${{ steps.get_latest_tag.outputs.LATEST_TAG }} | |
steps: | |
- name: Get latest release tag (including pre-releases) | |
id: get_latest_tag | |
run: | | |
LATEST_TAG=$(curl -s "https://api.github.com/repos/zed-industries/zed/releases" | jq -r 'first | .tag_name') | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT | |
echo "Latest tag found (including pre-releases): $LATEST_TAG" | |
- name: Debug - Print LATEST_TAG | |
run: | | |
echo "LATEST_TAG value: ${{ steps.get_latest_tag.outputs.LATEST_TAG }}" | |
if [ -z "${{ steps.get_latest_tag.outputs.LATEST_TAG }}" ]; then | |
echo "Error: LATEST_TAG is empty or null" | |
exit 1 | |
fi | |
- name: Debug - Print API response | |
run: | | |
API_RESPONSE=$(curl -s "https://api.github.com/repos/zed-industries/zed/releases") | |
echo "API Response: $API_RESPONSE" | |
build-windows-amd64: | |
needs: set-version | |
runs-on: windows-latest | |
env: | |
LATEST_TAG: ${{ needs.set-version.outputs.latest_tag }} | |
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/ | |
C:/Users/runneradmin/.cargo/registry/ | |
C:/Users/runneradmin/.cargo/git/ | |
C:/Users/runneradmin/.rustup/ | |
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }} | |
- 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) { | |
# Define file extensions to remove | |
$extensionsToRemove = @("*.exe", "*.msix", "*.msixbundle", "*.appinstaller") | |
# Remove files with specified extensions | |
foreach ($extension in $extensionsToRemove) { | |
Get-ChildItem -Path $releasePath -Filter $extension | ForEach-Object { | |
Remove-Item $_.FullName -Force | |
Write-Host "Removed 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: Debug - Print LATEST_TAG | |
run: | | |
Write-Host "LATEST_TAG value: $env:LATEST_TAG" | |
if ([string]::IsNullOrEmpty($env:LATEST_TAG)) { | |
Write-Host "Error: LATEST_TAG is empty or null" | |
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 . | |
# Check if the assets folder exists | |
if (-not (Test-Path "assets")) { | |
Write-Host "Error: assets folder not found" | |
exit 1 | |
} | |
# Check for necessary icons | |
$requiredAssets = @( | |
"Square44x44Logo.png", | |
"Square150x150Logo.png", | |
"LargeTile.png", | |
"SmallTile.png", | |
"StoreLogo.png" | |
) | |
foreach ($asset in $requiredAssets) { | |
$assetPath = "assets/$asset" | |
if (Test-Path $assetPath) { | |
Write-Host "$asset exists in assets folder" | |
} else { | |
Write-Host "Warning: $asset not found in assets folder. Creating an empty image." | |
magick convert -size 44x44 xc:transparent $assetPath | |
} | |
} | |
# Display the contents of the assets folder | |
Write-Host "Contents of assets folder:" | |
Get-ChildItem -Path "assets" | ForEach-Object { Write-Host " $($_.Name)" } | |
- name: Debug - List zed directory contents | |
run: | | |
cd zed | |
Write-Host "Current directory:" | |
Get-Location | |
Write-Host "Directory contents:" | |
Get-ChildItem -Force | Select-Object Name, LastWriteTime, Length | |
- name: Update AppxManifest with correct version and tag | |
run: | | |
cd zed | |
$version = $env:LATEST_TAG -replace '^v', '' | |
$versionParts = $version -split '-' | |
$mainVersion = $versionParts[0] | |
# Ensure we have four parts to the version number | |
$versionNumbers = $mainVersion -split '\.' | |
if ($versionNumbers.Length -lt 4) { | |
$mainVersion = $mainVersion + ('.0' * (4 - $versionNumbers.Length)) | |
} | |
$content = Get-Content AppxManifest.zed.xml -Raw | |
$content = $content.Replace('__VERSION__', $mainVersion).Replace('__LATEST_TAG__', $env:LATEST_TAG) | |
Set-Content AppxManifest.zed.xml -Value $content -NoNewline | |
- name: Prepare App Installer manifest | |
run: | | |
cd zed | |
$version = $env:LATEST_TAG -replace '^v', '' | |
$versionParts = $version -split '-' | |
$mainVersion = $versionParts[0] | |
# Ensure we have four parts to the version number | |
$versionNumbers = $mainVersion -split '\.' | |
if ($versionNumbers.Length -lt 4) { | |
$mainVersion = $mainVersion + ('.0' * (4 - $versionNumbers.Length)) | |
} | |
$appInstallerContent = @" | |
<?xml version="1.0" encoding="utf-8"?> | |
<AppInstaller | |
xmlns="http://schemas.microsoft.com/appx/appinstaller/2018" | |
Version="$mainVersion" | |
Uri="https://github.com/${{ github.repository }}/releases/download/${{ env.LATEST_TAG }}/Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller"> | |
<MainPackage | |
Name="Zed" | |
Version="$mainVersion" | |
Publisher="CN=ZedIndustries" | |
Uri="https://github.com/${{ github.repository }}/releases/download/${{ env.LATEST_TAG }}/Zed-windows-amd64-${{ env.LATEST_TAG }}.exe" | |
ProcessorArchitecture="x64" /> | |
<UpdateSettings> | |
<OnLaunch HoursBetweenUpdateChecks="0" /> | |
</UpdateSettings> | |
</AppInstaller> | |
"@ | |
$appInstallerFileName = "Zed-windows-amd64-$env:LATEST_TAG.appinstaller" | |
$appInstallerContent | Out-File -FilePath $appInstallerFileName -Encoding utf8NoBOM | |
Write-Host "Created $appInstallerFileName file" | |
# Verify the content of the .appinstaller file | |
Get-Content $appInstallerFileName | |
- name: Install Windows SDK | |
run: | | |
choco install windows-sdk-10-version-2004-all | |
- name: Create MSIX package | |
run: | | |
cd zed | |
& "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\MakeAppx.exe" pack /d . /p Zed-windows-amd64-${{ env.LATEST_TAG }}.msix /f AppxManifest.zed.xml | |
Write-Host "MSIX package created successfully" | |
- name: Sign MSIX package | |
run: | | |
cd zed | |
& "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\SignTool.exe" sign /fd SHA256 /a /f ../build-repo/cert/ZedCertificate.pfx /p ${{ secrets.CERTIFICATE_PASSWORD }} Zed-windows-amd64-${{ env.LATEST_TAG }}.msix | |
Write-Host "MSIX package signed successfully" | |
- 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: Prepare and copy artifacts | |
run: | | |
$sourceExe = "zed\target\release\Zed-windows-amd64-${{ env.LATEST_TAG }}.exe" | |
$sourceMsix = "zed\Zed-windows-amd64-${{ env.LATEST_TAG }}.msix" | |
$appInstaller = "zed\Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller" | |
# Copy artifacts to root | |
if (Test-Path $sourceExe -and Test-Path $sourceMsix) { | |
Copy-Item $sourceExe . | |
Copy-Item $sourceMsix . | |
Copy-Item $appInstaller . | |
Write-Host "Copied artifacts to root directory" | |
} else { | |
Write-Host "Error: Source files not found" | |
exit 1 | |
} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Zed-windows-amd64-${{ env.LATEST_TAG }} | |
path: | | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.exe | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.msix | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller | |
- name: Debug - List uploaded artifacts | |
run: | | |
echo "Uploaded artifact name: Zed-windows-amd64-${{ env.LATEST_TAG }}" | |
echo "LATEST_TAG value: ${{ env.LATEST_TAG }}" | |
- name: Debug - List zed directory contents | |
run: | | |
cd zed | |
Write-Host "Current directory:" | |
Get-Location | |
Write-Host "Directory contents:" | |
Get-ChildItem -Force | Select-Object Name, LastWriteTime, Length | |
upload-to-release: | |
needs: [set-version, build-windows-amd64] | |
runs-on: ubuntu-latest | |
env: | |
LATEST_TAG: ${{ needs.set-version.outputs.latest_tag }} | |
steps: | |
- name: Debug - Print LATEST_TAG | |
run: | | |
echo "LATEST_TAG value: ${{ env.LATEST_TAG }}" | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: Zed-windows-amd64-${{ env.LATEST_TAG }} | |
- name: Debug - List downloaded files | |
run: ls -R | |
- name: Get latest release info | |
id: get_release_info | |
run: | | |
RELEASE_INFO=$(curl -s "https://api.github.com/repos/zed-industries/zed/releases/tags/${{ env.LATEST_TAG }}") | |
RELEASE_BODY=$(echo "$RELEASE_INFO" | jq -r '.body // "No release notes available."') | |
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV | |
echo "$RELEASE_BODY" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- 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_ENV | |
- name: Debug - Print LATEST_TAG | |
run: | | |
echo "LATEST_TAG value: ${{ needs.set-version.outputs.latest_tag }}" | |
- name: Create or update release | |
uses: softprops/action-gh-release@v1 | |
if: env.RELEASE_EXISTS == 'false' | |
with: | |
tag_name: ${{ env.LATEST_TAG }} | |
name: ${{ env.LATEST_TAG }} | |
body: ${{ env.RELEASE_BODY }} | |
draft: false | |
prerelease: false | |
files: | | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.exe | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.msix | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update existing release | |
uses: softprops/action-gh-release@v1 | |
if: env.RELEASE_EXISTS == 'true' | |
with: | |
tag_name: ${{ env.LATEST_TAG }} | |
name: ${{ env.LATEST_TAG }} | |
body: ${{ env.RELEASE_BODY }} | |
draft: false | |
prerelease: false | |
files: | | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.exe | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.msix | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- 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 }} |