Skip to content

chore: add verification steps for downloaded artifacts and environmen… #39

chore: add verification steps for downloaded artifacts and environmen…

chore: add verification steps for downloaded artifacts and environmen… #39

Workflow file for this run

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-
- 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
}
- name: Diagnostic and rename build output
run: |
# Retrieving the last tag
$allTags = (Invoke-RestMethod -Uri https://api.github.com/repos/zed-industries/zed/releases | ForEach-Object { $_.tag_name })
$latestTag = $allTags | Select-Object -First 1
Write-Host "Latest tag: $latestTag"
# Path definition
$sourceDir = "target\release"
$sourceName = "Zed.exe"
$newFileName = "Zed-windows-amd64-$latestTag.exe"
$sourcePath = Join-Path -Path $sourceDir -ChildPath $sourceName
$destinationPath = Join-Path -Path $sourceDir -ChildPath $newFileName
if (Test-Path -Path $destinationPath) {
Write-Host "File $destinationPath already exists. Deleting the old file."
Remove-Item -Path $destinationPath
}
Write-Host "Current directory: $(Get-Location)"
Write-Host "Source directory exists: $(Test-Path -Path $sourceDir)"
Write-Host "Source path: $sourcePath"
Write-Host "Source file exists: $(Test-Path -Path $sourcePath)"
Write-Host "Destination path: $destinationPath"
Write-Host "Contents of ${sourceDir}:"
if (Test-Path -Path $sourceDir) {
Get-ChildItem -Path $sourceDir | ForEach-Object { Write-Host $_.Name }
} else {
Write-Host "Source directory does not exist."
}
if (Test-Path -Path $sourcePath) {
try {
Rename-Item -Path $sourcePath -NewName $newFileName -Force -ErrorAction Stop
Write-Host "File renamed successfully to $newFileName"
"NEXT_VER_CODE=$latestTag" | Out-File -FilePath $env:GITHUB_ENV -Append
} catch {
Write-Host "Error renaming file: $_"
exit 1
}
} else {
Write-Host "Error: Source file $sourcePath not found"
exit 1
}
- uses: actions/upload-artifact@v4
with:
name: Zed-windows-amd64-${{ env.NEXT_VER_CODE }}
path: target/release/Zed-windows-amd64-${{ env.NEXT_VER_CODE }}.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 "NEXT_VER_CODE: ${{ env.NEXT_VER_CODE }}"
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: Set version tag
id: set_version
run: |
latestTag=$(curl -s https://api.github.com/repos/zed-industries/zed/releases/latest | jq -r .tag_name)
if [ -z "$latestTag" ]; then
echo "Error: Unable to retrieve the latest tag"
exit 1
fi
echo "NEXT_VER_CODE=${latestTag}" >> $GITHUB_ENV
echo "Latest tag: $latestTag"
- name: Fetch release body from Zed
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 '.[0].body')
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
echo "$BODY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Verify environment variables
run: |
echo "NEXT_VER_CODE: ${{ env.NEXT_VER_CODE }}"
ls -l target/release/
- name: Upload modules to release
uses: svenstaro/upload-release-action@v2
if: env.NEXT_VER_CODE != ''
with:
release_name: ${{ env.NEXT_VER_CODE }}
tag: ${{ env.NEXT_VER_CODE }}
body: ${{ env.RELEASE_BODY }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ github.workspace }}/target/release/Zed-windows-amd64-${{ env.NEXT_VER_CODE }}.exe
overwrite: true
- 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 }}