From 8cb31c06f2cdf0afba8201cc548b4224ccdc43de Mon Sep 17 00:00:00 2001 From: Finesssee <90105158+Finesssee@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:30:59 +0700 Subject: [PATCH] Install GitHub CLI in release-publish job --- .circleci/config.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index c80f80e7c1..2a46a5d282 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,6 +64,28 @@ jobs: steps: - attach_workspace: at: . + - run: + name: Install GitHub CLI + shell: powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass + command: | + $ErrorActionPreference = 'Stop' + $gh = Get-Command gh -ErrorAction SilentlyContinue + if ($gh) { Write-Host "gh already installed at $($gh.Source)"; exit 0 } + $ghDir = Join-Path $env:LOCALAPPDATA 'gh' + New-Item -ItemType Directory -Force -Path $ghDir | Out-Null + $zipPath = Join-Path ([IO.Path]::GetTempPath()) 'gh.zip' + $apiUri = 'https://api.github.com/repos/cli/cli/releases/latest' + $release = Invoke-RestMethod -Uri $apiUri -Headers @{ 'User-Agent' = 'circleci' } + $asset = $release.assets | Where-Object { $_.name -match 'windows_amd64\.zip$' } | Select-Object -First 1 + if (-not $asset) { throw 'Could not find GitHub CLI Windows amd64 zip in latest release' } + Write-Host "Downloading $($asset.name)" + Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $zipPath + Expand-Archive -LiteralPath $zipPath -DestinationPath $ghDir -Force + $ghExe = Get-ChildItem -Path $ghDir -Recurse -Filter 'gh.exe' | Select-Object -First 1 + if (-not $ghExe) { throw "gh.exe not found after extracting $zipPath" } + $env:Path = "$($ghExe.DirectoryName);$env:Path" + [Environment]::SetEnvironmentVariable('Path', $env:Path, 'User') + Write-Host "Installed gh at $($ghExe.FullName)" - run: name: Upload matching assets to a draft GitHub Release shell: powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass