Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 153 additions & 53 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,60 @@ jobs:
- name: Summary - Repository checkout
shell: pwsh
run: |
echo "## πŸ“¦ Build Cmder - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "### Repository Information" >> $env:GITHUB_STEP_SUMMARY
echo "| Property | Value |" >> $env:GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $env:GITHUB_STEP_SUMMARY
echo "| Repository | \`${{ github.repository }}\` |" >> $env:GITHUB_STEP_SUMMARY
echo "| Branch | \`${{ github.ref_name }}\` |" >> $env:GITHUB_STEP_SUMMARY
echo "| Commit | \`${{ github.sha }}\` |" >> $env:GITHUB_STEP_SUMMARY
echo "| Actor | @${{ github.actor }} |" >> $env:GITHUB_STEP_SUMMARY
echo "| Workflow | \`${{ github.workflow }}\` |" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
# Get Cmder version
. scripts/utils.ps1
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script sources utils.ps1 without error handling. If the script file doesn't exist or has syntax errors, this will cause the step to fail. Consider adding error handling to verify the script exists and can be loaded successfully.

Suggested change
. scripts/utils.ps1
if (-not (Test-Path "scripts/utils.ps1")) {
Write-Error "scripts/utils.ps1 not found. Exiting."
exit 1
}
try {
. scripts/utils.ps1
} catch {
Write-Error "Failed to source scripts/utils.ps1: $_"
exit 1
}

Copilot uses AI. Check for mistakes.
$cmderVersion = Get-VersionStr
$buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")

# Determine branch link (handle PR merge refs)
$branchName = "${{ github.ref_name }}"
$branchLink = ""
if ($branchName -match '^(\d+)/(merge|head)$') {
# This is a PR merge/head ref, link to the PR
$prNumber = $Matches[1]
$branchLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
} elseif ("${{ github.event_name }}" -eq "pull_request") {
# This is a pull request event, link to the PR
$branchLink = "https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
} else {
# Regular branch, link to the branch tree
$branchLink = "https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}"
}

$summary = @"
## πŸ“¦ Build Cmder - Workflow Summary

<small>Build started: $buildTime</small>
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the <small> HTML tag in GitHub markdown may not render consistently across all viewers (like mobile apps or email notifications). Consider using markdown italic formatting with asterisks instead: *Build started: $buildTime* for better compatibility.

Suggested change
<small>Build started: $buildTime</small>
*Build started: $buildTime*

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Also wrap $buildTime in code tag (`)


### Repository Information
| Property | Value |
| --- | --- |
| Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) |
| Branch | [``$branchName``]($branchLink) |
| Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
| Actor | [@${{ github.actor }}](https://github.com/${{ github.actor }}) |
| Workflow | ``${{ github.workflow }}`` |
| Cmder Version | **$cmderVersion** |

---

### πŸ“ Vendor Packages
| Package | Version |
| --- | --- |
"@

# Read vendor sources.json and add to summary
$vendorSources = Get-Content "vendor/sources.json" | ConvertFrom-Json
if ($vendorSources.Count -eq 0) {
$summary += "`n| _No vendor packages found_ | |"
} else {
foreach ($vendor in $vendorSources) {
$summary += "`n| ``$($vendor.name)`` | $($vendor.version) |"
}
}
$summary += "`n"

$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
Expand All @@ -66,36 +109,21 @@ jobs:
if: success()
shell: pwsh
run: |
echo "### βœ… Build Status" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "Cmder launcher successfully compiled." >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
@"

---

### Build Status

βœ… Cmder built successfully.

"@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8

- name: Pack the built files
shell: pwsh
working-directory: scripts
run: .\pack.ps1 -verbose

