Skip to content
48 changes: 48 additions & 0 deletions .github/actions/composite/setupSentryCLI/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Setup Sentry CLI
description: Download sentry-cli binary from GitHub releases with SHA256 checksum verification

runs:
using: composite
steps:
- name: Download and verify sentry-cli
shell: bash
run: |
# To update: change VERSION and update checksums from
# https://github.com/getsentry/sentry-cli/releases
readonly VERSION="3.2.2"

declare -A CHECKSUMS=(
["Linux-x86_64"]="ec5987dc83ce601fb99bbc43abbc5623832ea507c13ee13f9eab62bf77d3e55e"
["Linux-aarch64"]="06d6498e48eb7c39dbf848a341689eb16ef646eace29d39fd0e4136c637b36a1"
["Darwin-x86_64"]="fed5ac43d7daa7db665ea74aee1c4ba35da63d745243cf32e6c33762230aab7c"
["Darwin-arm64"]="5c9fc7f3157d08bc36c9e44d199602e11da5c3135f217068da2d7c3390f0af22"
)

OS=$(uname -s)
ARCH=$(uname -m)
EXPECTED_SHA="${CHECKSUMS[${OS}-${ARCH}]}"

if [[ -z "$EXPECTED_SHA" ]]; then
echo "::error::Unsupported platform: ${OS}-${ARCH}"
exit 1
fi

INSTALL_DIR="${RUNNER_TEMP:-/tmp}/sentry-cli"
mkdir -p "$INSTALL_DIR"

DOWNLOAD_URL="https://github.com/getsentry/sentry-cli/releases/download/${VERSION}/sentry-cli-${OS}-${ARCH}"
echo "Downloading sentry-cli ${VERSION} for ${OS}-${ARCH}..."

curl --fail --location --retry 3 --retry-delay 3 \
"$DOWNLOAD_URL" --output "$INSTALL_DIR/sentry-cli"

ACTUAL_SHA=$(sha256sum "$INSTALL_DIR/sentry-cli" | awk '{print $1}')
if [[ "$ACTUAL_SHA" != "$EXPECTED_SHA" ]]; then
echo "::error::Checksum mismatch for sentry-cli ${VERSION} (${OS}-${ARCH}): expected ${EXPECTED_SHA}, got ${ACTUAL_SHA}"
rm -f "$INSTALL_DIR/sentry-cli"
exit 1
fi

chmod +x "$INSTALL_DIR/sentry-cli"
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
echo "Installed sentry-cli ${VERSION} (SHA256 verified)"
9 changes: 9 additions & 0 deletions .github/workflows/buildAdHoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ jobs:
pull-request-number: ${{ inputs.APP_PR_NUMBER }}
secrets: inherit

uploadSentry:
needs: [buildAndroid, buildIOS, buildWeb]
if: ${{ always() && (needs.buildAndroid.result == 'success' || needs.buildIOS.result == 'success' || needs.buildWeb.result == 'success') }}
uses: ./.github/workflows/uploadSentry.yml
with:
environment: adhoc
ref: ${{ inputs.APP_REF }}
secrets: inherit

deployWebAdHoc:
name: Deploy Web to S3 (adhoc)
needs: [buildWeb]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/buildAndroid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
uses: callstackincubator/android@4cedf4d9b5c167452c96fe67233577e0fde9a025
env:
GITHUB_TOKEN: ${{ github.token }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
Comment thread
roryabraham marked this conversation as resolved.
Resolved
Comment thread
roryabraham marked this conversation as resolved.
Resolved
IS_HYBRID_APP: true
FORCE_NATIVE_BUILD: ${{ inputs.force-native-build == 'true' && github.run_id || '' }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/buildIOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ jobs:
uses: callstackincubator/ios@dd30f7e53eee2ea6a59509793d0a30fbb5c91216
env:
GITHUB_TOKEN: ${{ github.token }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
IS_HYBRID_APP: true
FORCE_NATIVE_BUILD: ${{ inputs.force-native-build == 'true' && github.run_id || '' }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/buildWeb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
npm run build-adhoc
fi
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DISABLE_AUTO_UPLOAD: 'true'

- name: Upload web sourcemaps artifact
# v6
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,14 @@ jobs:
environment: ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }}
secrets: inherit

uploadSentry:
needs: [androidBuild, iosBuild, webBuild]
if: ${{ always() && (needs.androidBuild.result == 'success' || needs.iosBuild.result == 'success' || needs.webBuild.result == 'success') }}
uses: ./.github/workflows/uploadSentry.yml
with:
environment: ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }}
secrets: inherit

