#---------------------------------# # general configuration # #---------------------------------# name: Build Cmder # Controls when the action will run. Triggers the workflow on push or pull request events but only for the main branch on: push: branches: [ "master" ] tags: - "v*" pull_request: branches: [ "master", "development" ] #---------------------------------# # environment configuration # #---------------------------------# env: # Path to the root of the Cmder project. CMDER_ROOT: ${{ github.workspace }} permissions: contents: read # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build: name: Build Project runs-on: windows-latest permissions: contents: write discussions: write steps: - name: Check out repository code (Action from GitHub) uses: actions/checkout@v6 with: fetch-depth: 0 - name: Summary - Repository checkout shell: pwsh run: | # Get Cmder version . scripts/utils.ps1 $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 Build started: $buildTime ### 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 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 - name: Build Cmder Launcher shell: pwsh working-directory: scripts run: .\build.ps1 -Compile -verbose - name: Summary - Build completed if: success() shell: pwsh run: | @" --- ### 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: Upload artifact (cmder.zip) uses: actions/upload-artifact@v5 with: path: build/cmder.zip name: cmder.zip if-no-files-found: error - name: Upload artifact (cmder.7z) uses: actions/upload-artifact@v5 with: path: build/cmder.7z name: cmder.7z - name: Upload artifact (cmder_mini.zip) uses: actions/upload-artifact@v5 with: path: build/cmder_mini.zip name: cmder_mini.zip - name: Upload artifact (hashes.txt) uses: actions/upload-artifact@v5 with: path: build/hashes.txt name: hashes.txt - name: Summary - Artifacts uploaded if: success() shell: pwsh run: | $summary = @" --- ### 🗃️ Artifacts | Artifact | Size | Download | Hash (SHA256) | | --- | --- | --- | --- | "@ $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 $downloadUrl = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # 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]($downloadUrl) | ``$hash`` |" } } $summary += "`n" $summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8 - name: Create Release uses: softprops/action-gh-release@v2 with: files: | build/cmder.zip build/cmder.7z build/cmder_mini.zip build/hashes.txt draft: true generate_release_notes: true if: startsWith(github.ref, 'refs/tags/') - name: Summary - Release created if: startsWith(github.ref, 'refs/tags/') shell: pwsh run: | @" --- ### Release Information 🚀 Draft release created for tag: **``${{ github.ref_name }}``** 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