Files
OrcaSlicer/.github/workflows/sentry_cli.yml
2025-12-11 11:53:49 +08:00

166 lines
6.7 KiB
YAML

name: Upload Debug Symbols to Sentry
on:
workflow_call:
inputs:
os:
required: true
type: string
description: "Target OS: windows-latest, macos-14, ubuntu-20.04, ubuntu-24.04"
pdb-artifact-name:
required: false
type: string
description: "Artifact name for Windows PDB archive (e.g., 'PDB')"
dsym-artifact-name:
required: false
type: string
description: "Artifact name for macOS dSYM archive (e.g., 'dSYM_Mac_V1.0.0')"
release:
required: true
type: string
description: "Release version/tag"
jobs:
upload_symbols:
name: Upload Debug Symbols to Sentry
runs-on: ${{ inputs.os }}
steps:
# ==================== Windows ====================
- name: "[Windows] Install sentry-cli via choco"
if: inputs.os == 'windows-latest'
shell: pwsh
run: |
choco install sentry-cli -y -y 2>&1 | Out-Null
- name: "[Windows] Download PDB artifact"
if: inputs.os == 'windows-latest'
uses: actions/download-artifact@v4
with:
name: ${{ inputs.pdb-artifact-name }}
path: ./symbols
- name: "[Windows] Extract PDB archive"
if: inputs.os == 'windows-latest'
shell: pwsh
run: |
$archive = Get-ChildItem -Path ./symbols -Filter "*.7z" -File | Select-Object -First 1
if ($archive) {
Write-Host "Found archive: $($archive.FullName)"
Write-Host "Extracting to ./symbols/extracted ..."
7z x "$($archive.FullName)" -o"./symbols/extracted" -y
if ($LASTEXITCODE -ne 0) {
Write-Host "::error::Failed to extract archive with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
Write-Host "Extraction complete. Contents:"
Get-ChildItem -Path ./symbols/extracted -Recurse | ForEach-Object { Write-Host " $($_.FullName)" }
} else {
Write-Host "No .7z archive found, assuming PDB files are already extracted"
Get-ChildItem -Path ./symbols -Recurse | ForEach-Object { Write-Host " Found: $($_.FullName)" }
}
- name: "[Windows] Upload PDB to Sentry (sentry-cli)"
if: inputs.os == 'windows-latest'
shell: pwsh
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_LOG_LEVEL: debug
run: |
# Determine upload path - prefer extracted folder if it exists
$uploadPath = "./symbols"
if (Test-Path "./symbols/extracted") {
$uploadPath = "./symbols/extracted"
}
$pdbFiles = Get-ChildItem -Path $uploadPath -Filter "*.pdb" -File -Recurse
if ($pdbFiles.Count -gt 0) {
Write-Host "Found $($pdbFiles.Count) PDB file(s) to upload from $uploadPath :"
$pdbFiles | ForEach-Object { Write-Host " - $($_.FullName)" }
Write-Host ""
Write-Host "Starting Sentry upload with debug logging..."
sentry-cli.exe --log-level=debug --auth-token $env:SENTRY_AUTH_TOKEN upload-dif --org "${{ secrets.SENTRY_ORG }}" --project "${{ secrets.SENTRY_PROJECT }}" $uploadPath 2>&1 | Out-Host
if ($LASTEXITCODE -ne 0) {
Write-Host "::error::Sentry upload failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
} else {
Write-Host "::error::No PDB files found in $uploadPath"
Get-ChildItem -Path ./symbols -Recurse | ForEach-Object { Write-Host " Found: $($_.FullName)" }
exit 1
}
# ==================== macOS ====================
- name: "[macOS] Install sentry-cli"
if: inputs.os == 'macos-14'
run: |
# Try multiple installation methods for reliability
# Method 1: Official install script (most reliable)
if ! command -v sentry-cli &> /dev/null; then
echo "Installing sentry-cli via official script..."
curl -sL https://sentry.io/get-cli/ | bash || true
fi
# Method 2: npm fallback
if ! command -v sentry-cli &> /dev/null; then
echo "Official script failed, trying npm..."
npm install -g @sentry/cli || true
fi
# Method 3: Direct binary download fallback
if ! command -v sentry-cli &> /dev/null; then
echo "npm failed, downloading binary directly..."
SENTRY_CLI_VERSION=$(curl -s https://api.github.com/repos/getsentry/sentry-cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
curl -sL "https://github.com/getsentry/sentry-cli/releases/download/${SENTRY_CLI_VERSION}/sentry-cli-Darwin-universal" -o /usr/local/bin/sentry-cli
chmod +x /usr/local/bin/sentry-cli
fi
# Verify installation
if command -v sentry-cli &> /dev/null; then
echo "sentry-cli installed successfully:"
sentry-cli --version
else
echo "::error::Failed to install sentry-cli via all methods"
exit 1
fi
- name: "[macOS] Download dSYM artifact"
if: inputs.os == 'macos-14'
uses: actions/download-artifact@v4
with:
name: ${{ inputs.dsym-artifact-name }}
path: ./symbols
- name: "[macOS] Upload dSYM to Sentry (sentry-cli)"
if: inputs.os == 'macos-14'
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_LOG_LEVEL: debug
run: |
echo "Checking for dSYM files in ./symbols..."
find ./symbols -name "*.dSYM" -type d | while read dsym; do
echo "Found dSYM: $dsym"
done
dsymCount=$(find ./symbols -name "*.dSYM" -type d | wc -l | tr -d ' ')
if [ "$dsymCount" -gt 0 ]; then
echo "Found $dsymCount dSYM file(s) to upload from ./symbols:"
find ./symbols -name "*.dSYM" -type d | while read dsym; do
echo " - $dsym"
done
echo ""
echo "Starting Sentry upload with debug logging..."
sentry-cli --log-level=debug --auth-token "$SENTRY_AUTH_TOKEN" upload-dif --org "${{ secrets.SENTRY_ORG }}" --project "${{ secrets.SENTRY_PROJECT }}" --release "${{ inputs.release }}" ./symbols
if [ $? -ne 0 ]; then
echo "::error::Sentry upload failed with exit code $?"
exit 1
fi
else
echo "::error::No dSYM files found in ./symbols"
echo "Contents of ./symbols:"
find ./symbols -type f -o -type d | head -20
exit 1
fi
# ==================== Linux ====================