Skip to content

Commit dc7e1c1

Browse files
authored
Fix GitHub Actions step summary generation issues
2 parents be3d66d + 55251f7 commit dc7e1c1

File tree

7 files changed

+473
-162
lines changed

7 files changed

+473
-162
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
16
version: 2
27
updates:
38
# Enable version updates for GitHub Actions
4-
- package-ecosystem: "github-actions"
9+
- package-ecosystem: "github-actions" # See documentation for possible values
510
directory: "/" # Location of package manifests
611
schedule:
712
interval: "weekly"

.github/workflows/build.yml

Lines changed: 162 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- "v*"
1313
pull_request:
1414
branches: [ "master", "development" ]
15+
workflow_dispatch:
1516

1617
#---------------------------------#
1718
# environment configuration #
@@ -42,17 +43,94 @@ jobs:
4243
- name: Summary - Repository checkout
4344
shell: pwsh
4445
run: |
45-
echo "## 📦 Build Cmder - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY
46-
echo "" >> $env:GITHUB_STEP_SUMMARY
47-
echo "### Repository Information" >> $env:GITHUB_STEP_SUMMARY
48-
echo "| Property | Value |" >> $env:GITHUB_STEP_SUMMARY
49-
echo "| --- | --- |" >> $env:GITHUB_STEP_SUMMARY
50-
echo "| Repository | \`${{ github.repository }}\` |" >> $env:GITHUB_STEP_SUMMARY
51-
echo "| Branch | \`${{ github.ref_name }}\` |" >> $env:GITHUB_STEP_SUMMARY
52-
echo "| Commit | \`${{ github.sha }}\` |" >> $env:GITHUB_STEP_SUMMARY
53-
echo "| Actor | @${{ github.actor }} |" >> $env:GITHUB_STEP_SUMMARY
54-
echo "| Workflow | \`${{ github.workflow }}\` |" >> $env:GITHUB_STEP_SUMMARY
55-
echo "" >> $env:GITHUB_STEP_SUMMARY
46+
# Get Cmder version
47+
. scripts/utils.ps1
48+
$cmderVersion = Get-VersionStr
49+
$buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
50+
51+
# Determine branch and PR information
52+
$refName = "${{ github.ref_name }}"
53+
$headRef = "${{ github.head_ref }}"
54+
$eventName = "${{ github.event_name }}"
55+
$prNumber = $null
56+
$actualBranchName = $refName
57+
$branchLink = ""
58+
$prLink = ""
59+
60+
# Check if this is a PR merge ref (e.g., "3061/merge")
61+
if ($refName -match '^(\d+)/(merge|head)$') {
62+
$prNumber = $Matches[1]
63+
# Use head_ref for the actual branch name if available
64+
if ($headRef) {
65+
$actualBranchName = $headRef
66+
}
67+
$branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
68+
$prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
69+
} elseif ($eventName -eq "pull_request") {
70+
# This is a pull request event
71+
$prNumber = "${{ github.event.pull_request.number }}"
72+
if ($headRef) {
73+
$actualBranchName = $headRef
74+
}
75+
$branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
76+
$prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
77+
} else {
78+
# Regular branch, link to the branch tree
79+
$branchLink = "https://github.com/${{ github.repository }}/tree/$refName"
80+
}
81+
82+
$summary = @"
83+
## 📦 Build Cmder - Workflow Summary
84+
85+
<small>Build started: ``$buildTime``</small>
86+
87+
### Repository Information
88+
| Property | Value |
89+
| --- | --- |
90+
| Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) |
91+
| Branch | [``$actualBranchName``]($branchLink) |
92+
$(if ($prNumber) { "| Pull Request | [#$prNumber]($prLink) |" })
93+
| Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
94+
| Actor | [@${{ github.actor }}](https://github.com/${{ github.actor }}) |
95+
| Workflow | ``${{ github.workflow }}`` |
96+
| Cmder Version | **$cmderVersion** |
97+
98+
---
99+
100+
### 🗃️ Vendor Packages ([sources.json](vendor/sources.json))
101+
| Package | Version |
102+
| --- | --- |
103+
"@
104+
105+
# Read vendor sources.json and add to summary
106+
$vendorSources = Get-Content -Raw "vendor/sources.json" | ConvertFrom-Json
107+
if ($vendorSources.Count -eq 0) {
108+
$summary += "`n| _No vendor packages found_ | |"
109+
} else {
110+
foreach ($vendor in $vendorSources) {
111+
# Create release link based on vendor package
112+
$versionLink = "$($vendor.version)"
113+
if ($vendor.url) {
114+
# Extract owner/repo/tag from the URL and create release link
115+
# Handle both /releases/download/ and /archive/ URLs
116+
if ($vendor.url -match 'github\.com/([^/]+)/([^/]+)/(releases/download|archive)/([^/]+)') {
117+
$owner = $Matches[1]
118+
$repo = $Matches[2]
119+
$pathType = $Matches[3]
120+
$tag = $Matches[4]
121+
if ($pathType -eq 'archive') {
122+
$tag = $tag -replace '\.(?:tar\.gz|tgz|zip)$', ''
123+
}
124+
$versionLink = "[$($vendor.version)](https://github.com/$owner/$repo/releases/tag/$tag)"
125+
}
126+
}
127+
$summary += "`n| ``$($vendor.name)`` | $versionLink |"
128+
}
129+
}
130+
131+
$summary += "`n"
132+
133+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
56134
57135
- name: Add MSBuild to PATH
58136
uses: microsoft/setup-msbuild@v3
@@ -66,36 +144,21 @@ jobs:
66144
if: success()
67145
shell: pwsh
68146
run: |
69-
echo "### ✅ Build Status" >> $env:GITHUB_STEP_SUMMARY
70-
echo "" >> $env:GITHUB_STEP_SUMMARY
71-
echo "Cmder launcher successfully compiled." >> $env:GITHUB_STEP_SUMMARY
72-
echo "" >> $env:GITHUB_STEP_SUMMARY
147+
$summary = @"
148+
149+
---
150+
151+
✅ Cmder built successfully.
152+
153+
"@
154+
155+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
73156
74157
- name: Pack the built files
75158
shell: pwsh
76159
working-directory: scripts
77160
run: .\pack.ps1 -verbose
78161

79-
- name: Summary - Package artifacts
80-
if: success()
81-
shell: pwsh
82-
run: |
83-
echo "### 📦 Artifacts Created" >> $env:GITHUB_STEP_SUMMARY
84-
echo "" >> $env:GITHUB_STEP_SUMMARY
85-
echo "| Artifact | Size | Hash (SHA256) |" >> $env:GITHUB_STEP_SUMMARY
86-
echo "| --- | --- | --- |" >> $env:GITHUB_STEP_SUMMARY
87-
$artifacts = @("cmder.zip", "cmder.7z", "cmder_mini.zip")
88-
foreach ($artifact in $artifacts) {
89-
$path = "build/$artifact"
90-
if (Test-Path $path) {
91-
$size = (Get-Item $path).Length / 1MB
92-
# Truncate hash to first 16 chars for summary readability (full hash in hashes.txt)
93-
$hash = (Get-FileHash $path -Algorithm SHA256).Hash.Substring(0, 16)
94-
echo "| \`$artifact\` | $([math]::Round($size, 2)) MB | \`$hash...\` |" >> $env:GITHUB_STEP_SUMMARY
95-
}
96-
}
97-
echo "" >> $env:GITHUB_STEP_SUMMARY
98-
99162
- name: Upload artifact (cmder.zip)
100163
uses: actions/upload-artifact@v7
101164
with:
@@ -128,15 +191,55 @@ jobs:
128191
- name: Summary - Artifacts uploaded
129192
if: success()
130193
shell: pwsh
194+
env:
195+
GH_TOKEN: ${{ github.token }}
131196
run: |
132-
echo "### ☁️ Upload Status" >> $env:GITHUB_STEP_SUMMARY
133-
echo "" >> $env:GITHUB_STEP_SUMMARY
134-
echo "All artifacts successfully uploaded to GitHub Actions:" >> $env:GITHUB_STEP_SUMMARY
135-
echo '- ✅ `cmder.zip`' >> $env:GITHUB_STEP_SUMMARY
136-
echo '- ✅ `cmder.7z`' >> $env:GITHUB_STEP_SUMMARY
137-
echo '- ✅ `cmder_mini.zip`' >> $env:GITHUB_STEP_SUMMARY
138-
echo '- ✅ `hashes.txt`' >> $env:GITHUB_STEP_SUMMARY
139-
echo "" >> $env:GITHUB_STEP_SUMMARY
197+
# Source utility functions
198+
. scripts/utils.ps1
199+
200+
$summary = @"
201+
202+
### 🗃️ Artifacts
203+
204+
| Artifact | Size | Hash (SHA256) |
205+
| --- | --- | --- |
206+
"@
207+
208+
# Get all files from the build directory (excluding directories and hidden files)
209+
if (Test-Path "build") {
210+
$buildFiles = Get-ChildItem -Path "build" -File | Where-Object { -not $_.Name.StartsWith('.') } | Sort-Object Name
211+
212+
foreach ($file in $buildFiles) {
213+
$artifact = $file.Name
214+
$path = $file.FullName
215+
$sizeFormatted = Format-FileSize -Bytes $file.Length
216+
$hash = (Get-FileHash $path -Algorithm SHA256).Hash
217+
218+
# Try to get the actual artifact download URL
219+
$downloadUrl = Get-ArtifactDownloadUrl -ArtifactName $artifact -Repository "${{ github.repository }}" -RunId "${{ github.run_id }}"
220+
$warning = ""
221+
222+
if (-not $downloadUrl) {
223+
# Fallback to workflow run page if artifact URL fetch fails
224+
$downloadUrl = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
225+
$warning = " ⚠️"
226+
}
227+
228+
# Determine emoji based on file type
229+
if ($artifact -match '\.txt$') {
230+
$emoji = "📄"
231+
} elseif ($artifact -match '\.(zip|rar|7z)$') {
232+
$emoji = "🗄️"
233+
} else {
234+
$emoji = "📦"
235+
}
236+
237+
$summary += "`n| $emoji [``$artifact``$warning]($downloadUrl) | $sizeFormatted | ``$hash`` |"
238+
}
239+
}
240+
$summary += "`n"
241+
242+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
140243
141244
- name: Create Release
142245
uses: softprops/action-gh-release@v2
@@ -154,14 +257,20 @@ jobs:
154257
if: startsWith(github.ref, 'refs/tags/')
155258
shell: pwsh
156259
run: |
157-
echo "### 🚀 Release Information" >> $env:GITHUB_STEP_SUMMARY
158-
echo "" >> $env:GITHUB_STEP_SUMMARY
159-
echo "Draft release created for tag: **\`${{ github.ref_name }}\`**" >> $env:GITHUB_STEP_SUMMARY
160-
echo "" >> $env:GITHUB_STEP_SUMMARY
161-
echo "Release includes:" >> $env:GITHUB_STEP_SUMMARY
162-
echo "- Full version (\`cmder.zip\`, \`cmder.7z\`)" >> $env:GITHUB_STEP_SUMMARY
163-
echo "- Mini version (\`cmder_mini.zip\`)" >> $env:GITHUB_STEP_SUMMARY
164-
echo "- File hashes (\`hashes.txt\`)" >> $env:GITHUB_STEP_SUMMARY
165-
echo "" >> $env:GITHUB_STEP_SUMMARY
166-
echo "> ⚠️ Release is in **draft** mode. Please review and publish manually." >> $env:GITHUB_STEP_SUMMARY
260+
$summary = @"
261+
262+
---
263+
264+
### Release Information
265+
266+
🚀 Draft release created for tag: **``${{ github.ref_name }}``**
267+
268+
Release includes:
269+
- Full version (``cmder.zip``, ``cmder.7z``)
270+
- Mini version (``cmder_mini.zip``)
271+
- File hashes (``hashes.txt``)
272+
273+
> ⚠️ Release is in **draft** mode. Please review and publish manually.
274+
"@
167275
276+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8

.github/workflows/codeql.yml

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,21 @@ jobs:
5050
- name: Summary - CodeQL analysis started
5151
shell: pwsh
5252
run: |
53-
$summary = @(
54-
'## 🔒 CodeQL Security Analysis - Workflow Summary'
55-
''
56-
'### Analysis Configuration'
57-
''
58-
'| Property | Value |'
59-
'| --- | --- |'
60-
'| Repository | `${{ github.repository }}` |'
61-
'| Branch | `${{ github.ref_name }}` |'
62-
'| Language | `${{ matrix.language }}` |'
63-
'| Commit | `${{ github.sha }}` |'
64-
''
65-
)
66-
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY
53+
$summary = @"
54+
## 🔒 CodeQL Security Analysis - Workflow Summary
55+
56+
### Analysis Configuration
57+
58+
| Property | Value |
59+
| --- | --- |
60+
| Repository | ``${{ github.repository }}`` |
61+
| Branch | ``${{ github.ref_name }}`` |
62+
| Language | ``${{ matrix.language }}`` |
63+
| Commit | ``${{ github.sha }}`` |
64+
65+
"@
66+
67+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
6768
6869
# Initializes the CodeQL tools for scanning.
6970
- name: Initialize CodeQL
@@ -89,13 +90,14 @@ jobs:
8990
if: success()
9091
shell: pwsh
9192
run: |
92-
$summary = @(
93-
'### ✅ Build Completed'
94-
''
95-
'Cmder launcher built successfully for CodeQL analysis.'
96-
''
97-
)
98-
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY
93+
$summary = @"
94+
### ✅ Build Completed
95+
96+
Cmder launcher built successfully for CodeQL analysis.
97+
98+
"@
99+
100+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
99101
100102
- name: Perform CodeQL Analysis
101103
uses: github/codeql-action/analyze@v4
@@ -106,13 +108,14 @@ jobs:
106108
if: success()
107109
shell: pwsh
108110
run: |
109-
$summary = @(
110-
'### 🔍 CodeQL Analysis Results'
111-
''
112-
'✅ CodeQL security analysis completed successfully.'
113-
''
114-
'**Language analyzed:** `${{ matrix.language }}`'
115-
''
116-
'> Check the Security tab for detailed findings and recommendations.'
117-
)
118-
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY
111+
$summary = @"
112+
### 🔍 CodeQL Analysis Results
113+
114+
✅ CodeQL security analysis completed successfully.
115+
116+
**Language analyzed:** ``${{ matrix.language }}``
117+
118+
> Check the Security tab for detailed findings and recommendations.
119+
"@
120+
121+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8

0 commit comments

Comments
 (0)