feat: inherited msix-build branch set-version job #134
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: | |
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_ENV | |
echo "Latest tag found (including pre-releases): $LATEST_TAG" | |
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: | | |
$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 | |
- 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: | | |
$latestRelease = (Invoke-RestMethod -Uri https://api.github.com/repos/zed-industries/zed/releases/) | |
$latestTag = $latestRelease.tag_name | |
$isPrerelease = $latestRelease.prerelease.ToString().ToLower() | |
if (-not $latestTag) { | |
$latestTag = "v0.0.0" | |
$isPrerelease = "false" | |
} | |
echo "LATEST_TAG=$latestTag" >> $env:GITHUB_ENV | |
echo "IS_PRERELEASE=$isPrerelease" >> $env:GITHUB_ENV | |
echo "Latest tag: $latestTag, Is Pre-release: $isPrerelease" | |
- 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 | |
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_ENV | |
- name: Get latest release tag | |
id: get_latest_tag | |
run: | | |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/zed-industries/zed/releases/) | |
LATEST_TAG=$(echo $LATEST_RELEASE | jq -r '.tag_name') | |
IS_PRERELEASE=$(echo $LATEST_RELEASE | jq -r '.prerelease') | |
if [ -z "$LATEST_TAG" ]; then | |
LATEST_TAG="v0.0.0" | |
IS_PRERELEASE=false | |
fi | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV | |
echo "Latest tag: $LATEST_TAG, Is Pre-release: $IS_PRERELEASE" | |
- 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_ENV | |
echo "$BODY" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.LATEST_TAG }} | |
release_name: ${{ env.LATEST_TAG }} | |
body: ${{ env.RELEASE_BODY }} | |
draft: false | |
prerelease: ${{ env.IS_PRERELEASE }} | |
- name: Upload 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-${{ env.LATEST_TAG }}.exe | |
asset_name: Zed-windows-amd64-${{ env.LATEST_TAG }}.exe | |
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 }} |