ci: avoid cross-step env in Windows workflow
Some checks failed
Build Windows Release / Build Windows x64 Release (push) Failing after 25s
Some checks failed
Build Windows Release / Build Windows x64 Release (push) Failing after 25s
This commit is contained in:
@@ -110,9 +110,6 @@ jobs:
|
|||||||
$zipPath = Join-Path $sourceDir $zipName
|
$zipPath = Join-Path $sourceDir $zipName
|
||||||
$hash = (Get-FileHash $zipPath -Algorithm SHA256).Hash.ToLowerInvariant()
|
$hash = (Get-FileHash $zipPath -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||||
"$hash $zipName" | Out-File -FilePath "$zipPath.sha256" -Encoding ascii
|
"$hash $zipName" | Out-File -FilePath "$zipPath.sha256" -Encoding ascii
|
||||||
"PACKAGE_ZIP=$zipPath" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
|
||||||
"PACKAGE_SHA256=$zipPath.sha256" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
|
||||||
"RELEASE_TAG=$version" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
|
||||||
Write-Host "Package: $zipPath"
|
Write-Host "Package: $zipPath"
|
||||||
Write-Host "SHA256: $hash"
|
Write-Host "SHA256: $hash"
|
||||||
|
|
||||||
@@ -120,9 +117,16 @@ jobs:
|
|||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
if (-not (Test-Path $env:PACKAGE_ZIP)) { throw "zip does not exist: $env:PACKAGE_ZIP" }
|
$shortSha = $env:GITHUB_SHA.Substring(0, 10)
|
||||||
if (-not (Test-Path $env:PACKAGE_SHA256)) { throw "sha256 does not exist: $env:PACKAGE_SHA256" }
|
$version = if ($env:GITHUB_REF_TYPE -eq 'tag') { $env:GITHUB_REF_NAME } else { "build-$shortSha" }
|
||||||
if ((Get-Item $env:PACKAGE_ZIP).Length -le 0) { throw "zip file is empty: $env:PACKAGE_ZIP" }
|
$zipName = "$env:PACKAGE_BASENAME-$version.zip"
|
||||||
|
$sourceDir = Join-Path $env:RUNNER_TEMP 'chengnan-work'
|
||||||
|
$zipPath = Join-Path $sourceDir $zipName
|
||||||
|
$shaPath = "$zipPath.sha256"
|
||||||
|
if (-not (Test-Path $zipPath)) { throw "zip does not exist: $zipPath" }
|
||||||
|
if (-not (Test-Path $shaPath)) { throw "sha256 does not exist: $shaPath" }
|
||||||
|
if ((Get-Item $zipPath).Length -le 0) { throw "zip file is empty: $zipPath" }
|
||||||
|
Write-Host "Verified package: $zipPath"
|
||||||
|
|
||||||
- name: Upload package to repository release
|
- name: Upload package to repository release
|
||||||
shell: powershell
|
shell: powershell
|
||||||
@@ -134,11 +138,18 @@ jobs:
|
|||||||
if ([string]::IsNullOrWhiteSpace($token)) { $token = $env:GITHUB_TOKEN }
|
if ([string]::IsNullOrWhiteSpace($token)) { $token = $env:GITHUB_TOKEN }
|
||||||
if ([string]::IsNullOrWhiteSpace($token)) { throw 'Missing release token. Configure RELEASE_TOKEN in repository secrets or ensure GITHUB_TOKEN is available.' }
|
if ([string]::IsNullOrWhiteSpace($token)) { throw 'Missing release token. Configure RELEASE_TOKEN in repository secrets or ensure GITHUB_TOKEN is available.' }
|
||||||
|
|
||||||
|
$shortSha = $env:GITHUB_SHA.Substring(0, 10)
|
||||||
|
$version = if ($env:GITHUB_REF_TYPE -eq 'tag') { $env:GITHUB_REF_NAME } else { "build-$shortSha" }
|
||||||
|
$zipName = "$env:PACKAGE_BASENAME-$version.zip"
|
||||||
|
$sourceDir = Join-Path $env:RUNNER_TEMP 'chengnan-work'
|
||||||
|
$zipPath = Join-Path $sourceDir $zipName
|
||||||
|
$shaPath = "$zipPath.sha256"
|
||||||
|
|
||||||
$serverUrl = if ($env:GITHUB_SERVER_URL) { $env:GITHUB_SERVER_URL.TrimEnd('/') } else { 'https://git.luochen570.cn' }
|
$serverUrl = if ($env:GITHUB_SERVER_URL) { $env:GITHUB_SERVER_URL.TrimEnd('/') } else { 'https://git.luochen570.cn' }
|
||||||
$repo = $env:GITHUB_REPOSITORY
|
$repo = $env:GITHUB_REPOSITORY
|
||||||
$apiBase = "$serverUrl/api/v1/repos/$repo"
|
$apiBase = "$serverUrl/api/v1/repos/$repo"
|
||||||
$tagName = $env:RELEASE_TAG
|
$tagName = $version
|
||||||
$releaseName = if ($env:GITHUB_REF_TYPE -eq 'tag') { $env:GITHUB_REF_NAME } else { "chengnan $($env:GITHUB_SHA.Substring(0, 10))" }
|
$releaseName = if ($env:GITHUB_REF_TYPE -eq 'tag') { $env:GITHUB_REF_NAME } else { "chengnan $shortSha" }
|
||||||
$isPrerelease = if ($env:GITHUB_REF_TYPE -eq 'tag') { $false } else { $true }
|
$isPrerelease = if ($env:GITHUB_REF_TYPE -eq 'tag') { $false } else { $true }
|
||||||
$headers = @{ Authorization = "token $token"; Accept = 'application/json' }
|
$headers = @{ Authorization = "token $token"; Accept = 'application/json' }
|
||||||
|
|
||||||
@@ -186,6 +197,6 @@ jobs:
|
|||||||
Write-Host "Uploaded release asset: $name"
|
Write-Host "Uploaded release asset: $name"
|
||||||
}
|
}
|
||||||
|
|
||||||
Upload-Asset $env:PACKAGE_ZIP
|
Upload-Asset $zipPath
|
||||||
Upload-Asset $env:PACKAGE_SHA256
|
Upload-Asset $shaPath
|
||||||
Write-Host "Release assets uploaded to $serverUrl/$repo/releases/tag/$tagName"
|
Write-Host "Release assets uploaded to $serverUrl/$repo/releases/tag/$tagName"
|
||||||
|
|||||||
Reference in New Issue
Block a user