From a49921bb1baeba134f75bccd7127fe8e442b9ee3 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sat, 15 Oct 2022 15:37:39 +0330 Subject: [PATCH 01/27] add github variable helpers (credit: @microsoft) --- scripts/utils.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 117f274a..ca224798 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -67,6 +67,31 @@ function Digest-Hash($path) { return Invoke-Expression "md5sum $path" } +function Set-GHVariable { + param( + [Parameter(Mandatory = $true)] + [string]$Name, + [Parameter(Mandatory = $true)] + [string]$Value + ) + + Write-Verbose "Setting CI variable $Name to $Value" -Verbose + + if ($env:GITHUB_ENV) { + "$Name=$Value" | Out-File $env:GITHUB_ENV -Append + } +} + +function Get-GHTempPath { + $temp = [System.IO.Path]::GetTempPath() + if ($env:RUNNER_TEMP) { + $temp = $env:RUNNER_TEMP + } + + Write-Verbose "Get CI Temp path: $temp" -Verbose + return $temp +} + function Get-VersionStr() { # Clear existing variable if ($string) { Clear-Variable -name string } From 1c4a8b3ff541917b1ba9056edabd6a9ac0b96c49 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sat, 15 Oct 2022 15:39:57 +0330 Subject: [PATCH 02/27] add vendor dependency check action --- .github/workflows/vendor.yml | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/vendor.yml diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml new file mode 100644 index 00000000..3beb8f51 --- /dev/null +++ b/.github/workflows/vendor.yml @@ -0,0 +1,39 @@ +name: Update Vendor + +on: + schedule: + # At 13:37 UTC every day. + - cron: '37 13 * * *' + +defaults: + run: + shell: pwsh + +permissions: + contents: read + +jobs: + vendor: + + runs-on: windows-latest + continue-on-error: false + timeout-minutes: 15 + permissions: + contents: write + pull-requests: write + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: | + # TODO + + - uses: peter-evans/create-pull-request@v4 + with: + title: 'Actions: Updates to the vendored dependencies' + body: 'Automatic changes' + commit-message: 'Update vendored dependencies' + branch: update-vendor + base: master From 59269aa9f13a47bacaf5996b063f131bc3b7307e Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sat, 15 Oct 2022 15:48:13 +0330 Subject: [PATCH 03/27] allow manual trigger --- .github/workflows/vendor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 3beb8f51..190c2784 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -1,6 +1,7 @@ name: Update Vendor on: + workflow_dispatch: schedule: # At 13:37 UTC every day. - cron: '37 13 * * *' From f58652fc28dab3c0405164ced2e59551b9b50287 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sun, 16 Oct 2022 16:01:15 +0330 Subject: [PATCH 04/27] check requirements only for specified switches --- scripts/build.ps1 | 50 ++++++++++++++++++++++++++++------------------- scripts/pack.ps1 | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 32ebe98a..522dafed 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -60,18 +60,18 @@ $cmder_root = Resolve-Path "$PSScriptRoot\.." . "$PSScriptRoot\utils.ps1" $ErrorActionPreference = "Stop" -Push-Location -Path $saveTo -$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json - -# Get the version string -$version = Get-VersionStr - # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" -Ensure-Executable "msbuild" + +# Get the vendor sources +$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json + +Push-Location -Path $saveTo New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null +$vend = $pwd + # Preserve modified (by user) ConEmu setting file if ($config -ne "") { $ConEmuXml = Join-Path $saveTo "conemu-maximus5\ConEmu.xml" @@ -83,14 +83,13 @@ if ($config -ne "") { } else { $ConEmuXml = "" } # Kill ssh-agent.exe if it is running from the $env:cmder_root we are building -foreach ($ssh_agent in $(get-process ssh-agent -erroraction silentlycontinue)) { - if ([string]$($ssh_agent.path) -match [string]$cmder_root.replace('\','\\')) { +foreach ($ssh_agent in $(Get-Process ssh-agent -ErrorAction SilentlyContinue)) { + if ([string]$($ssh_agent.path) -Match [string]$cmder_root.replace('\','\\')) { Write-Verbose $("Stopping " + $ssh_agent.path + "!") Stop-Process $ssh_agent.id } } -$vend = $pwd foreach ($s in $sources) { Write-Verbose "Getting vendored $($s.name) $($s.version)..." @@ -105,11 +104,12 @@ foreach ($s in $sources) { if ((Get-Childitem $s.name).Count -eq 1) { Flatten-Directory($s.name) } + # Write current version to .cmderver file, for later. "$($s.version)" | Out-File "$($s.name)/.cmderver" } -# Restore user configuration +# Restore ConEmu user configuration if ($ConEmuXml -ne "") { Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'" Copy-Item $ConEmuXmlSave $ConEmuXml @@ -117,13 +117,23 @@ if ($ConEmuXml -ne "") { Pop-Location -if($Compile) { +if ($Compile) { + # Check for requirements + Ensure-Executable "msbuild" + + # Get the version string + $version = Get-VersionStr + Push-Location -Path $launcher - Create-RC $version ($launcher + '\src\version.rc2'); - # https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference + Create-RC $version ($launcher + '\src\version.rc2') + + Write-Verbose "Building the launcher..." + + # Referene: https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference msbuild CmderLauncher.vcxproj /t:Clean,Build /p:configuration=Release /m + if ($LastExitCode -ne 0) { - throw "MSBuild failed to build the executable." + throw "MSBuild failed to build the launcher executable." } else { Write-Verbose "Successfully built Cmder v$version!" @@ -141,16 +151,16 @@ if($Compile) { } # Put vendor\cmder.sh in /etc/profile.d so it runs when we start bash or mintty -if ( (Test-Path $($SaveTo + "git-for-windows/etc/profile.d") ) ) { +if ( (Test-Path $($saveTo + "git-for-windows/etc/profile.d") ) ) { Write-Verbose "Adding cmder.sh /etc/profile.d" - Copy-Item $($SaveTo + "cmder.sh") $($SaveTo + "git-for-windows/etc/profile.d/cmder.sh") + Copy-Item $($saveTo + "cmder.sh") $($saveTo + "git-for-windows/etc/profile.d/cmder.sh") } # Replace /etc/profile.d/git-prompt.sh with cmder lambda prompt so it runs when we start bash or mintty -if ( !(Test-Path $($SaveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") ) ) { +if ( !(Test-Path $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") ) ) { Write-Verbose "Replacing /etc/profile.d/git-prompt.sh with our git-prompt.sh" - Move-Item $($SaveTo + "git-for-windows/etc/profile.d/git-prompt.sh") $($SaveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") - Copy-Item $($SaveTo + "git-prompt.sh") $($SaveTo + "git-for-windows/etc/profile.d/git-prompt.sh") + Move-Item $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") + Copy-Item $($saveTo + "git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") } Write-Host -ForegroundColor green "All good and done!" diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index be10b045..be5df375 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -11,7 +11,7 @@ Creates default archives for cmder .EXAMPLE - .\build -verbose + .\pack.ps1 -verbose Creates default archives for cmder with plenty of information .NOTES From d94fe86b2a67651fddf9742225e99d0f687209aa Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sun, 16 Oct 2022 16:10:51 +0330 Subject: [PATCH 05/27] add -noVendor flag --- scripts/build.ps1 | 147 +++++++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 67 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 522dafed..512f473e 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -16,6 +16,10 @@ .\build.ps1 -Compile Recompile the launcher executable if you have the requisite build tools for C++ installed. +.EXAMPLE + .\build.ps1 -Compile -NoVendor + + Skip all downloads and only build launcher. .EXAMPLE .\build -verbose @@ -49,6 +53,9 @@ Param( # Config folder location [string]$config = "$PSScriptRoot\..\config", + # Using this option will skip all downloads and only build launcher + [switch]$noVendor, + # New launcher if you have MSBuild tools installed [switch]$Compile ) @@ -60,28 +67,6 @@ $cmder_root = Resolve-Path "$PSScriptRoot\.." . "$PSScriptRoot\utils.ps1" $ErrorActionPreference = "Stop" -# Check for requirements -Ensure-Exists $sourcesPath -Ensure-Executable "7z" - -# Get the vendor sources -$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json - -Push-Location -Path $saveTo -New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null - -$vend = $pwd - -# Preserve modified (by user) ConEmu setting file -if ($config -ne "") { - $ConEmuXml = Join-Path $saveTo "conemu-maximus5\ConEmu.xml" - if (Test-Path $ConEmuXml -pathType leaf) { - $ConEmuXmlSave = Join-Path $config "ConEmu.xml" - Write-Verbose "Backup '$ConEmuXml' to '$ConEmuXmlSave'" - Copy-Item $ConEmuXml $ConEmuXmlSave - } else { $ConEmuXml = "" } -} else { $ConEmuXml = "" } - # Kill ssh-agent.exe if it is running from the $env:cmder_root we are building foreach ($ssh_agent in $(Get-Process ssh-agent -ErrorAction SilentlyContinue)) { if ([string]$($ssh_agent.path) -Match [string]$cmder_root.replace('\','\\')) { @@ -90,33 +75,6 @@ foreach ($ssh_agent in $(Get-Process ssh-agent -ErrorAction SilentlyContinue)) { } } -foreach ($s in $sources) { - Write-Verbose "Getting vendored $($s.name) $($s.version)..." - - # We do not care about the extensions/type of archive - $tempArchive = "tmp/$($s.name).tmp" - Delete-Existing $tempArchive - Delete-Existing $s.name - - Download-File -Url $s.url -File $vend\$tempArchive -ErrorAction Stop - Extract-Archive $tempArchive $s.name - - if ((Get-Childitem $s.name).Count -eq 1) { - Flatten-Directory($s.name) - } - - # Write current version to .cmderver file, for later. - "$($s.version)" | Out-File "$($s.name)/.cmderver" -} - -# Restore ConEmu user configuration -if ($ConEmuXml -ne "") { - Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'" - Copy-Item $ConEmuXmlSave $ConEmuXml -} - -Pop-Location - if ($Compile) { # Check for requirements Ensure-Executable "msbuild" @@ -135,32 +93,87 @@ if ($Compile) { if ($LastExitCode -ne 0) { throw "MSBuild failed to build the launcher executable." } - else { - Write-Verbose "Successfully built Cmder v$version!" - if ( $Env:APPVEYOR -eq 'True' ) { - Add-AppveyorMessage -Message "Building Cmder v$version was successful." -Category Information - } - if ( $Env:GITHUB_ACTIONS -eq 'true' ) { - Write-Output "::notice title=Build Complete::Building Cmder v$version was successful." + Pop-Location +} + +if (-Not $noVendor) { + # Check for requirements + Ensure-Exists $sourcesPath + Ensure-Executable "7z" + + # Get the vendor sources + $sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json + + Push-Location -Path $saveTo + New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null + + $vend = $pwd + + # Preserve modified (by user) ConEmu setting file + if ($config -ne "") { + $ConEmuXml = Join-Path $saveTo "conemu-maximus5\ConEmu.xml" + if (Test-Path $ConEmuXml -pathType leaf) { + $ConEmuXmlSave = Join-Path $config "ConEmu.xml" + Write-Verbose "Backup '$ConEmuXml' to '$ConEmuXmlSave'" + Copy-Item $ConEmuXml $ConEmuXmlSave + } else { $ConEmuXml = "" } + } else { $ConEmuXml = "" } + + foreach ($s in $sources) { + Write-Verbose "Getting vendored $($s.name) $($s.version)..." + + # We do not care about the extensions/type of archive + $tempArchive = "tmp/$($s.name).tmp" + Delete-Existing $tempArchive + Delete-Existing $s.name + + Download-File -Url $s.url -File $vend\$tempArchive -ErrorAction Stop + Extract-Archive $tempArchive $s.name + + if ((Get-Childitem $s.name).Count -eq 1) { + Flatten-Directory($s.name) } + + # Write current version to .cmderver file, for later. + "$($s.version)" | Out-File "$($s.name)/.cmderver" + } + + # Restore ConEmu user configuration + if ($ConEmuXml -ne "") { + Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'" + Copy-Item $ConEmuXmlSave $ConEmuXml } + + # Put vendor\cmder.sh in /etc/profile.d so it runs when we start bash or mintty + if ( (Test-Path $($saveTo + "git-for-windows/etc/profile.d") ) ) { + Write-Verbose "Adding cmder.sh /etc/profile.d" + Copy-Item $($saveTo + "cmder.sh") $($saveTo + "git-for-windows/etc/profile.d/cmder.sh") + } + + # Replace /etc/profile.d/git-prompt.sh with cmder lambda prompt so it runs when we start bash or mintty + if ( !(Test-Path $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") ) ) { + Write-Verbose "Replacing /etc/profile.d/git-prompt.sh with our git-prompt.sh" + Move-Item $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") + Copy-Item $($saveTo + "git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") + } + Pop-Location -} else { - Write-Warning "You are not building a launcher, Use -Compile" +} + +if (-Not $Compile -Or $noVendor) { + Write-Warning "You are not building the full project, Use -Compile without -noVendor" Write-Warning "This cannot be a release. Test build only!" + return } -# Put vendor\cmder.sh in /etc/profile.d so it runs when we start bash or mintty -if ( (Test-Path $($saveTo + "git-for-windows/etc/profile.d") ) ) { - Write-Verbose "Adding cmder.sh /etc/profile.d" - Copy-Item $($saveTo + "cmder.sh") $($saveTo + "git-for-windows/etc/profile.d/cmder.sh") +Write-Verbose "Successfully built Cmder v$version!" + +if ( $Env:APPVEYOR -eq 'True' ) { + Add-AppveyorMessage -Message "Building Cmder v$version was successful." -Category Information } -# Replace /etc/profile.d/git-prompt.sh with cmder lambda prompt so it runs when we start bash or mintty -if ( !(Test-Path $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") ) ) { - Write-Verbose "Replacing /etc/profile.d/git-prompt.sh with our git-prompt.sh" - Move-Item $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") - Copy-Item $($saveTo + "git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") +if ( $Env:GITHUB_ACTIONS -eq 'true' ) { + Write-Output "::notice title=Build Complete::Building Cmder v$version was successful." } Write-Host -ForegroundColor green "All good and done!" From 87f7ddf4492710408d938938358edf881b2d66fb Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sun, 16 Oct 2022 16:13:26 +0330 Subject: [PATCH 06/27] formatting and case conventions --- scripts/pack.ps1 | 2 +- scripts/utils.ps1 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index be5df375..6cdd376c 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -52,7 +52,7 @@ Push-Location -Path $cmderRoot Delete-Existing "$cmderRoot\Version*" Delete-Existing "$cmderRoot\build\*" -If(-not (Test-Path -PathType container $saveTo)) { +if (-not (Test-Path -PathType container $saveTo)) { (New-Item -ItemType Directory -Path $saveTo) | Out-Null } diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index ca224798..4cfb4777 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -9,13 +9,13 @@ function Ensure-Exists($path) { function Ensure-Executable($command) { try { Get-Command $command -ErrorAction Stop > $null } catch { - If( ($command -eq "7z") -and (Test-Path "$env:programfiles\7-zip\7z.exe") ){ + if( ($command -eq "7z") -and (Test-Path "$env:programfiles\7-zip\7z.exe") ){ Set-Alias -Name "7z" -Value "$env:programfiles\7-zip\7z.exe" -Scope script } - ElseIf( ($command -eq "7z") -and (Test-Path "$env:programw6432\7-zip\7z.exe") ) { + elseif( ($command -eq "7z") -and (Test-Path "$env:programw6432\7-zip\7z.exe") ) { Set-Alias -Name "7z" -Value "$env:programw6432\7-zip\7z.exe" -Scope script } - Else { + else { Write-Error "Missing $command! Ensure it is installed and on in the PATH" exit 1 } From 7995f349819fe759a1bea4050a624a28b979bce1 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sun, 16 Oct 2022 17:34:57 +0330 Subject: [PATCH 07/27] adjust comments --- scripts/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 512f473e..e317bee9 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -56,7 +56,7 @@ Param( # Using this option will skip all downloads and only build launcher [switch]$noVendor, - # New launcher if you have MSBuild tools installed + # Build launcher if you have MSBuild tools installed [switch]$Compile ) From 71536ddddf910d44e3fe1ca6cf035dafe1ce7670 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 19:52:15 +0330 Subject: [PATCH 08/27] stop ssh agent only if building vendors --- scripts/build.ps1 | 18 +++++++++--------- scripts/utils.ps1 | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index e317bee9..c0048bbf 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -53,7 +53,7 @@ Param( # Config folder location [string]$config = "$PSScriptRoot\..\config", - # Using this option will skip all downloads and only build launcher + # Using this option will skip all downloads, if you only need to build launcher [switch]$noVendor, # Build launcher if you have MSBuild tools installed @@ -67,14 +67,6 @@ $cmder_root = Resolve-Path "$PSScriptRoot\.." . "$PSScriptRoot\utils.ps1" $ErrorActionPreference = "Stop" -# Kill ssh-agent.exe if it is running from the $env:cmder_root we are building -foreach ($ssh_agent in $(Get-Process ssh-agent -ErrorAction SilentlyContinue)) { - if ([string]$($ssh_agent.path) -Match [string]$cmder_root.replace('\','\\')) { - Write-Verbose $("Stopping " + $ssh_agent.path + "!") - Stop-Process $ssh_agent.id - } -} - if ($Compile) { # Check for requirements Ensure-Executable "msbuild" @@ -119,6 +111,14 @@ if (-Not $noVendor) { } else { $ConEmuXml = "" } } else { $ConEmuXml = "" } + # Kill ssh-agent.exe if it is running from the $env:cmder_root we are building + foreach ($ssh_agent in $(Get-Process ssh-agent -ErrorAction SilentlyContinue)) { + if ([string]$($ssh_agent.path) -Match [string]$cmder_root.replace('\','\\')) { + Write-Verbose $("Stopping " + $ssh_agent.path + "!") + Stop-Process $ssh_agent.id + } + } + foreach ($s in $sources) { Write-Verbose "Getting vendored $($s.name) $($s.version)..." diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 4cfb4777..21c86bc4 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -92,7 +92,7 @@ function Get-GHTempPath { return $temp } -function Get-VersionStr() { +function Get-VersionStr { # Clear existing variable if ($string) { Clear-Variable -name string } From 3901fef98b2f599fa705ac0a34e71c8ed12107c2 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 20:08:37 +0330 Subject: [PATCH 09/27] minor letter casing edit --- scripts/build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index c0048bbf..2255a992 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -11,7 +11,7 @@ .EXAMPLE .\build.ps1 - Executes the default build for Cmder; Conemu, clink. This is equivalent to the "minimum" style package in the releases + Executes the default build for Cmder; ConEmu, clink. This is equivalent to the "minimum" style package in the releases .EXAMPLE .\build.ps1 -Compile @@ -94,7 +94,7 @@ if (-Not $noVendor) { Ensure-Executable "7z" # Get the vendor sources - $sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json + $sources = Get-Content $sourcesPath | Out-String | ConvertFrom-Json Push-Location -Path $saveTo New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null From 6b72e8494052b9473c8a48a5db9fab9b200a5e51 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 20:30:12 +0330 Subject: [PATCH 10/27] minor letter casing update --- scripts/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 2255a992..0253c3cb 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -130,7 +130,7 @@ if (-Not $noVendor) { Download-File -Url $s.url -File $vend\$tempArchive -ErrorAction Stop Extract-Archive $tempArchive $s.name - if ((Get-Childitem $s.name).Count -eq 1) { + if ((Get-ChildItem $s.name).Count -eq 1) { Flatten-Directory($s.name) } From e7139bd4742ad26f907deceef712d688a8d55dd4 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:00:30 +0330 Subject: [PATCH 11/27] initial update vendors script --- .github/workflows/vendor.yml | 28 +++- scripts/update.ps1 | 266 +++++++++++++++++++++++++++++++++++ 2 files changed, 287 insertions(+), 7 deletions(-) create mode 100644 scripts/update.ps1 diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 190c2784..de993a87 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -5,11 +5,11 @@ on: schedule: # At 13:37 UTC every day. - cron: '37 13 * * *' - + defaults: run: shell: pwsh - + permissions: contents: read @@ -27,14 +27,28 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - + - run: | - # TODO + $currentVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) + . .\scripts\update.ps1 -verbose + Set-GWVariable -Name COUNT_UPDATED -Value $count + $newVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) + $listUpdated = "" + $updateMessage = "" + for ($s in $newVersion) { + $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version + if ($s.version -ne $oldVersion) { + $listUpdated += "$($s.name), " + $updateMessage += "**$($s.name)** ($oldVersion → **$($s.version)**)
" + } + } + Set-GWVariable -Name $listUpdated -Value $listUpdated.Trim(', ') + Set-GWVariable -Name UPDATE_MESSAGE -Value $updateMessage - uses: peter-evans/create-pull-request@v4 with: - title: 'Actions: Updates to the vendored dependencies' - body: 'Automatic changes' - commit-message: 'Update vendored dependencies' + title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies' + body: '### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies`n${{ env.UPDATE_MESSAGE }}' + commit-message: 'Update vendored dependencies (${{ env.LIST_UPDATED }})' branch: update-vendor base: master diff --git a/scripts/update.ps1 b/scripts/update.ps1 new file mode 100644 index 00000000..b8de658a --- /dev/null +++ b/scripts/update.ps1 @@ -0,0 +1,266 @@ +<# +.Synopsis + Update Cmder vendored dependencies +.DESCRIPTION + This script updates dependencies to the latest version in vendor/sources.json file. + + You will need to make this script executable by setting your Powershell Execution Policy to Remote signed + Then unblock the script for execution with UnblockFile .\build.ps1 +.EXAMPLE + .\build.ps1 + + Updates the dependency sources in the default location, the vendor/sources.json file. +.EXAMPLE + .\build -verbose + + Updates the dependency sources and see what's going on. +.EXAMPLE + .\build.ps1 -SourcesPath '~/custom/vendors.json' + + Specify the path to update dependency sources file at. +.NOTES + AUTHORS + David Refoua + Part of the Cmder project. +.LINK + http://cmder.app/ - Project Home +#> +[CmdletBinding(SupportsShouldProcess=$true)] +Param( + # CmdletBinding will give us; + # -verbose switch to turn on logging and + # -whatif switch to not actually make changes + + # Path to the vendor configuration source file + [string]$sourcesPath = "$PSScriptRoot\..\vendor\sources.json" +) + +# Get the root directory of the cmder project. +$cmder_root = Resolve-Path "$PSScriptRoot\.." + +# Dot source util functions into this scope +. "$PSScriptRoot\utils.ps1" +$ErrorActionPreference = "Stop" + +# Attempts to match the current link with the new link, returning the count of matching characters. +function Match-Filenames { + param ( + $url, + $downloadUrl, + $fromEnd + ) + + $filename = [System.IO.Path]::GetFileName($url) + $filenameDownload = [System.IO.Path]::GetFileName($downloadUrl) + + $position = 0 + + if ([String]::IsNullOrEmpty($filename) -Or [String]::IsNullOrEmpty($filenameDownload)) { + throw "Either one or both filenames are empty!" + } + + if ($fromEnd) { + $arr = $filename -split "" + [array]::Reverse($arr) + $filename = $arr -join '' + $arr = $filenameDownload -split "" + [array]::Reverse($arr) + $filenameDownload = $arr -join '' + } + + while ($filename.Substring($position, 1) -eq $filenameDownload.Substring($position, 1)) { + $position++ + + if ( ($position -ge $filename.Length) -or ($position -ge $filenameDownload.Length) ) { + break + } + } + + return $position +} + +# Uses the GitHub api in order to fetch the current download links for the latest releases of the repo. +function Fetch-DownloadUrl { + param ( + [Parameter(Mandatory = $true)] + $urlStr + ) + + $url = [uri] $urlStr + + if ((-Not $url) -Or ($null -eq $url) -Or ($url -eq '')) { + throw "Failed to parse url: $urlStr" + } + + if (-Not ("http", "https" -Contains $url.Scheme)) { + throw "unknown source scheme: $($url.Scheme)" + } + + if (-Not ($url.Host -ilike "*github.com")) { + throw "unknown source domain: $($url.Host)" + } + + $p = $url.Segments.Split([Environment]::NewLine) + + # Api server for GitHub + $urlHost = "api.github.com" + + # Path for releases end-point + $urlPath = [IO.Path]::Combine('repos', $p[1], $p[2], 'releases').Trim('/') + + $apiUrl = [uri] (New-Object System.UriBuilder -ArgumentList $url.Scheme, $urlHost, -1, $urlPath).Uri + + $info = Invoke-RestMethod -Uri $apiUrl + + $downloadLinks = (New-Object System.Collections.Generic.List[System.Object]) + + $charCount = 0 + + if (-Not ($info -Is [array])) { + throw "The response received from API server is invalid" + } + + :loop foreach ($i in $info) { + if (-Not ($i.assets -Is [array])) { + continue + } + + foreach ($a in $i.assets) { + if ([String]::IsNullOrEmpty($a.browser_download_url)) { + continue + } + + # Skip some download links as we're not interested in them + if ( $a.browser_download_url -ilike "*_symbols*" ) { + continue + } + + $score = Match-Filenames $url $a.browser_download_url + + # Skip links that don't match or are less similar + if ( ($score -eq 0) -or ($score -lt $charCount) ) { + continue + } + + # If we reach the same download link as we have + if ( $score -eq [System.IO.Path]::GetFileName($url).Length ) { + } + + $charCount = $score + $downloadLinks.Add($a.browser_download_url) + } + + # If at least one download link was found, don't continue with older releases + if ( $downloadLinks.Length -gt 0 ) { + break :loop + } + } + + # Special case for archive downloads of repository + if (($null -eq $downloadLinks) -Or (-Not $downloadLinks)) { + if ((($p | % {$_.Trim('/')}) -Contains "archive") -And $info[0].tag_name) { + for ($i = 0; $i -lt $p.Length; $i++) { + if ($p[$i].Trim('/') -eq "archive") { + $p[$i+1] = $info[0].tag_name + ".zip" + $downloadLinks = $url.Scheme + "://" + $url.Host + ($p -Join '') + return $downloadLinks + } + } + } + return '' + } + + $temp = $downloadLinks | Where-Object { (Match-Filenames $url $_) -eq $charCount } + + $downloadLinks = (New-Object System.Collections.Generic.List[System.Object]) + + $charCount = 0 + + foreach ($l in $temp) { + $score = Match-Filenames $url $l true + + if ( ($score -eq 0) -or ($score -lt $charCount) ) { + continue + } + + $charCount = $score + } + + $downloadLinks = $temp | Where-Object { (Match-Filenames $url $_ true) -eq $charCount } + + if (($null -eq $downloadLinks) -Or (-Not $downloadLinks)) { + throw "No suitable download links matched for the url!" + } + + if (-Not($downloadLinks -is [String])) { + throw "Found multiple matches for the same url:`n" + $downloadLinks + } + + return $downloadLinks +} + +$count = 0 + +# Read the current sources content +$sources = Get-Content $sourcesPath | Out-String | ConvertFrom-Json + +foreach ($s in $sources) { + Write-Verbose "Updating sources link for $($s.name)..." + + Write-Verbose "Old Link: $($s.url)" + + $downloadUrl = Fetch-DownloadUrl $s.url + + if (($null -eq $downloadUrl) -Or ($downloadUrl -eq '')) { + Write-Verbose "No new links were found" + continue + } + + Write-Verbose "Link: $downloadUrl" + + $url = [uri] $downloadUrl + + $version = '' + + if ( ($url.Segments[-3] -eq "download/") -And ($url.Segments[-2].StartsWith("v")) ) { + $version = $url.Segments[-2].TrimStart('v').TrimEnd('/') + } + + if ( ($url.Segments[-2] -eq "archive/") ) { + $version = [System.IO.Path]::GetFileNameWithoutExtension($url.Segments[-1].TrimStart('v').TrimEnd('/')) + } + + if ( $version -eq '' ) { + throw "Unable to extract version from url string" + } + + Write-Verbose "Version: $version" + + if ( $s.version -ne $version ) { + if ( ([System.Version] $s.version) -gt ([System.Version] $version) ) { + throw "The current version $($s.version) is already newer than the found version $version!" + } + + $count++ + } + + $s.url = $downloadUrl + $s.version = $version +} + +$sources | ConvertTo-Json | Set-Content $sourcesPath + +if ($count -eq 0) { + Write-Host -ForegroundColor yellow "No new releases were found." + return +} + +if ( $Env:APPVEYOR -eq 'True' ) { + Add-AppveyorMessage -Message "Successfully updated $count dependencies." -Category Information +} + +if ( $Env:GITHUB_ACTIONS -eq 'true' ) { + Write-Output "::notice title=Build Complete::Successfully updated $count dependencies." +} + +Write-Host -ForegroundColor green "Successfully updated $count dependencies." From f468ddfe952562cf47ab3a6c40ac23d72fba3027 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:02:53 +0330 Subject: [PATCH 12/27] fix typo --- .github/workflows/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index de993a87..9b08504b 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -35,7 +35,7 @@ jobs: $newVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) $listUpdated = "" $updateMessage = "" - for ($s in $newVersion) { + foreach ($s in $newVersion) { $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version if ($s.version -ne $oldVersion) { $listUpdated += "$($s.name), " From 1d330e7330580c376fe0c09f660a65778896580a Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:09:06 +0330 Subject: [PATCH 13/27] remove incompatible version string matching --- scripts/update.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/update.ps1 b/scripts/update.ps1 index b8de658a..7c29435e 100644 --- a/scripts/update.ps1 +++ b/scripts/update.ps1 @@ -237,9 +237,9 @@ foreach ($s in $sources) { Write-Verbose "Version: $version" if ( $s.version -ne $version ) { - if ( ([System.Version] $s.version) -gt ([System.Version] $version) ) { - throw "The current version $($s.version) is already newer than the found version $version!" - } + # if ( ([System.Version] $s.version) -gt ([System.Version] $version) ) { + # throw "The current version $($s.version) is already newer than the found version $version!" + # } $count++ } From 1e34c885f3e69b186e0fee3030987624958c0315 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:11:37 +0330 Subject: [PATCH 14/27] fix typos --- .github/workflows/vendor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 9b08504b..254cf37d 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -31,7 +31,7 @@ jobs: - run: | $currentVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) . .\scripts\update.ps1 -verbose - Set-GWVariable -Name COUNT_UPDATED -Value $count + Set-GHVariable -Name COUNT_UPDATED -Value $count $newVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) $listUpdated = "" $updateMessage = "" @@ -42,8 +42,8 @@ jobs: $updateMessage += "**$($s.name)** ($oldVersion → **$($s.version)**)
" } } - Set-GWVariable -Name $listUpdated -Value $listUpdated.Trim(', ') - Set-GWVariable -Name UPDATE_MESSAGE -Value $updateMessage + Set-GHVariable -Name $listUpdated -Value $listUpdated.Trim(', ') + Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage - uses: peter-evans/create-pull-request@v4 with: From e1a0d3850c1dbe2d321579b753a7cab85a5ae83d Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:18:24 +0330 Subject: [PATCH 15/27] improve formatting of text --- .github/workflows/vendor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 254cf37d..8cc87ba5 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -39,7 +39,7 @@ jobs: $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version if ($s.version -ne $oldVersion) { $listUpdated += "$($s.name), " - $updateMessage += "**$($s.name)** ($oldVersion → **$($s.version)**)
" + $updateMessage += "- **$($s.name)** ($oldVersion → **$($s.version)**)\n" } } Set-GHVariable -Name $listUpdated -Value $listUpdated.Trim(', ') @@ -48,7 +48,7 @@ jobs: - uses: peter-evans/create-pull-request@v4 with: title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies' - body: '### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies`n${{ env.UPDATE_MESSAGE }}' + body: '### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies:\n\n${{ env.UPDATE_MESSAGE }}\n\n---\nPlease verify and then **Merge** the pull request to update.' commit-message: 'Update vendored dependencies (${{ env.LIST_UPDATED }})' branch: update-vendor base: master From 3fe76de9b51be552be76f1095447c886d8e1d950 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:19:19 +0330 Subject: [PATCH 16/27] fix github variable --- .github/workflows/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 8cc87ba5..cbce7393 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -42,7 +42,7 @@ jobs: $updateMessage += "- **$($s.name)** ($oldVersion → **$($s.version)**)\n" } } - Set-GHVariable -Name $listUpdated -Value $listUpdated.Trim(', ') + Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage - uses: peter-evans/create-pull-request@v4 From 3f88112d22763c0c5567eb40cc46c4d29c6bcefd Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:20:32 +0330 Subject: [PATCH 17/27] edit notice title --- scripts/update.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update.ps1 b/scripts/update.ps1 index 7c29435e..cbdee8df 100644 --- a/scripts/update.ps1 +++ b/scripts/update.ps1 @@ -260,7 +260,7 @@ if ( $Env:APPVEYOR -eq 'True' ) { } if ( $Env:GITHUB_ACTIONS -eq 'true' ) { - Write-Output "::notice title=Build Complete::Successfully updated $count dependencies." + Write-Output "::notice title=Task Complete::Successfully updated $count dependencies." } Write-Host -ForegroundColor green "Successfully updated $count dependencies." From 129c2971c7ad6dab661832319d528944c88a87bb Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:51:35 +0330 Subject: [PATCH 18/27] use a table for message description --- .github/workflows/vendor.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index cbce7393..928a9645 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -34,21 +34,25 @@ jobs: Set-GHVariable -Name COUNT_UPDATED -Value $count $newVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) $listUpdated = "" - $updateMessage = "" + $updateMessage = "| Name | Old Version | New Version |`n| :--- | ---- | ---- |`n" foreach ($s in $newVersion) { $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version if ($s.version -ne $oldVersion) { $listUpdated += "$($s.name), " - $updateMessage += "- **$($s.name)** ($oldVersion → **$($s.version)**)\n" + $updateMessage += "| **$($s.name)** | $oldVersion | **$($s.version)**|`n" } } Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') - Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage + Set-GHVariable -Name UPDATE_MESSAGE -Value [System.Web.HTTPUtility]::UrlEncode($updateMessage) - uses: peter-evans/create-pull-request@v4 with: title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies' - body: '### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies:\n\n${{ env.UPDATE_MESSAGE }}\n\n---\nPlease verify and then **Merge** the pull request to update.' + body: | + ### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies: + ${{ env.UPDATE_MESSAGE }} + --- + Please verify and then **Merge** the pull request to update. commit-message: 'Update vendored dependencies (${{ env.LIST_UPDATED }})' branch: update-vendor base: master From ae391eb576decf602018345b16d2cda2bcf0253b Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:56:05 +0330 Subject: [PATCH 19/27] use paranthesis to fix bug --- .github/workflows/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 928a9645..bbc9eaf1 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -43,7 +43,7 @@ jobs: } } Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') - Set-GHVariable -Name UPDATE_MESSAGE -Value [System.Web.HTTPUtility]::UrlEncode($updateMessage) + Set-GHVariable -Name UPDATE_MESSAGE -Value ([System.Web.HTTPUtility]::UrlEncode($updateMessage)) - uses: peter-evans/create-pull-request@v4 with: From 0559060cebe3a47432f23cf23c5fb9082ab35855 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 21:58:51 +0330 Subject: [PATCH 20/27] use correct escaping for new line --- .github/workflows/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index bbc9eaf1..08025938 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -43,7 +43,7 @@ jobs: } } Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') - Set-GHVariable -Name UPDATE_MESSAGE -Value ([System.Web.HTTPUtility]::UrlEncode($updateMessage)) + Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage.Replace("`n", "%0a") - uses: peter-evans/create-pull-request@v4 with: From 4264158ff2cd65a486dee184fabb57b78bd6b4b6 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 22:14:00 +0330 Subject: [PATCH 21/27] attempt to fix new lines for PR message --- .github/workflows/vendor.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 08025938..8a51ab0f 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -28,7 +28,8 @@ jobs: with: fetch-depth: 0 - - run: | + - id: make-changes + run: | $currentVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) . .\scripts\update.ps1 -verbose Set-GHVariable -Name COUNT_UPDATED -Value $count @@ -39,18 +40,21 @@ jobs: $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version if ($s.version -ne $oldVersion) { $listUpdated += "$($s.name), " - $updateMessage += "| **$($s.name)** | $oldVersion | **$($s.version)**|`n" + $updateMessage += "| **$($s.name)** | $oldVersion | **$($s.version)** |`n" } } Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') - Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage.Replace("`n", "%0a") + $updateMessage = $updateMessage.Replace("%", "%25") + $updateMessage = $updateMessage.Replace("`r", "%0d") + $updateMessage = $updateMessage.Replace("`n", "%0a") + Write-Host "::set-output name=updateMessage::$updateMessage" - uses: peter-evans/create-pull-request@v4 with: title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies' body: | ### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies: - ${{ env.UPDATE_MESSAGE }} + ${{ steps.make_changes.outputs.updateMessage }} --- Please verify and then **Merge** the pull request to update. commit-message: 'Update vendored dependencies (${{ env.LIST_UPDATED }})' From cc9699c13499730788f00b75428b3ee44258650f Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 22:16:26 +0330 Subject: [PATCH 22/27] resolve issues with variable name --- .github/workflows/vendor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 8a51ab0f..56dfc895 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -39,7 +39,7 @@ jobs: foreach ($s in $newVersion) { $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version if ($s.version -ne $oldVersion) { - $listUpdated += "$($s.name), " + $listUpdated += "$($s.name v$s.version), " $updateMessage += "| **$($s.name)** | $oldVersion | **$($s.version)** |`n" } } @@ -54,7 +54,7 @@ jobs: title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies' body: | ### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies: - ${{ steps.make_changes.outputs.updateMessage }} + ${{ steps.make-changes.outputs.updateMessage }} --- Please verify and then **Merge** the pull request to update. commit-message: 'Update vendored dependencies (${{ env.LIST_UPDATED }})' From 3943ba6cc8bc7bb15319fe469d226b3b0eaac9de Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 22:19:37 +0330 Subject: [PATCH 23/27] fix small bug --- .github/workflows/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 56dfc895..774f1a80 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -39,7 +39,7 @@ jobs: foreach ($s in $newVersion) { $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version if ($s.version -ne $oldVersion) { - $listUpdated += "$($s.name v$s.version), " + $listUpdated += "$($s.name) v$($s.version), " $updateMessage += "| **$($s.name)** | $oldVersion | **$($s.version)** |`n" } } From d767c9b2e97764900da7ac442926f908502e9d08 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 22:25:09 +0330 Subject: [PATCH 24/27] use alternative method to escape newlines --- .github/workflows/vendor.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 774f1a80..c84fcc77 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -44,17 +44,14 @@ jobs: } } Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') - $updateMessage = $updateMessage.Replace("%", "%25") - $updateMessage = $updateMessage.Replace("`r", "%0d") - $updateMessage = $updateMessage.Replace("`n", "%0a") - Write-Host "::set-output name=updateMessage::$updateMessage" + Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage.Replace("%", "%25").Replace("`r", "%0D").Replace("`n", "%0A") - uses: peter-evans/create-pull-request@v4 with: title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies' body: | ### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies: - ${{ steps.make-changes.outputs.updateMessage }} + ${{ env.UPDATE_MESSAGE }} --- Please verify and then **Merge** the pull request to update. commit-message: 'Update vendored dependencies (${{ env.LIST_UPDATED }})' From 9151fb346968be32f747ce07f23d71a1956ef54f Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 23:35:29 +0330 Subject: [PATCH 25/27] new line GitHub env improvements --- .github/workflows/vendor.yml | 2 +- scripts/utils.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index c84fcc77..d8b98320 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -44,7 +44,7 @@ jobs: } } Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') - Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage.Replace("%", "%25").Replace("`r", "%0D").Replace("`n", "%0A") + Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage - uses: peter-evans/create-pull-request@v4 with: diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 21c86bc4..70f6d29f 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -78,7 +78,7 @@ function Set-GHVariable { Write-Verbose "Setting CI variable $Name to $Value" -Verbose if ($env:GITHUB_ENV) { - "$Name=$Value" | Out-File $env:GITHUB_ENV -Append + echo "$Name=$Value" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 } } From 856d22e9f8de8cf6d9a25fbf89de1b062a2d60b6 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 17 Oct 2022 23:43:06 +0330 Subject: [PATCH 26/27] write raw github env var with newlines --- .github/workflows/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index d8b98320..73945514 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -44,7 +44,7 @@ jobs: } } Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') - Set-GHVariable -Name UPDATE_MESSAGE -Value $updateMessage + echo "UPDATE_MESSAGE<< Date: Mon, 17 Oct 2022 23:46:14 +0330 Subject: [PATCH 27/27] fix small ending delimiter --- .github/workflows/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 73945514..5fd08b3e 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -44,7 +44,7 @@ jobs: } } Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') - echo "UPDATE_MESSAGE<<