@@ -7,11 +7,11 @@ name: Build Cmder
77# Controls when the action will run. Triggers the workflow on push or pull request events but only for the main branch
88on :
99 push :
10- branches : [ "main" ]
10+ branches : [ "master", " main" ]
1111 tags :
1212 - " v*"
1313 pull_request :
14- branches : [ "main", "dev " ]
14+ branches : [ "master", " main", "development " ]
1515
1616# ---------------------------------#
1717# environment configuration #
@@ -47,50 +47,83 @@ jobs:
4747 $cmderVersion = Get-VersionStr
4848 $buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
4949
50- # Determine branch link (handle PR merge refs)
51- $branchName = "${{ github.ref_name }}"
50+ # Determine branch and PR information
51+ $refName = "${{ github.ref_name }}"
52+ $headRef = "${{ github.head_ref }}"
53+ $eventName = "${{ github.event_name }}"
54+ $prNumber = $null
55+ $actualBranchName = $refName
5256 $branchLink = ""
53- if ($branchName -match '^(\d+)/(merge|head)$') {
54- # This is a PR merge/head ref, link to the PR
57+ $prLink = ""
58+
59+ # Check if this is a PR merge ref (e.g., "3061/merge")
60+ if ($refName -match '^(\d+)/(merge|head)$') {
5561 $prNumber = $Matches[1]
56- $branchLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
57- } elseif ("${{ github.event_name }}" -eq "pull_request") {
58- # This is a pull request event, link to the PR
59- $branchLink = "https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
62+ # Use head_ref for the actual branch name if available
63+ if ($headRef) {
64+ $actualBranchName = $headRef
65+ }
66+ $branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
67+ $prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
68+ } elseif ($eventName -eq "pull_request") {
69+ # This is a pull request event
70+ $prNumber = "${{ github.event.pull_request.number }}"
71+ if ($headRef) {
72+ $actualBranchName = $headRef
73+ }
74+ $branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
75+ $prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
6076 } else {
6177 # Regular branch, link to the branch tree
62- $branchLink = "https://github.com/${{ github.repository }}/tree/${{ github.ref_name }} "
78+ $branchLink = "https://github.com/${{ github.repository }}/tree/$refName "
6379 }
6480
6581 $summary = @"
6682 ## 📦 Build Cmder - Workflow Summary
6783
68- <small>Build started: $buildTime</small>
84+ <small>Build started: `` $buildTime`` </small>
6985
7086 ### Repository Information
7187 | Property | Value |
7288 | --- | --- |
7389 | Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) |
74- | Branch | [``$branchName``]($branchLink) |
90+ | Branch | [``$actualBranchName``]($branchLink) |
91+ $(if ($prNumber) { "| Pull Request | [#$prNumber]($prLink) |" })
7592 | Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
7693 | Actor | [@${{ github.actor }}](https://github.com/${{ github.actor }}) |
7794 | Workflow | ``${{ github.workflow }}`` |
7895 | Cmder Version | **$cmderVersion** |
7996
8097 ---
8198
82- ### 📁 Vendor Packages
99+ ### 🗃️ Vendor Packages ([sources.json](vendor/sources.json))
83100 | Package | Version |
84101 | --- | --- |
85102 "@
86103
87104 # Read vendor sources.json and add to summary
88- $vendorSources = Get-Content "vendor/sources.json" | ConvertFrom-Json
105+ $vendorSources = Get-Content -Raw "vendor/sources.json" | ConvertFrom-Json
89106 if ($vendorSources.Count -eq 0) {
90107 $summary += "`n| _No vendor packages found_ | |"
91108 } else {
92109 foreach ($vendor in $vendorSources) {
93- $summary += "`n| ``$($vendor.name)`` | $($vendor.version) |"
110+ # Create release link based on vendor package
111+ $versionLink = "$($vendor.version)"
112+ if ($vendor.url) {
113+ # Extract owner/repo/tag from the URL and create release link
114+ # Handle both /releases/download/ and /archive/ URLs
115+ if ($vendor.url -match 'github\.com/([^/]+)/([^/]+)/(releases/download|archive)/([^/]+)') {
116+ $owner = $Matches[1]
117+ $repo = $Matches[2]
118+ $pathType = $Matches[3]
119+ $tag = $Matches[4]
120+ if ($pathType -eq 'archive') {
121+ $tag = $tag -replace '\.(?:tar\.gz|tgz|zip)$', ''
122+ }
123+ $versionLink = "[$($vendor.version)](https://github.com/$owner/$repo/releases/tag/$tag)"
124+ }
125+ }
126+ $summary += "`n| ``$($vendor.name)`` | $versionLink |"
94127 }
95128 }
96129
@@ -99,12 +132,12 @@ jobs:
99132 $summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
100133
101134 - name : Add MSBuild to PATH
102- uses : microsoft/setup-msbuild@v2
135+ uses : microsoft/setup-msbuild@v3
103136
104137 - name : Build Cmder Launcher
105138 shell : pwsh
106139 working-directory : scripts
107- run : .\build.ps1 -Compile -verbose -InstallPacman
140+ run : .\build.ps1 -Compile -verbose -terminal -all -installPacman
108141
109142 - name : Summary - Build completed
110143 if : success()
@@ -114,8 +147,6 @@ jobs:
114147
115148 ---
116149
117- ### Build Status
118-
119150 ✅ Cmder built successfully.
120151
121152 "@
@@ -125,89 +156,106 @@ jobs:
125156 - name : Pack the built files
126157 shell : pwsh
127158 working-directory : scripts
128- run : .\pack.ps1 -verbose
159+ run : .\pack.ps1 -verbose -terminal all
160+
161+ - name : Upload artifact (cmder_win_mini.zip)
162+ uses : actions/upload-artifact@v4
163+ with :
164+ path : build/cmder_win_mini.zip
165+ name : cmder_win_mini.zip
166+ if-no-files-found : error
167+
168+ - name : Upload artifact (cmder_win.7z)
169+ uses : actions/upload-artifact@v4
170+ with :
171+ path : build/cmder_win.7z
172+ name : cmder_win.7z
173+ if-no-files-found : error
174+
175+ - name : Upload artifact (cmder_win.zip)
176+ uses : actions/upload-artifact@v4
177+ with :
178+ path : build/cmder_win.zip
179+ name : cmder_win.zip
180+ if-no-files-found : error
181+
182+ - name : Upload artifact (cmder_wt.zip)
183+ uses : actions/upload-artifact@v4
184+ with :
185+ path : build/cmder_wt.zip
186+ name : cmder_wt.zip
187+ if-no-files-found : error
188+
189+ - name : Upload artifact (cmder_wt.7z)
190+ uses : actions/upload-artifact@v4
191+ with :
192+ path : build/cmder_wt.7z
193+ name : cmder_wt.7z
194+
195+ - name : Upload artifact (cmder_wt_mini.zip)
196+ uses : actions/upload-artifact@v4
197+ with :
198+ path : build/cmder_wt_mini.zip
199+ name : cmder_wt_mini.zip
129200
130201 - name : Upload artifact (cmder.zip)
131- uses : actions/upload-artifact@v6
202+ uses : actions/upload-artifact@v7
132203 with :
133204 path : build/cmder.zip
134205 name : cmder.zip
206+ archive : false
135207 if-no-files-found : error
136208
137209 - name : Upload artifact (cmder.7z)
138- uses : actions/upload-artifact@v6
210+ uses : actions/upload-artifact@v7
139211 with :
140212 path : build/cmder.7z
141213 name : cmder.7z
214+ archive : false
142215
143216 - name : Upload artifact (cmder_mini.zip)
144- uses : actions/upload-artifact@v6
217+ uses : actions/upload-artifact@v7
145218 with :
146219 path : build/cmder_mini.zip
147220 name : cmder_mini.zip
221+ archive : false
148222
149223 - name : Upload artifact (hashes.txt)
150- uses : actions/upload-artifact@v6
224+ uses : actions/upload-artifact@v7
151225 with :
152226 path : build/hashes.txt
153227 name : hashes.txt
228+ archive : false
154229
155230 - name : Summary - Artifacts uploaded
156231 if : success()
157232 shell : pwsh
158233 env :
159234 GH_TOKEN : ${{ github.token }}
160235 run : |
236+ # Source utility functions
237+ . scripts/utils.ps1
238+
161239 $summary = @"
162240
163- ---
164-
165241 ### 🗃️ Artifacts
166242
167- | Artifact | Size | Download | Hash (SHA256) |
168- | --- | --- | --- | --- |
243+ | Artifact | Size | Hash (SHA256) |
244+ | --- | --- | --- |
169245 "@
170246
171- # Function to get artifact download URL with retry logic
172- function Get-ArtifactDownloadUrl {
173- param(
174- [string]$ArtifactName,
175- [int]$MaxRetries = 3,
176- [int]$DelaySeconds = 2
177- )
178-
179- for ($i = 0; $i -lt $MaxRetries; $i++) {
180- try {
181- # Use GitHub CLI to get artifact information
182- $artifactsJson = gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" --jq ".artifacts[] | select(.name == `"$ArtifactName`")"
183-
184- if ($artifactsJson) {
185- $artifact = $artifactsJson | ConvertFrom-Json
186- if ($artifact.archive_download_url) {
187- return $artifact.archive_download_url
188- }
189- }
190- } catch {
191- Write-Host "Attempt $($i + 1) failed to get artifact URL for $ArtifactName : $_"
192- }
193-
194- if ($i -lt ($MaxRetries - 1)) {
195- Start-Sleep -Seconds $DelaySeconds
196- }
197- }
198-
199- return $null
200- }
201-
202- $artifacts = @("cmder.zip", "cmder.7z", "cmder_mini.zip", "hashes.txt")
203- foreach ($artifact in $artifacts) {
204- $path = "build/$artifact"
205- if (Test-Path $path) {
206- $size = (Get-Item $path).Length / 1MB
247+ # Get all files from the build directory (excluding directories and hidden files)
248+ if (Test-Path "build") {
249+ $buildFiles = Get-ChildItem -Path "build" -File | Where-Object { -not $_.Name.StartsWith('.') } | Sort-Object Name
250+
251+ foreach ($file in $buildFiles) {
252+ $artifact = $file.Name
253+ $path = $file.FullName
254+ $sizeFormatted = Format-FileSize -Bytes $file.Length
207255 $hash = (Get-FileHash $path -Algorithm SHA256).Hash
208256
209257 # Try to get the actual artifact download URL
210- $downloadUrl = Get-ArtifactDownloadUrl -ArtifactName $artifact
258+ $downloadUrl = Get-ArtifactDownloadUrl -ArtifactName $artifact -Repository "${{ github.repository }}" -RunId "${{ github.run_id }}"
211259 $warning = ""
212260
213261 if (-not $downloadUrl) {
@@ -219,21 +267,21 @@ jobs:
219267 # Determine emoji based on file type
220268 if ($artifact -match '\.txt$') {
221269 $emoji = "📄"
222- } elseif ($artifact -match '\.(zip|7z)$') {
270+ } elseif ($artifact -match '\.(zip|rar| 7z)$') {
223271 $emoji = "🗄️"
224272 } else {
225273 $emoji = "📦"
226274 }
227275
228- $summary += "`n| $emoji ``$artifact`` | $([math]::Round($size, 2)) MB | [📥 Download$warning]($downloadUrl) | ``$hash`` |"
276+ $summary += "`n| $emoji [ ``$artifact``$warning]($downloadUrl) | $sizeFormatted | ``$hash`` |"
229277 }
230278 }
231279 $summary += "`n"
232280
233281 $summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
234282
235283 - name : Create Release
236- uses : softprops/action-gh-release@v2
284+ uses : softprops/action-gh-release@v3
237285 with :
238286 files : |
239287 build/cmder.zip
0 commit comments