fix(ci): upload symbols outside release path

This commit is contained in:
edde746
2026-04-27 13:23:30 +02:00
parent ca6cb46ba8
commit 240389fb6d
3 changed files with 367 additions and 46 deletions
+27 -7
View File
@@ -1,16 +1,18 @@
#!/usr/bin/env pwsh
# Usage: upload-symbols.ps1 <platform>
# Env: BUGS_ADMIN_TOKEN (required), BUGS_URL (default https://bugs.plezy.app)
# Usage: upload-symbols.ps1 <platform> [source-root]
# Env: BUGS_ADMIN_TOKEN (required unless BUGS_UPLOAD_DRY_RUN is set), BUGS_URL (default https://bugs.plezy.app)
# Platforms: windows-x64 | windows-arm64
param(
[Parameter(Mandatory = $true)]
[string]$Platform
[string]$Platform,
[string]$SourceRoot
)
$ErrorActionPreference = 'Stop'
$Token = $env:BUGS_ADMIN_TOKEN
if ([string]::IsNullOrEmpty($Token)) {
$DryRun = -not [string]::IsNullOrEmpty($env:BUGS_UPLOAD_DRY_RUN)
if (-not $DryRun -and [string]::IsNullOrEmpty($Token)) {
Write-Error 'BUGS_ADMIN_TOKEN env var required'
exit 1
}
@@ -21,11 +23,22 @@ $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$Root = Split-Path -Parent $ScriptDir
Set-Location $Root
if ([string]::IsNullOrEmpty($SourceRoot)) {
$SearchRoot = $Root
}
elseif ([System.IO.Path]::IsPathRooted($SourceRoot)) {
$SearchRoot = $SourceRoot
}
else {
$SearchRoot = Join-Path $Root $SourceRoot
}
$Release = "plezy@$(git rev-parse --short HEAD)"
$Stage = New-Item -ItemType Directory -Path ([System.IO.Path]::GetTempPath()) -Name ([System.IO.Path]::GetRandomFileName()) -Force
$Zip = $null
try {
$DebugInfoDir = Join-Path $Root "debug-info\$Platform"
$DebugInfoDir = Join-Path $SearchRoot "debug-info\$Platform"
if (Test-Path $DebugInfoDir) {
Copy-Item -Path "$DebugInfoDir\*" -Destination $Stage -Recurse -Force
}
@@ -33,7 +46,7 @@ try {
switch ($Platform) {
{ $_ -eq 'windows-x64' -or $_ -eq 'windows-arm64' } {
$Arch = $Platform -replace '^windows-', ''
$PdbRoot = Join-Path $Root "build\windows\$Arch\runner\Release"
$PdbRoot = Join-Path $SearchRoot "build\windows\$Arch\runner\Release"
if (Test-Path $PdbRoot) {
Get-ChildItem -Path $PdbRoot -Filter '*.pdb' -Recurse | ForEach-Object {
Copy-Item $_.FullName -Destination $Stage -Force
@@ -46,11 +59,18 @@ try {
}
}
if (-not (Get-ChildItem -Path $Stage -Force)) {
$Files = Get-ChildItem -Path $Stage -File -Recurse
if (-not $Files) {
Write-Error "no symbols found for platform $Platform"
exit 3
}
if ($DryRun) {
Write-Host "dry-run: would upload $($Files.Count) symbol file(s) for $Platform release $Release"
$Files | ForEach-Object { Write-Host "dry-run: $_" }
return
}
$Zip = Join-Path ([System.IO.Path]::GetTempPath()) "symbols-$([System.IO.Path]::GetRandomFileName()).zip"
Compress-Archive -Path (Join-Path $Stage '*') -DestinationPath $Zip -Force
+26 -9
View File
@@ -1,18 +1,29 @@
#!/usr/bin/env bash
# Usage: upload-symbols.sh <platform>
# Env: BUGS_ADMIN_TOKEN (required), BUGS_URL (default https://bugs.plezy.app)
# Usage: upload-symbols.sh <platform> [source-root]
# Env: BUGS_ADMIN_TOKEN (required unless BUGS_UPLOAD_DRY_RUN is set), BUGS_URL (default https://bugs.plezy.app)
# Platforms: macos | ios | android-apk | android-aab | linux-x64 | linux-arm64
set -euo pipefail
PLATFORM="${1:?platform arg required}"
TOKEN="${BUGS_ADMIN_TOKEN:?BUGS_ADMIN_TOKEN env var required}"
URL="${BUGS_URL:-https://bugs.plezy.app}"
MAX_ATTEMPTS="${BUGS_UPLOAD_ATTEMPTS:-5}"
DRY_RUN="${BUGS_UPLOAD_DRY_RUN:-}"
if [ -z "$DRY_RUN" ]; then
TOKEN="${BUGS_ADMIN_TOKEN:?BUGS_ADMIN_TOKEN env var required}"
else
TOKEN="${BUGS_ADMIN_TOKEN:-}"
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$ROOT"
SOURCE_ROOT="${2:-$ROOT}"
if [[ "$SOURCE_ROOT" != /* ]]; then
SOURCE_ROOT="$ROOT/$SOURCE_ROOT"
fi
RELEASE="plezy@$(git rev-parse --short HEAD)"
ENDPOINT="${URL}/api/0/projects/plezy/plezy/files/dsyms/"
FILES=()
@@ -25,8 +36,8 @@ add_matches() {
}
add_debug_info() {
if [ -d "debug-info/${PLATFORM}" ]; then
add_matches "debug-info/${PLATFORM}" -type f
if [ -d "${SOURCE_ROOT}/debug-info/${PLATFORM}" ]; then
add_matches "${SOURCE_ROOT}/debug-info/${PLATFORM}" -type f
fi
}
@@ -53,6 +64,12 @@ upload_file() {
local fail_arg
size="$(file_size "$file")"
if [ -n "$DRY_RUN" ]; then
echo "dry-run: would upload symbols ${index}/${total}: ${file} (${size} bytes)"
return 0
fi
body="$(mktemp)"
fail_arg="$(curl_fail_arg)"
@@ -100,16 +117,16 @@ add_debug_info
case "$PLATFORM" in
macos)
add_matches build/macos/Build/Products/Release -path '*.dSYM/Contents/Resources/DWARF/*' -type f
add_matches "${SOURCE_ROOT}/build/macos/Build/Products/Release" -path '*.dSYM/Contents/Resources/DWARF/*' -type f
;;
ios)
add_matches build/ios -path '*.dSYM/Contents/Resources/DWARF/*' -type f
add_matches "${SOURCE_ROOT}/build/ios" -path '*.dSYM/Contents/Resources/DWARF/*' -type f
;;
linux-x64|linux-arm64)
add_matches build/linux -path '*/release/bundle/plezy' -type f
add_matches "${SOURCE_ROOT}/build/linux" -path '*/release/bundle/plezy' -type f
;;
android-apk|android-aab)
add_matches build/app/intermediates/merged_native_libs -name '*.so' -type f
add_matches "${SOURCE_ROOT}/build/app/intermediates/merged_native_libs" -name '*.so' -type f
;;
*)
echo "unknown platform: $PLATFORM" >&2