- name: Summary - Package artifacts
if: success()
shell: pwsh
run: |
echo "### πŸ“¦ Artifacts Created" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "| Artifact | Size | Hash (SHA256) |" >> $env:GITHUB_STEP_SUMMARY
echo "| --- | --- | --- |" >> $env:GITHUB_STEP_SUMMARY
$artifacts = @("cmder.zip", "cmder.7z", "cmder_mini.zip")
foreach ($artifact in $artifacts) {
$path = "build/$artifact"
if (Test-Path $path) {
$size = (Get-Item $path).Length / 1MB
# Truncate hash to first 16 chars for summary readability (full hash in hashes.txt)
$hash = (Get-FileHash $path -Algorithm SHA256).Hash.Substring(0, 16)
echo "| \`$artifact\` | $([math]::Round($size, 2)) MB | \`$hash...\` |" >> $env:GITHUB_STEP_SUMMARY
}
}
echo "" >> $env:GITHUB_STEP_SUMMARY

- name: Upload artifact (cmder.zip)
uses: actions/upload-artifact@v5
with:
Expand Down Expand Up @@ -124,15 +152,82 @@ jobs:
- name: Summary - Artifacts uploaded
if: success()
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "### ☁️ Upload Status" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "All artifacts successfully uploaded to GitHub Actions:" >> $env:GITHUB_STEP_SUMMARY
echo "- βœ… \`cmder.zip\`" >> $env:GITHUB_STEP_SUMMARY
echo "- βœ… \`cmder.7z\`" >> $env:GITHUB_STEP_SUMMARY
echo "- βœ… \`cmder_mini.zip\`" >> $env:GITHUB_STEP_SUMMARY
echo "- βœ… \`hashes.txt\`" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
$summary = @"

---

### πŸ—ƒοΈ Artifacts

| Artifact | Size | Download | Hash (SHA256) |
| --- | --- | --- | --- |
"@

