ci: upload release artifacts concurrently [CI SKIP]
This commit is contained in:
1 parent
a9ee4ec34c
commit
3bf12ec73d
2 files changed
+47
-32
No files matched your search
@@ -33,24 +33,6 @@ function New-TarGzArchive([string]$SourceDirectory, [string]$ArchivePath, [strin
|
||||
}
|
||||
}
|
||||
|
||||
function Upload-Package([string]$File) {
|
||||
$name = Split-Path -Leaf $File
|
||||
$url = "$giteaBase/api/packages/justme/generic/monitor-node/$version/$name"
|
||||
$status = & curl.exe --silent --show-error --retry 3 --netrc-file $netrc --upload-file $File --output NUL --write-out '%{http_code}' $url
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Gitea package upload failed for $name."
|
||||
}
|
||||
if ($status -match '^2') {
|
||||
Write-Output "uploaded Gitea package $name"
|
||||
}
|
||||
elseif ($status -eq '409') {
|
||||
Write-Output "Gitea package $name already exists; reusing the existing release file"
|
||||
}
|
||||
else {
|
||||
throw "Gitea package upload failed for $name (HTTP $status)."
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$targets = @(
|
||||
@{ Rid = 'linux-x64'; Os = 'linux'; Arch = 'amd64'; Windows = $false },
|
||||
@@ -64,6 +46,7 @@ try {
|
||||
)
|
||||
$packageRoot = Join-Path $root '.release\packages'
|
||||
$null = New-Item -ItemType Directory -Force -Path $packageRoot
|
||||
$uploadFiles = [System.Collections.Generic.List[string]]::new()
|
||||
foreach ($target in $targets) {
|
||||
$agentDirectory = Join-Path $root ".release\publish\$($target.Rid)\agent"
|
||||
$probeDirectory = Join-Path $root ".release\publish\$($target.Rid)\probe"
|
||||
@@ -123,10 +106,29 @@ consumer install.
|
||||
$checksum = "$hash $archiveName`n"
|
||||
$checksumPath = "$archive.sha256"
|
||||
[IO.File]::WriteAllText($checksumPath, $checksum, [Text.UTF8Encoding]::new($false))
|
||||
Upload-Package $archive
|
||||
Upload-Package $checksumPath
|
||||
[void]$uploadFiles.Add($archive)
|
||||
[void]$uploadFiles.Add($checksumPath)
|
||||
}
|
||||
}
|
||||
|
||||
$uploadFiles.ToArray() | ForEach-Object -Parallel {
|
||||
$file = $_
|
||||
$name = Split-Path -Leaf $file
|
||||
$url = "$using:giteaBase/api/packages/justme/generic/monitor-node/$using:version/$name"
|
||||
$status = & curl.exe --silent --show-error --retry 3 --netrc-file $using:netrc --upload-file $file --output NUL --write-out '%{http_code}' $url
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Gitea package upload failed for $name."
|
||||
}
|
||||
if ($status -match '^2') {
|
||||
Write-Output "uploaded Gitea package $name"
|
||||
}
|
||||
elseif ($status -eq '409') {
|
||||
Write-Output "Gitea package $name already exists; reusing the existing release file"
|
||||
}
|
||||
else {
|
||||
throw "Gitea package upload failed for $name (HTTP $status)."
|
||||
}
|
||||
} -ThrottleLimit 8
|
||||
}
|
||||
finally {
|
||||
Remove-Item -LiteralPath $netrc -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Reference in new issue
Block a user