4646 . scripts/utils.ps1
4747 $cmderVersion = Get-VersionStr
4848 $buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
49-
49+
5050 # Determine branch link (handle PR merge refs)
5151 $branchName = "${{ github.ref_name }}"
5252 $branchLink = ""
@@ -61,12 +61,12 @@ jobs:
6161 # Regular branch, link to the branch tree
6262 $branchLink = "https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}"
6363 }
64-
64+
6565 $summary = @"
6666 ## 📦 Build Cmder - Workflow Summary
67-
67+
6868 <small>Build started: $buildTime</small>
69-
69+
7070 ### Repository Information
7171 | Property | Value |
7272 | --- | --- |
@@ -76,14 +76,14 @@ jobs:
7676 | Actor | [@${{ github.actor }}](https://github.com/${{ github.actor }}) |
7777 | Workflow | ``${{ github.workflow }}`` |
7878 | Cmder Version | **$cmderVersion** |
79-
79+
8080 ---
81-
81+
8282 ### 📁 Vendor Packages
8383 | Package | Version |
8484 | --- | --- |
8585 "@
86-
86+
8787 # Read vendor sources.json and add to summary
8888 $vendorSources = Get-Content "vendor/sources.json" | ConvertFrom-Json
8989 if ($vendorSources.Count -eq 0) {
9494 }
9595 }
9696 $summary += "`n"
97-
97+
9898 $summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
9999
100100 - name : Add MSBuild to PATH
@@ -110,13 +110,13 @@ jobs:
110110 shell : pwsh
111111 run : |
112112 @"
113-
113+
114114 ---
115-
115+
116116 ### Build Status
117-
117+
118118 ✅ Cmder built successfully.
119-
119+
120120 "@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
121121
122122 - name : Pack the built files
@@ -156,28 +156,28 @@ jobs:
156156 GH_TOKEN : ${{ github.token }}
157157 run : |
158158 $summary = @"
159-
159+
160160 ---
161-
161+
162162 ### 🗃️ Artifacts
163-
163+
164164 | Artifact | Size | Download | Hash (SHA256) |
165165 | --- | --- | --- | --- |
166166 "@
167-
167+
168168 # Function to get artifact download URL with retry logic
169169 function Get-ArtifactDownloadUrl {
170170 param(
171171 [string]$ArtifactName,
172172 [int]$MaxRetries = 3,
173173 [int]$DelaySeconds = 2
174174 )
175-
175+
176176 for ($i = 0; $i -lt $MaxRetries; $i++) {
177177 try {
178178 # Use GitHub CLI to get artifact information
179179 $artifactsJson = gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" --jq ".artifacts[] | select(.name == `"$ArtifactName`")"
180-
180+
181181 if ($artifactsJson) {
182182 $artifact = $artifactsJson | ConvertFrom-Json
183183 if ($artifact.archive_download_url) {
@@ -187,32 +187,32 @@ jobs:
187187 } catch {
188188 Write-Host "Attempt $($i + 1) failed to get artifact URL for $ArtifactName : $_"
189189 }
190-
190+
191191 if ($i -lt ($MaxRetries - 1)) {
192192 Start-Sleep -Seconds $DelaySeconds
193193 }
194194 }
195-
195+
196196 return $null
197197 }
198-
198+
199199 $artifacts = @("cmder.zip", "cmder.7z", "cmder_mini.zip", "hashes.txt")
200200 foreach ($artifact in $artifacts) {
201201 $path = "build/$artifact"
202202 if (Test-Path $path) {
203203 $size = (Get-Item $path).Length / 1MB
204204 $hash = (Get-FileHash $path -Algorithm SHA256).Hash
205-
205+
206206 # Try to get the actual artifact download URL
207207 $downloadUrl = Get-ArtifactDownloadUrl -ArtifactName $artifact
208208 $warning = ""
209-
209+
210210 if (-not $downloadUrl) {
211211 # Fallback to workflow run page if artifact URL fetch fails
212212 $downloadUrl = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
213213 $warning = " ⚠️"
214214 }
215-
215+
216216 # Determine emoji based on file type
217217 if ($artifact -match '\.txt$') {
218218 $emoji = "📄"
@@ -221,12 +221,12 @@ jobs:
221221 } else {
222222 $emoji = "📦"
223223 }
224-
224+
225225 $summary += "`n| $emoji ``$artifact`` | $([math]::Round($size, 2)) MB | [📥 Download$warning]($downloadUrl) | ``$hash`` |"
226226 }
227227 }
228228 $summary += "`n"
229-
229+
230230 $summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
231231
232232 - name : Create Release
@@ -246,17 +246,17 @@ jobs:
246246 shell : pwsh
247247 run : |
248248 @"
249-
249+
250250 ---
251-
251+
252252 ### Release Information
253-
253+
254254 🚀 Draft release created for tag: **``${{ github.ref_name }}``**
255-
255+
256256 Release includes:
257257 - Full version (``cmder.zip``, ``cmder.7z``)
258258 - Mini version (``cmder_mini.zip``)
259259 - File hashes (``hashes.txt``)
260-
260+
261261 > ⚠️ Release is in **draft** mode. Please review and publish manually.
262262 "@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
0 commit comments