-
Notifications
You must be signed in to change notification settings - Fork 2
389 lines (338 loc) · 13.5 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
name: Zed Windows Build
on:
workflow_dispatch:
push:
branches:
- main
- msix-build
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_OUTPUT
echo "Latest tag found (including pre-releases): $LATEST_TAG"
- name: Debug - Print LATEST_TAG
run: |
echo "LATEST_TAG value: ${{ steps.get_latest_tag.outputs.LATEST_TAG }}"
if [ -z "${{ steps.get_latest_tag.outputs.LATEST_TAG }}" ]; then
echo "Error: LATEST_TAG is empty or null"
exit 1
fi
- name: Debug - Print API response
run: |
API_RESPONSE=$(curl -s "https://api.github.com/repos/zed-industries/zed/releases")
echo "API Response: $API_RESPONSE"
build-windows-amd64:
needs: set-version
runs-on: windows-latest
env:
LATEST_TAG: ${{ needs.set-version.outputs.latest_tag }}
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/
target/
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: Cache Rust
uses: Swatinem/rust-cache@v2
with:
cache-directories: |
~/.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 }}-rust-${{ hashFiles('**/Cargo.lock') }}
- 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) {
# Define file extensions to remove
$extensionsToRemove = @("*.exe", "*.msix", "*.msixbundle", "*.appinstaller")
# Remove files with specified extensions
foreach ($extension in $extensionsToRemove) {
Get-ChildItem -Path $releasePath -Filter $extension | ForEach-Object {
Remove-Item $_.FullName -Force
Write-Host "Removed file: $($_.Name)"
}
}
# 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}"
}
- name: Build Zed
run: |
cd zed
cargo build --release -j 4
- name: Verify Zed build
run: |
if (Test-Path "zed/target/release/Zed.exe") {
Write-Host "Zed.exe built successfully"
} else {
Write-Host "Zed.exe not found after build"
exit 1
}
- name: Debug - Print LATEST_TAG
run: |
Write-Host "LATEST_TAG value: $env:LATEST_TAG"
if ([string]::IsNullOrEmpty($env:LATEST_TAG)) {
Write-Host "Error: LATEST_TAG is empty or null"
exit 1
}
- name: Rename build output
run: |
$sourceDir = "zed/target/release"
$sourceName = "Zed.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
}
- name: Prepare App Installer package
run: |
cd zed
Copy-Item ../build-repo/AppxManifest.zed.xml .
# Check if the assets folder exists
if (-not (Test-Path "assets")) {
Write-Host "Error: assets folder not found"
exit 1
}
# Check for necessary icons
$requiredAssets = @(
"Square44x44Logo.png",
"Square150x150Logo.png",
"LargeTile.png",
"SmallTile.png",
"StoreLogo.png"
)
foreach ($asset in $requiredAssets) {
$assetPath = "assets/$asset"
if (Test-Path $assetPath) {
Write-Host "$asset exists in assets folder"
} else {
Write-Host "Warning: $asset not found in assets folder. Creating an empty image."
magick convert -size 44x44 xc:transparent $assetPath
}
}
# Display the contents of the assets folder
Write-Host "Contents of assets folder:"
Get-ChildItem -Path "assets" | ForEach-Object { Write-Host " $($_.Name)" }
- name: Debug - List zed directory contents
run: |
cd zed
Write-Host "Current directory:"
Get-Location
Write-Host "Directory contents:"
Get-ChildItem -Force | Select-Object Name, LastWriteTime, Length
- name: Update AppxManifest with correct version and tag
run: |
cd zed
$version = $env:LATEST_TAG -replace '^v', ''
$versionParts = $version -split '-'
$mainVersion = $versionParts[0]
# Ensure we have four parts to the version number
$versionNumbers = $mainVersion -split '\.'
if ($versionNumbers.Length -lt 4) {
$mainVersion = $mainVersion + ('.0' * (4 - $versionNumbers.Length))
}
$content = Get-Content AppxManifest.zed.xml -Raw
$content = $content.Replace('__VERSION__', $mainVersion).Replace('__LATEST_TAG__', $env:LATEST_TAG)
Set-Content AppxManifest.zed.xml -Value $content -NoNewline
- name: Prepare App Installer manifest
run: |
cd zed
$version = $env:LATEST_TAG -replace '^v', ''
$versionParts = $version -split '-'
$mainVersion = $versionParts[0]
# Ensure we have four parts to the version number
$versionNumbers = $mainVersion -split '\.'
if ($versionNumbers.Length -lt 4) {
$mainVersion = $mainVersion + ('.0' * (4 - $versionNumbers.Length))
}
$appInstallerContent = @"
<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
xmlns="http://schemas.microsoft.com/appx/appinstaller/2018"
Version="$mainVersion"
Uri="https://github.com/${{ github.repository }}/releases/download/${{ env.LATEST_TAG }}/Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller">
<MainPackage
Name="Zed"
Version="$mainVersion"
Publisher="CN=ZedIndustries"
Uri="https://github.com/${{ github.repository }}/releases/download/${{ env.LATEST_TAG }}/Zed-windows-amd64-${{ env.LATEST_TAG }}.exe"
ProcessorArchitecture="x64" />
<UpdateSettings>
<OnLaunch HoursBetweenUpdateChecks="0" />
</UpdateSettings>
</AppInstaller>
"@
$appInstallerFileName = "Zed-windows-amd64-$env:LATEST_TAG.appinstaller"
$appInstallerContent | Out-File -FilePath $appInstallerFileName -Encoding utf8NoBOM
Write-Host "Created $appInstallerFileName file"
# Verify the content of the .appinstaller file
Get-Content $appInstallerFileName
- name: List directory contents
working-directory: ./zed
run: |
Write-Host "Current directory:"
Get-Location
Write-Host "Directory contents:"
Get-ChildItem -Recurse | Select-Object FullName, Length, CreationTime, LastWriteTime
- name: Prepare and copy artifacts
run: |
$sourceExe = "zed\target\release\Zed-windows-amd64-${{ env.LATEST_TAG }}.exe"
$appInstaller = "zed\Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller"
# Copy artifacts to root
if (Test-Path $sourceExe) {
Copy-Item $sourceExe .
Copy-Item $appInstaller .
Write-Host "Copied artifacts to root directory"
} else {
Write-Host "Error: Tagged Zed executable not found at $sourceExe"
exit 1
}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Zed-windows-amd64-${{ env.LATEST_TAG }}
path: |
Zed-windows-amd64-${{ env.LATEST_TAG }}.exe
Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller
- name: Debug - List uploaded artifacts
run: |
echo "Uploaded artifact name: Zed-windows-amd64-${{ env.LATEST_TAG }}"
echo "LATEST_TAG value: ${{ env.LATEST_TAG }}"
- name: Debug - List zed directory contents
run: |
cd zed
Write-Host "Current directory:"
Get-Location
Write-Host "Directory contents:"
Get-ChildItem -Force | Select-Object Name, LastWriteTime, Length
upload-to-release:
needs: [set-version, build-windows-amd64]
runs-on: ubuntu-latest
env:
LATEST_TAG: ${{ needs.set-version.outputs.latest_tag }}
steps:
- name: Debug - Print LATEST_TAG
run: |
echo "LATEST_TAG value: ${{ env.LATEST_TAG }}"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: Zed-windows-amd64-${{ env.LATEST_TAG }}
- name: Debug - List downloaded files
run: ls -R
- name: Get latest release info
id: get_release_info
run: |
RELEASE_INFO=$(curl -s "https://api.github.com/repos/zed-industries/zed/releases/tags/${{ env.LATEST_TAG }}")
RELEASE_BODY=$(echo "$RELEASE_INFO" | jq -r '.body // "No release notes available."')
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
echo "$RELEASE_BODY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- 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_ENV
- name: Debug - Print LATEST_TAG
run: |
echo "LATEST_TAG value: ${{ needs.set-version.outputs.latest_tag }}"
- name: Create or update release
uses: softprops/action-gh-release@v1
if: env.RELEASE_EXISTS == 'false'
with:
tag_name: ${{ env.LATEST_TAG }}
name: ${{ env.LATEST_TAG }}
body: ${{ env.RELEASE_BODY }}
draft: false
prerelease: false
files: |
Zed-windows-amd64-${{ env.LATEST_TAG }}.exe
Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update existing release
uses: softprops/action-gh-release@v1
if: env.RELEASE_EXISTS == 'true'
with:
tag_name: ${{ env.LATEST_TAG }}
name: ${{ env.LATEST_TAG }}
body: ${{ env.RELEASE_BODY }}
draft: false
prerelease: false
files: |
Zed-windows-amd64-${{ env.LATEST_TAG }}.exe
Zed-windows-amd64-${{ env.LATEST_TAG }}.appinstaller
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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 }}