Zed Windows Build #59
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 | |
permissions: | |
contents: write | |
jobs: | |
build-windows-amd64: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: zed-industries/zed | |
- uses: dtolnay/rust-toolchain@stable | |
- run: rustup target add wasm32-wasi | |
- uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: amd64 | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.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 }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
# 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) | |
$oldArtifactsAmd = Get-ChildItem -Path "target/release" -Filter "Zed-windows-amd64-*.exe" | |
$oldArtifacts = Get-ChildItem -Path "target/release" -Filter "Zed.exe" | |
foreach ($artifact in $oldArtifactsAmd) { | |
if ($artifact.Name -ne "Zed-windows-amd64-$latestTag.exe") { | |
Remove-Item $artifact.FullName -Force | |
Write-Host "Removed old artifact: $($artifact.Name)" | |
} | |
} | |
foreach ($artifact in $oldArtifacts) { | |
if ($artifact.Name -ne "Zed.exe") { | |
Remove-Item $artifact.FullName -Force | |
Write-Host "Removed old artifact: $($artifact.Name)" | |
} | |
} | |
################################################ Build Zed ################################################ | |
- run: cargo build --release -j 4 | |
########################################################################################################### | |
- run: copy target/release/Zed.exe target/release/Zed-windows-amd64.exe | |
# Check if the file exists | |
- run: | | |
if (Test-Path -Path 'target/release/Zed-windows-amd64.exe') { | |
echo "Build successful, file exists." | |
} | |
else { | |
echo "Build failed, file does not exist." | |
exit 1 | |
} | |
# Get latest release tag from GitHub API + fallback to v0.0.0 if no tag is found | |
- name: Get latest release tag from GitHub API | |
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" | |
# Rename build output to include the latest tag | |
- name: Rename build output | |
run: | | |
$sourceDir = "target\release" | |
$sourceName = "Zed-windows-amd64.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 | |
} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Zed-windows-amd64-${{ env.LATEST_TAG }} | |
path: target/release/Zed-windows-amd64-${{ env.LATEST_TAG }}.exe | |
################################################### MSIX PART ################################################## | |
- name: Install Windows SDK | |
uses: microsoft/[email protected] | |
- name: Extract and convert icon | |
run: | | |
$iconPath = "zed_icon.ico" | |
Add-Type -AssemblyName System.Drawing | |
$icon = [System.Drawing.Icon]::ExtractAssociatedIcon("target\release\Zed.exe") | |
$icon.ToBitmap().Save($iconPath, [System.Drawing.Imaging.ImageFormat]::Png) | |
.\IconExtractor.exe "target\release\Zed.exe" "zed_icon.ico" | |
magick convert zed_icon.ico -resize 44x44 assets\Square44x44Logo.png | |
magick convert zed_icon.ico -resize 150x150 assets\Square150x150Logo.png | |
magick convert zed_icon.ico -resize 310x310 assets\LargeTile.png | |
magick convert zed_icon.ico -resize 71x71 assets\SmallTile.png | |
magick convert zed_icon.ico -resize 50x50 assets\StoreLogo.png | |
- name: Create MSIX manifest | |
run: | | |
$manifestContent = Get-Content -Path "AppxManifest.zed.xml" -Raw | |
$manifestContent = $manifestContent -replace "__VERSION__", "${{ env.LATEST_TAG }}" | |
$manifestContent | Out-File -FilePath "AppxManifest.xml" -Encoding utf8 | |
- name: Create MSIX package | |
run: | | |
& "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.xml | |
################################################################################################################ | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Zed-windows-amd64-${{ env.LATEST_TAG }} | |
path: | | |
target/release/Zed-windows-amd64-${{ env.LATEST_TAG }}.exe | |
Zed-windows-amd64-${{ env.LATEST_TAG }}.msix | |
upload-to-release: | |
runs-on: ubuntu-latest | |
needs: [build-windows-amd64] | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: Zed-* | |
merge-multiple: true | |
path: target/release | |
- name: Verify downloaded artifacts | |
run: | | |
echo "Contents of current directory:" | |
ls -R | |
echo "Contents of target/release directory:" | |
ls -l target/release || echo "target/release directory does not exist" | |
- name: Verify environment variables and files | |
run: | | |
echo "LATEST_TAG=$LATEST_TAG" | |
echo "Current directory:" | |
pwd | |
echo "Contents of current directory:" | |
ls -R | |
echo "Contents of target/release directory:" | |
ls -l target/release || echo "target/release directory does not exist" | |
echo "Searching for Zed-windows-amd64 files:" | |
find . -name "Zed-windows-amd64*" | |
- name: Get current date | |
id: get_date | |
run: echo "DATE=$(date +'%m-%d-%Y')" >> $GITHUB_OUTPUT | |
- name: Get latest release tag from GitHub API | |
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: Fetch release body from GitHub API | |
id: fetch_body | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
RELEASE_DATA=$(curl -s \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
https://api.github.com/repos/zed-industries/zed/releases/) | |
BODY=$(echo "$RELEASE_DATA" | jq -r '.body') | |
echo "RELEASE_BODY<<EOF" >> $GITHUB_OUTPUT | |
echo "$BODY" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Check if release exists | |
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 }}") | |
if [ "$RELEASE_EXISTS" = "200" ]; then | |
echo "RELEASE_EXISTS=true" >> $GITHUB_OUTPUT | |
else | |
echo "RELEASE_EXISTS=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Create Release | |
id: create_release | |
if: steps.check_release.outputs.RELEASE_EXISTS == 'false' | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_name: ${{ steps.get_latest_tag.outputs.LATEST_TAG }} | |
tag_name: ${{ steps.get_latest_tag.outputs.LATEST_TAG }} | |
body: ${{ steps.fetch_body.outputs.RELEASE_BODY }} | |
draft: false | |
prerelease: ${{ steps.get_latest_tag.outputs.IS_PRERELEASE }} | |
- 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.fetch_body.outputs.RELEASE_BODY) }}, | |
"draft": false, | |
"prerelease": ${{ env.IS_PRERELEASE }} | |
}' | |
- name: Get Release ID | |
id: get_release_id | |
run: | | |
RELEASE_ID=$(curl -s \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.LATEST_TAG }}" \ | |
| jq -r .id) | |
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_OUTPUT | |
- name: Upload EXE Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/release/Zed-windows-amd64-${{ steps.get_latest_tag.outputs.LATEST_TAG }}.exe | |
asset_name: Zed-windows-amd64-${{ steps.get_latest_tag.outputs.LATEST_TAG }}.exe | |
asset_content_type: application/octet-stream | |
- name: Upload MSIX Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./Zed-windows-amd64-${{ steps.get_latest_tag.outputs.LATEST_TAG }}.msix | |
asset_name: Zed-windows-amd64-${{ steps.get_latest_tag.outputs.LATEST_TAG }}.msix | |
asset_content_type: application/octet-stream | |
- uses: actions/checkout@v4 | |
with: | |
repository: yannouuuu/zed-windows-build | |
fetch-depth: 0 | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
branch: update | |
file_pattern: build.md *-update.json | |
commit_message: Bump version ${{ env.NEXT_VER_CODE }} |