# Function to get artifact download URL with retry logic
function Get-ArtifactDownloadUrl {
param(
[string]$ArtifactName,
[int]$MaxRetries = 3,
[int]$DelaySeconds = 2
)

for ($i = 0; $i -lt $MaxRetries; $i++) {
try {
# Use GitHub CLI to get artifact information
$artifactsJson = gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" --jq ".artifacts[] | select(.name == `"$ArtifactName`")"

if ($artifactsJson) {
$artifact = $artifactsJson | ConvertFrom-Json
if ($artifact.archive_download_url) {
return $artifact.archive_download_url
}
}
} catch {
Write-Host "Attempt $($i + 1) failed to get artifact URL for $ArtifactName : $_"
}

if ($i -lt ($MaxRetries - 1)) {
Start-Sleep -Seconds $DelaySeconds
}
}

return $null
}

$artifacts = @("cmder.zip", "cmder.7z", "cmder_mini.zip", "hashes.txt")
foreach ($artifact in $artifacts) {
$path = "build/$artifact"
if (Test-Path $path) {
$size = (Get-Item $path).Length / 1MB
$hash = (Get-FileHash $path -Algorithm SHA256).Hash
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file hash calculation doesn't include error handling. If a file doesn't exist (the Test-Path check passed) but becomes unavailable before Get-FileHash is called, this will cause an error. Consider adding error handling around Get-FileHash or combining the Test-Path check with the hash calculation in a try-catch block.

Suggested change
$hash = (Get-FileHash $path -Algorithm SHA256).Hash
try {
$hash = (Get-FileHash $path -Algorithm SHA256).Hash
} catch {
$hash = "N/A"
}

Copilot uses AI. Check for mistakes.

# Try to get the actual artifact download URL
$downloadUrl = Get-ArtifactDownloadUrl -ArtifactName $artifact
$warning = ""

if (-not $downloadUrl) {
# Fallback to workflow run page if artifact URL fetch fails
$downloadUrl = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
$warning = " ⚠️"
}

# Determine emoji based on file type
if ($artifact -match '\.txt$') {
$emoji = "πŸ“„"
} elseif ($artifact -match '\.(zip|7z)$') {
$emoji = "πŸ—„οΈ"
} else {
$emoji = "πŸ“¦"
}

$summary += "`n| $emoji ``$artifact`` | $([math]::Round($size, 2)) MB | [πŸ“₯ Download$warning]($downloadUrl) | ``$hash`` |"
}
}
$summary += "`n"

$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8

- name: Create Release
uses: softprops/action-gh-release@v2
Expand All @@ -150,13 +245,18 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
shell: pwsh
run: |
echo "### πŸš€ Release Information" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "Draft release created for tag: **\`${{ github.ref_name }}\`**" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "Release includes:" >> $env:GITHUB_STEP_SUMMARY
echo "- Full version (\`cmder.zip\`, \`cmder.7z\`)" >> $env:GITHUB_STEP_SUMMARY
echo "- Mini version (\`cmder_mini.zip\`)" >> $env:GITHUB_STEP_SUMMARY
echo "- File hashes (\`hashes.txt\`)" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "> ⚠️ Release is in **draft** mode. Please review and publish manually." >> $env:GITHUB_STEP_SUMMARY
@"

---

### Release Information

πŸš€ Draft release created for tag: **``${{ github.ref_name }}``**
Comment on lines +252 to +254
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heading "Release Information" is missing an emoji prefix, while the content below uses the πŸš€ emoji. For consistency with other section headings, consider moving the emoji to the heading itself (e.g., "### πŸš€ Release Information") rather than having it in the body text.

Suggested change
### Release Information
πŸš€ Draft release created for tag: **``${{ github.ref_name }}``**
### πŸš€ Release Information
Draft release created for tag: **``${{ github.ref_name }}``**

Copilot uses AI. Check for mistakes.

Release includes:
- Full version (``cmder.zip``, ``cmder.7z``)
- Mini version (``cmder_mini.zip``)
- File hashes (``hashes.txt``)

> ⚠️ Release is in **draft** mode. Please review and publish manually.
"@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
50 changes: 28 additions & 22 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@ jobs:
- name: Summary - CodeQL analysis started
shell: pwsh
run: |
echo "## πŸ”’ CodeQL Security Analysis - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "### Analysis Configuration" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "| Property | Value |" >> $env:GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $env:GITHUB_STEP_SUMMARY
echo "| Repository | \`${{ github.repository }}\` |" >> $env:GITHUB_STEP_SUMMARY
echo "| Branch | \`${{ github.ref_name }}\` |" >> $env:GITHUB_STEP_SUMMARY
echo "| Language | \`${{ matrix.language }}\` |" >> $env:GITHUB_STEP_SUMMARY
echo "| Commit | \`${{ github.sha }}\` |" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
@"
## πŸ”’ CodeQL Security Analysis - Workflow Summary

### Analysis Configuration

| Property | Value |
| --- | --- |
| Repository | ``${{ github.repository }}`` |
| Branch | ``${{ github.ref_name }}`` |
| Language | ``${{ matrix.language }}`` |
| Commit | ``${{ github.sha }}`` |

"@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand All @@ -86,10 +88,12 @@ jobs:
if: success()
shell: pwsh
run: |
echo "### βœ… Build Completed" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "Cmder launcher built successfully for CodeQL analysis." >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
@"
### βœ… Build Completed

Cmder launcher built successfully for CodeQL analysis.

"@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
Expand All @@ -100,10 +104,12 @@ jobs:
if: success()
shell: pwsh
run: |
echo "### πŸ” CodeQL Analysis Results" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "βœ… CodeQL security analysis completed successfully." >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "**Language analyzed:** \`${{ matrix.language }}\`" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "> Check the Security tab for detailed findings and recommendations." >> $env:GITHUB_STEP_SUMMARY
@"
### πŸ” CodeQL Analysis Results

βœ… CodeQL security analysis completed successfully.

**Language analyzed:** ``${{ matrix.language }}``

> Check the Security tab for detailed findings and recommendations.
"@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
Loading