Skip to content

Commit 6944cf5

Browse files
committed
update workflows from pr
1 parent 330f354 commit 6944cf5

6 files changed

Lines changed: 311 additions & 178 deletions

File tree

.github/dependabot.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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:
3-
# Enable version updates for GitHub Actions
4-
- package-ecosystem: "github-actions"
8+
- package-ecosystem: "github-actions" # See documentation for possible values
59
directory: "/" # Location of package manifests
610
schedule:
711
interval: "weekly"
8-
labels:
9-
- "👆 Dependencies"
10-
- "🔄️ GitHub Actions"

.github/workflows/branches.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1313
jobs:
14-
# This job updates the development branch with the main branch
14+
# This job updates the development branch with the master branch
1515
update-development:
1616
# The type of runner that the job will run on
1717
runs-on: ubuntu-latest
@@ -32,19 +32,19 @@ jobs:
3232
echo "" >> $GITHUB_STEP_SUMMARY
3333
echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY
3434
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
35-
echo "| Source Branch | \`main\` |" >> $GITHUB_STEP_SUMMARY
35+
echo "| Source Branch | \`master\` |" >> $GITHUB_STEP_SUMMARY
3636
echo "| Target Branch | \`development\` |" >> $GITHUB_STEP_SUMMARY
3737
echo "| Triggered by | @${{ github.actor }} |" >> $GITHUB_STEP_SUMMARY
3838
echo "| Commit | \`${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY
3939
echo "" >> $GITHUB_STEP_SUMMARY
4040
4141
# Runs a single command using the runners shell
42-
- name: Merge main into development
42+
- name: Merge master into development
4343
run: |
4444
git config user.name "${{ github.actor }}"
4545
git config user.email "${{ github.actor }}@users.noreply.github.com"
4646
git checkout development
47-
git merge --no-ff main
47+
git merge --no-ff master
4848
git push origin development
4949
5050
- name: Summary - Merge completed
@@ -53,8 +53,8 @@ jobs:
5353
run: |
5454
echo "### ✅ Merge Successful" >> $GITHUB_STEP_SUMMARY
5555
echo "" >> $GITHUB_STEP_SUMMARY
56-
echo "The \`main\` branch has been successfully merged into \`development\`." >> $GITHUB_STEP_SUMMARY
56+
echo "The \`master\` branch has been successfully merged into \`development\`." >> $GITHUB_STEP_SUMMARY
5757
echo "" >> $GITHUB_STEP_SUMMARY
5858
echo "**Merge type:** No fast-forward merge" >> $GITHUB_STEP_SUMMARY
5959
echo "" >> $GITHUB_STEP_SUMMARY
60-
echo "> The development branch is now synchronized with the latest changes from main." >> $GITHUB_STEP_SUMMARY
60+
echo "> The development branch is now synchronized with the latest changes from master." >> $GITHUB_STEP_SUMMARY

.github/workflows/build.yml

