diff --git a/.github/actions/composite/setupSentryCLI/action.yml b/.github/actions/composite/setupSentryCLI/action.yml new file mode 100644 index 000000000000..a971742b537e --- /dev/null +++ b/.github/actions/composite/setupSentryCLI/action.yml @@ -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)" diff --git a/.github/workflows/buildAdHoc.yml b/.github/workflows/buildAdHoc.yml index 14e1fc066ea7..f4b06519fc55 100644 --- a/.github/workflows/buildAdHoc.yml +++ b/.github/workflows/buildAdHoc.yml @@ -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] diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 1e1c9ef457e5..71f05a7fc43b 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -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' IS_HYBRID_APP: true FORCE_NATIVE_BUILD: ${{ inputs.force-native-build == 'true' && github.run_id || '' }} with: diff --git a/.github/workflows/buildIOS.yml b/.github/workflows/buildIOS.yml index ae43bcd2d8e7..47a38ff7db7d 100644 --- a/.github/workflows/buildIOS.yml +++ b/.github/workflows/buildIOS.yml @@ -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: diff --git a/.github/workflows/buildWeb.yml b/.github/workflows/buildWeb.yml index 0562ff333e7f..7a3fca528241 100644 --- a/.github/workflows/buildWeb.yml +++ b/.github/workflows/buildWeb.yml @@ -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 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index aa5f42d640ff..319464950c93 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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] diff --git a/.github/workflows/uploadSentry.yml b/.github/workflows/uploadSentry.yml new file mode 100644 index 000000000000..e4aea40d919e --- /dev/null +++ b/.github/workflows/uploadSentry.yml @@ -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 + + - 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