Publish distributions to Gitea PyPI registry alongside the release
publish-dlp-io / publish (push) Failing after 1m6s
publish-dlp-io / publish (push) Failing after 1m6s
This commit is contained in:
@@ -341,3 +341,51 @@ jobs:
|
||||
throw "release asset mismatch: $($publishedNames -join ', ')"
|
||||
}
|
||||
Write-Host "release verified: $tag ($($localNames.Count) files)"
|
||||
|
||||
- name: Publish packages to Gitea PyPI
|
||||
shell: pwsh
|
||||
env:
|
||||
TWINE_USERNAME: antior
|
||||
TWINE_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||
TWINE_REPOSITORY_URL: ${{ gitea.server_url }}/api/packages/antior/pypi
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ([string]::IsNullOrWhiteSpace($env:TWINE_PASSWORD)) {
|
||||
throw "GITHUB_TOKEN is required to publish packages"
|
||||
}
|
||||
$headers = @{ Authorization = "token $env:TWINE_PASSWORD" }
|
||||
$simpleUrl = "$env:TWINE_REPOSITORY_URL/simple/dlp-io/"
|
||||
|
||||
function Get-RegistryFileNames {
|
||||
try {
|
||||
$response = Invoke-WebRequest -Headers $headers -Uri $simpleUrl
|
||||
} catch {
|
||||
if ([int]$_.Exception.Response.StatusCode -eq 404) { return @() }
|
||||
throw
|
||||
}
|
||||
return @([regex]::Matches($response.Content, '<a\s+href="[^"]+"[^>]*>(?<name>[^<]+)</a>', "IgnoreCase") |
|
||||
ForEach-Object { [Net.WebUtility]::HtmlDecode($_.Groups["name"].Value) })
|
||||
}
|
||||
|
||||
$published = @(Get-RegistryFileNames)
|
||||
$missing = @(Get-ChildItem -LiteralPath dist -File | Where-Object { $published -notcontains $_.Name })
|
||||
if ($missing.Count -gt 0) {
|
||||
$uploadArgs = @("-3.13", "-m", "twine", "upload", "--non-interactive", "--disable-progress-bar") +
|
||||
@($missing | ForEach-Object FullName)
|
||||
& py @uploadArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw "twine upload failed" }
|
||||
} else {
|
||||
Write-Host "all registry artifacts already published"
|
||||
}
|
||||
|
||||
$expected = @(Get-ChildItem -LiteralPath dist -File | ForEach-Object Name)
|
||||
for ($attempt = 1; $attempt -le 20; $attempt++) {
|
||||
$published = @(Get-RegistryFileNames)
|
||||
$unpublished = @($expected | Where-Object { $published -notcontains $_ })
|
||||
if ($unpublished.Count -eq 0) { break }
|
||||
if ($attempt -lt 20) { Start-Sleep -Seconds 3 }
|
||||
}
|
||||
if ($unpublished.Count -ne 0) {
|
||||
throw "registry package files missing after upload: $($unpublished -join ', ')"
|
||||
}
|
||||
Write-Host "registry verified: dlp-io==$($env:DLP_IO_PACKAGE_VERSION) ($($expected.Count) files)"
|
||||
|
||||
Reference in New Issue
Block a user