cache: exclude unnecessary cargo and rustup directories #74
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/ | |
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: 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) { | |
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" | |
} | |
} else { | |
Write-Host "Release directory does not exist yet: $releasePath" | |
} | |
- name: Build Zed | |
run: | | |
cd zed | |
cargo build --release -j 4 | |
- name: Prepare build output | |
run: | | |
cd zed | |
Copy-Item target/release/Zed.exe target/release/Zed-windows-amd64-$env:LATEST_TAG.exe | |
if (Test-Path target/release/Zed-windows-amd64-$env:LATEST_TAG.exe) { | |
echo "Build successful, file exists." | |
} else { | |
echo "Build failed, file does not exist." | |
exit 1 | |
} | |
- name: Prepare MSIX package | |
run: | | |
cd zed | |
Copy-Item ../build-repo/AppxManifest.zed.xml . | |
if (Test-Path "../build-repo/assets") { | |
Copy-Item ../build-repo/assets ./ -Recurse | |
} else { | |
Write-Host "Assets directory not found. Creating empty assets directory." | |
New-Item -Path "assets" -ItemType Directory | |
} | |
# Extract and convert icon | |
$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) | |
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: | | |
cd zed | |
$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: | | |
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.xml | |
- 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 }}.msix | |
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 }}.msix \ | |
"$upload_url?name=Zed-windows-amd64-${{ env.LATEST_TAG }}.msix" | |
- 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 }} |