Lines changed: 169 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -42,132 +42,200 @@ jobs:
4242
- name: Summary - Repository checkout
4343
shell: pwsh
4444
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
45+
# Get Cmder version
46+
. scripts/utils.ps1
47+
$cmderVersion = Get-VersionStr
48+
$buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
49+
50+
# Determine branch link (handle PR merge refs)
51+
$branchName = "${{ github.ref_name }}"
52+
$branchLink = ""
53+
if ($branchName -match '^(\d+)/(merge|head)$') {
54+
# This is a PR merge/head ref, link to the PR
55+
$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 }}"
60+
} else {
61+
# Regular branch, link to the branch tree
62+
$branchLink = "https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}"
63+
}
64+
65+
$summary = @"
66+
## 📦 Build Cmder - Workflow Summary
67+
68+
<small>Build started: $buildTime</small>
69+
70+
### Repository Information
71+
| Property | Value |
72+
| --- | --- |
73+
| Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) |
74+
| Branch | [``$branchName``]($branchLink) |
75+
| Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
76+
| Actor | [@${{ github.actor }}](https://github.com/${{ github.actor }}) |
77+
| Workflow | ``${{ github.workflow }}`` |
78+
| Cmder Version | **$cmderVersion** |
79+
80+
---
81+
82+
### 📁 Vendor Packages
83+
| Package | Version |
84+
| --- | --- |
85+
"@
86+
87+
# Read vendor sources.json and add to summary
88+
$vendorSources = Get-Content "vendor/sources.json" | ConvertFrom-Json
89+
if ($vendorSources.Count -eq 0) {
90+
$summary += "`n| _No vendor packages found_ | |"
91+
} else {
92+
foreach ($vendor in $vendorSources) {
93+
$summary += "`n| ``$($vendor.name)`` | $($vendor.version) |"
94+
}
95+
}
96+
$summary += "`n"
97+
98+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
5699
57100
- name: Add MSBuild to PATH
58101
uses: microsoft/setup-msbuild@v2
59102

60103
- name: Build Cmder Launcher
61104
shell: pwsh
62105
working-directory: scripts
63-
run: .\build.ps1 -Compile -verbose -terminal windows-terminal -InstallPacman
106+
run: .\build.ps1 -Compile -verbose
64107

65108
- name: Summary - Build completed
66109
if: success()
67110
shell: pwsh
68111
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
112+
@"
113+
114+
---
115+
116+
### Build Status
117+
118+
✅ Cmder built successfully.
119+
120+
"@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
73121
74122
- name: Pack the built files
75123
shell: pwsh
76124
working-directory: scripts
77-
run: .\pack.ps1 -verbose -terminal windows-terminal
125+
run: .\pack.ps1 -verbose
78126

79-
- name: Upload artifact (cmder_win_mini.zip)
80-
uses: actions/upload-artifact@v6
127+
- name: Upload artifact (cmder.zip)
128+
uses: actions/upload-artifact@v5
81129
with:
82-
path: build/cmder_win_mini.zip
83-
name: cmder_win_mini.zip
130+
path: build/cmder.zip
131+
name: cmder.zip
84132
if-no-files-found: error
85133

86-
- name: Upload artifact (cmder_win.7z)
87-
uses: actions/upload-artifact@v6
134+
- name: Upload artifact (cmder.7z)
135+
uses: actions/upload-artifact@v5
88136
with:
89-
path: build/cmder_win.7z
90-
name: cmder_win.7z
91-
if-no-files-found: error
137+
path: build/cmder.7z
138+
name: cmder.7z
92139

93-
- name: Upload artifact (cmder_win.zip)
94-
uses: actions/upload-artifact@v6
140+
- name: Upload artifact (cmder_mini.zip)
141+
uses: actions/upload-artifact@v5
95142
with:
96-
path: build/cmder_win.zip
97-
name: cmder_win.zip
98-
if-no-files-found: error
143+
path: build/cmder_mini.zip
144+
name: cmder_mini.zip
99145

100-
- name: Upload artifact (cmder_wt.zip)
101-
uses: actions/upload-artifact@v6
102-
with:
103-
path: build/cmder_wt.zip
104-
name: cmder_wt.zip
105-
if-no-files-found: error
106-
107-
- name: Upload artifact (cmder_wt.7z)
108-
uses: actions/upload-artifact@v6
109-
with:
110-
path: build/cmder_wt.7z
111-
name: cmder_wt.7z
112-
113-
- name: Upload artifact (cmder_wt_mini.zip)
114-
uses: actions/upload-artifact@v6
146+
- name: Upload artifact (hashes.txt)
147+
uses: actions/upload-artifact@v5
115148
with:
116-
path: build/cmder_wt_mini.zip
117-
name: cmder_wt_mini.zip
149+
path: build/hashes.txt
150+
name: hashes.txt
118151

119-
- name: Summary - Package artifacts
152+
- name: Summary - Artifacts uploaded
120153
if: success()
121154
shell: pwsh
155+
env:
156+
GH_TOKEN: ${{ github.token }}
122157
run: |
123-
echo "### 📦 Artifacts Created" >> $env:GITHUB_STEP_SUMMARY
124-
echo "" >> $env:GITHUB_STEP_SUMMARY
125-
echo "| Artifact | Size | Hash (SHA256) |" >> $env:GITHUB_STEP_SUMMARY
126-
echo "| --- | --- | --- |" >> $env:GITHUB_STEP_SUMMARY
127-
$artifacts = @("cmder_win.zip", "cmder_win.7z", "cmder_win_mini.zip", "cmder_wt.zip", "cmder_wt.7z", "cmder_wt_mini.zip")
158+
$summary = @"
159+
160+
---
161+
162+
### 🗃️ Artifacts
163+
164+
| Artifact | Size | Download | Hash (SHA256) |
165+
| --- | --- | --- | --- |
166+
"@
167+
168+
# Function to get artifact download URL with retry logic
169+
function Get-ArtifactDownloadUrl {
170+
param(
171+
[string]$ArtifactName,
172+
[int]$MaxRetries = 3,
173+
[int]$DelaySeconds = 2
174+
)
175+
176+
for ($i = 0; $i -lt $MaxRetries; $i++) {
177+
try {
178+
# Use GitHub CLI to get artifact information
179+
$artifactsJson = gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" --jq ".artifacts[] | select(.name == `"$ArtifactName`")"
180+
181+
if ($artifactsJson) {
182+
$artifact = $artifactsJson | ConvertFrom-Json
183+
if ($artifact.archive_download_url) {
184+
return $artifact.archive_download_url
185+
}
186+
}
187+
} catch {
188+
Write-Host "Attempt $($i + 1) failed to get artifact URL for $ArtifactName : $_"
189+
}
190+
191+
if ($i -lt ($MaxRetries - 1)) {
192+
Start-Sleep -Seconds $DelaySeconds
193+
}
194+
}
195+
196+
return $null
197+
}
198+
199+
$artifacts = @("cmder.zip", "cmder.7z", "cmder_mini.zip", "hashes.txt")
128200
foreach ($artifact in $artifacts) {
129201
$path = "build/$artifact"
130202
if (Test-Path $path) {
131203
$size = (Get-Item $path).Length / 1MB
132-
# Truncate hash to first 16 chars for summary readability (full hash in hashes.txt)
133-
$hash = (Get-FileHash $path -Algorithm SHA256).Hash.Substring(0, 16)
134-
echo "| \`$artifact\` | $([math]::Round($size, 2)) MB | \`$hash...\` |" >> $env:GITHUB_STEP_SUMMARY
204+
$hash = (Get-FileHash $path -Algorithm SHA256).Hash
205+
206+
# Try to get the actual artifact download URL
207+
$downloadUrl = Get-ArtifactDownloadUrl -ArtifactName $artifact
208+
$warning = ""
209+
210+
if (-not $downloadUrl) {
211+
# Fallback to workflow run page if artifact URL fetch fails
212+
$downloadUrl = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
213+
$warning = " ⚠️"
214+
}
215+
216+
# Determine emoji based on file type
217+
if ($artifact -match '\.txt$') {
218+
$emoji = "📄"
219+
} elseif ($artifact -match '\.(zip|7z)$') {
220+
$emoji = "🗄️"
221+
} else {
222+
$emoji = "📦"
223+
}
224+
225+
$summary += "`n| $emoji ``$artifact`` | $([math]::Round($size, 2)) MB | [📥 Download$warning]($downloadUrl) | ``$hash`` |"
135226
}
136227
}
137-
echo "" >> $env:GITHUB_STEP_SUMMARY
138-
139-
- name: Upload artifact (hashes.txt)
140-
uses: actions/upload-artifact@v6
141-
with:
142-
path: build/hashes.txt
143-
name: hashes.txt
144-
145-
- name: Summary - Artifacts uploaded
146-
if: success()
147-
shell: pwsh
148-
run: |
149-
echo "### ☁️ Upload Status" >> $env:GITHUB_STEP_SUMMARY
150-
echo "" >> $env:GITHUB_STEP_SUMMARY
151-
echo "All artifacts successfully uploaded to GitHub Actions:" >> $env:GITHUB_STEP_SUMMARY
152-
echo '- ✅ `cmder_win.zip`' >> $env:GITHUB_STEP_SUMMARY
153-
echo '- ✅ `cmder_win.7z`' >> $env:GITHUB_STEP_SUMMARY
154-
echo '- ✅ `cmder_win_mini.zip`' >> $env:GITHUB_STEP_SUMMARY
155-
echo '- ✅ `cmder_wt.zip`' >> $env:GITHUB_STEP_SUMMARY
156-
echo '- ✅ `cmder_wt.7z`' >> $env:GITHUB_STEP_SUMMARY
157-
echo '- ✅ `cmder_wt_mini.zip`' >> $env:GITHUB_STEP_SUMMARY
158-
echo '- ✅ `hashes.txt`' >> $env:GITHUB_STEP_SUMMARY
159-
echo "" >> $env:GITHUB_STEP_SUMMARY
228+
$summary += "`n"
229+
230+
$summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
160231
161232
- name: Create Release
162233
uses: softprops/action-gh-release@v2
163234
with:
164235
files: |
165-
build/cmder_win.zip
166-
build/cmder_win.7z
167-
build/cmder_win_mini.zip
168-
build/cmder_wt.zip
169-
build/cmder_wt.7z
170-
build/cmder_wt_mini.zip
236+
build/cmder.zip
237+
build/cmder.7z
238+
build/cmder_mini.zip
171239
build/hashes.txt
172240
draft: true
173241
generate_release_notes: true
@@ -177,13 +245,18 @@ jobs:
177245
if: startsWith(github.ref, 'refs/tags/')
178246
shell: pwsh
179247
run: |
180-
echo "### 🚀 Release Information" >> $env:GITHUB_STEP_SUMMARY
181-
echo "" >> $env:GITHUB_STEP_SUMMARY
182-
echo "Draft release created for tag: **\`${{ github.ref_name }}\`**" >> $env:GITHUB_STEP_SUMMARY
183-
echo "" >> $env:GITHUB_STEP_SUMMARY
184-
echo "Release includes:" >> $env:GITHUB_STEP_SUMMARY
185-
echo "- Full version (\`cmder.zip\`, \`cmder.7z\`)" >> $env:GITHUB_STEP_SUMMARY
186-
echo "- Mini version (\`cmder_mini.zip\`)" >> $env:GITHUB_STEP_SUMMARY
187-
echo "- File hashes (\`hashes.txt\`)" >> $env:GITHUB_STEP_SUMMARY
188-
echo "" >> $env:GITHUB_STEP_SUMMARY
189-
echo "> ⚠️ Release is in **draft** mode. Please review and publish manually." >> $env:GITHUB_STEP_SUMMARY
248+
@"
249+
250+
---
251+
252+
### Release Information
253+
254+
🚀 Draft release created for tag: **``${{ github.ref_name }}``**
255+
256+
Release includes:
257+
- Full version (``cmder.zip``, ``cmder.7z``)
258+
- Mini version (``cmder_mini.zip``)
259+
- File hashes (``hashes.txt``)
260+
261+
> ⚠️ Release is in **draft** mode. Please review and publish manually.
262+
"@ | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8

0 commit comments

Comments
 (0)