Skip to content

Check Zed Releases and Build for Windows #74

Check Zed Releases and Build for Windows

Check Zed Releases and Build for Windows #74

Workflow file for this run

name: Check Zed Releases and Build for Windows
on:
schedule:
- cron: '0 */6 * * *' # Runs every 6 hours
workflow_dispatch:
inputs:
force_build:
description: 'Force build even if not needed'
required: false
type: boolean
default: false
env:
ZED_REPO: 'zed-industries/zed'
SCCACHE_DIR: C:\sccache
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
RUSTFLAGS: "-C opt-level=3 -C codegen-units=16"
CARGO_PROFILE_RELEASE_LTO: "off"
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 16
SCCACHE_CACHE_SIZE: 20G
SCCACHE_ERROR_LOG: C:\sccache_error.log
jobs:
check-and-build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get latest release
id: get_latest_release
run: |
$release = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ env.ZED_REPO }}/releases/latest")
$tag = $release.tag_name
echo "LATEST_TAG=$tag" >> $env:GITHUB_OUTPUT
- name: Check if build needed
id: check_build
run: |
$latestBuild = Get-Content -Path .\latest_build.txt -ErrorAction SilentlyContinue
$forceBuild = '${{ github.event.inputs.force_build }}' -eq 'true'
if ("${{ steps.get_latest_release.outputs.LATEST_TAG }}" -ne "$latestBuild" -or $forceBuild) {
echo "BUILD_NEEDED=true" >> $env:GITHUB_OUTPUT
} else {
echo "BUILD_NEEDED=false" >> $env:GITHUB_OUTPUT
}
- name: Set core count
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
run: |
$cores = (Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors
echo "CPU_CORES=$cores" >> $env:GITHUB_ENV
- name: Checkout Zed
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
uses: actions/checkout@v4
with:
repository: ${{ env.ZED_REPO }}
ref: ${{ steps.get_latest_release.outputs.LATEST_TAG }}
path: 'zed'
- name: Install Rust
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Rust dependencies
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
uses: actions/cache@v4
with:
path: |
~\.cargo\registry
~\.cargo\git
zed\target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-
${{ runner.os }}-cargo-
- name: Install latest sccache
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
run: |
$ProgressPreference = 'SilentlyContinue'
$latestRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/mozilla/sccache/releases/latest").tag_name
$latestVersion = $latestRelease -replace 'v',''
Invoke-WebRequest -Uri "https://github.com/mozilla/sccache/releases/download/$latestRelease/sccache-$latestRelease-x86_64-pc-windows-msvc.tar.gz" -OutFile sccache.tar.gz
tar xzf sccache.tar.gz
Move-Item -Path "sccache-$latestRelease-x86_64-pc-windows-msvc\sccache.exe" -Destination "$env:USERPROFILE\.cargo\bin\sccache.exe"
echo "Installed sccache version $latestVersion"
- name: Setup sccache
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
run: |
echo "RUSTC_WRAPPER=sccache" >> $env:GITHUB_ENV
echo "SCCACHE_DIR=${{ env.SCCACHE_DIR }}" >> $env:GITHUB_ENV
echo "SCCACHE_CACHE_SIZE=${{ env.SCCACHE_CACHE_SIZE }}" >> $env:GITHUB_ENV
echo "SCCACHE_ERROR_LOG=${{ env.SCCACHE_ERROR_LOG }}" >> $env:GITHUB_ENV
- name: Cache sccache
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
uses: actions/cache@v4
with:
path: ${{ env.SCCACHE_DIR }}
key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}-
${{ runner.os }}-sccache-
- name: Start sccache server
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
run: |
sccache --start-server
sccache --show-stats
- name: Build Zed
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
run: |
cd zed
cargo build --release --jobs $env:CPU_CORES --verbose
env:
CARGO_BUILD_JOBS: ${{ env.CPU_CORES }}
- name: Rename and move built executable
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
id: rename_executable
continue-on-error: true
run: |
$version = "${{ steps.get_latest_release.outputs.LATEST_TAG }}"
$newFileName = "zed-windows-$version.exe"
Move-Item -Path "./zed/target/release/zed.exe" -Destination "./$newFileName"
echo "ARTIFACT_NAME=$newFileName" >> $env:GITHUB_OUTPUT
- name: Create Release
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
id: create_release
continue-on-error: true
uses: softprops/action-gh-release@v2
with:
tag_name: zed-windows-${{ steps.get_latest_release.outputs.LATEST_TAG }}
name: Zed for Windows ${{ steps.get_latest_release.outputs.LATEST_TAG }}
draft: false
prerelease: false
files: ./${{ steps.rename_executable.outputs.ARTIFACT_NAME }}
- name: Update latest build
if: steps.check_build.outputs.BUILD_NEEDED == 'true'
continue-on-error: true
run: |
$latestTag = "${{ steps.get_latest_release.outputs.LATEST_TAG }}"
$latestTag | Out-File -FilePath .\latest_build.txt -NoNewline
git config user.name github-actions
git config user.email github-actions@github.com
git add latest_build.txt
$status = git status --porcelain
if ($status) {
git pull
git commit -m "Update latest build to $latestTag"
git push
echo "Changes committed and pushed."
} else {
echo "No changes to commit. latest_build.txt is already up to date."
}