webDeploy:
name: Deploy Web to S3
needs: [prep, webBuild, buildStorybook]
Expand Down
141 changes: 141 additions & 0 deletions .github/workflows/uploadSentry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Upload debug symbols to Sentry

on:
workflow_call:
inputs:
environment:
description: "'adhoc', 'staging', or 'production'"
type: string
required: true
ref:
description: 'Git ref to checkout (must match the ref used to build the artifacts)'
type: string
default: ''
artifact-prefix:
description: 'The prefix for build artifact names'
type: string
default: ''

jobs:
uploadSentry:
name: Upload debug symbols to Sentry
runs-on: blacksmith-4vcpu-ubuntu-2404
continue-on-error: true
steps:
- name: Checkout
# v6
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ inputs.ref || github.sha }}
fetch-depth: 0
Comment thread
roryabraham marked this conversation as resolved.
Resolved

- name: Determine Sentry release name
id: release
run: |
PKG_NAME=$(jq -r .name < package.json)
PKG_VERSION=$(jq -r .version < package.json)
RELEASE="${PKG_NAME}@${PKG_VERSION}"
echo "RELEASE=$RELEASE" >> "$GITHUB_OUTPUT"
echo "Sentry release: $RELEASE"

- name: Download Android sourcemap
id: download-android-sourcemap
continue-on-error: true
# v7
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: ${{ inputs.artifact-prefix }}android-sourcemap-artifact
path: ./sentry-sourcemaps

- name: Download Android proguard mapping
id: download-android-proguard
continue-on-error: true
# v7
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: ${{ inputs.artifact-prefix }}android-proguard-mapping
path: ./sentry-proguard

- name: Download iOS sourcemap
id: download-ios-sourcemap
continue-on-error: true
# v7
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: ${{ inputs.artifact-prefix }}ios-sourcemap-artifact
path: ./sentry-sourcemaps

- name: Download iOS dSYMs
id: download-ios-dsym
continue-on-error: true
# v7
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: ${{ inputs.artifact-prefix }}ios-dsym-artifact
path: ./sentry-dsyms

- name: Download Web sourcemaps
id: download-web-sourcemaps
continue-on-error: true
# v7
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: web-sourcemaps-artifact
path: ./sentry-sourcemaps

- name: Create Sentry release and upload sourcemaps
if: steps.download-android-sourcemap.outcome == 'success' || steps.download-ios-sourcemap.outcome == 'success' || steps.download-web-sourcemaps.outcome == 'success'
# v3.5.0
uses: getsentry/action-release@dab6548b3c03c4717878099e43782cf5be654289
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: expensify
SENTRY_PROJECT: app
with:
environment: ${{ inputs.environment }}
release: ${{ steps.release.outputs.RELEASE }}
sourcemaps: ./sentry-sourcemaps
set_commits: auto
inject: false

- name: Setup sentry-cli
if: steps.download-android-proguard.outcome == 'success' || steps.download-ios-dsym.outcome == 'success'
uses: ./.github/actions/composite/setupSentryCLI

- name: Upload proguard mapping to Sentry
if: steps.download-android-proguard.outcome == 'success'
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: expensify
SENTRY_PROJECT: app
run: |
for attempt in 1 2 3; do
echo "Attempt $attempt: uploading proguard mapping..."
if sentry-cli upload-proguard ./sentry-proguard/mapping.txt; then
echo "Proguard mapping uploaded successfully"
exit 0
fi
echo "::warning::Upload attempt $attempt failed, retrying in 10s..."
sleep 10
done
echo "::error::Failed to upload proguard mapping after 3 attempts"
exit 1

- name: Upload iOS dSYMs to Sentry
if: steps.download-ios-dsym.outcome == 'success'
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: expensify
SENTRY_PROJECT: app
run: |
for attempt in 1 2 3; do
echo "Attempt $attempt: uploading iOS dSYMs..."
if sentry-cli debug-files upload ./sentry-dsyms/; then
echo "iOS dSYMs uploaded successfully"
exit 0
fi
echo "::warning::Upload attempt $attempt failed, retrying in 10s..."
sleep 10
done
echo "::error::Failed to upload iOS dSYMs after 3 attempts"
exit 1
Loading