Skip to content

feat(core): Support SENTRY_RELEASE and SENTRY_DIST env vars in build scripts#6070

Merged
antonis merged 3 commits intomainfrom
antonis/feat/sentry-release-dist-env-vars
Apr 30, 2026
Merged

feat(core): Support SENTRY_RELEASE and SENTRY_DIST env vars in build scripts#6070
antonis merged 3 commits intomainfrom
antonis/feat/sentry-release-dist-env-vars

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 29, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Extends sentry-xcode.sh and sentry.gradle to support SENTRY_RELEASE and SENTRY_DIST environment variables for overriding values in sentry.options.json at build time, following the existing SENTRY_ENVIRONMENT pattern.

When using native auto-init (RNSentrySDK.start() / useNativeInit), users with custom release formats in Sentry.init() end up with two releases in Sentry — one from native init (auto-detected) and one from JS init (custom). This gives them a build-time mechanism to align both.

These env vars are already used by sentry-cli for source maps upload in the same build scripts, so setting them now aligns both source maps and native init in one step.

💡 Motivation and Context

Closes #6069
Related: #6064

💚 How did you test it?

Added tests for the iOS xcode script covering:

  • Override release only
  • Override dist only
  • Override existing release/dist values
  • Override all three (environment + release + dist) together
  • Source file is not modified
  • Invalid JSON fallback

No gradle tests exist in the repo (pre-existing).

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

…scripts

The build scripts (`sentry-xcode.sh` and `sentry.gradle`) already support
overriding `environment` in `sentry.options.json` via `SENTRY_ENVIRONMENT`.
This extends the same pattern to `SENTRY_RELEASE` and `SENTRY_DIST`.

When using native auto-init, users with custom release formats in
`Sentry.init()` need a way to set matching values in the options file
at build time to avoid split releases (pre-JS crashes on one release,
post-JS events on another).

These env vars are already used by `sentry-cli` for source maps upload,
so setting them now aligns both source maps and native init in one step.

Closes #6069

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • feat(core): Support SENTRY_RELEASE and SENTRY_DIST env vars in build scripts by antonis in #6070
  • test(ios): Add unit tests for RNSentryIsPathUnderAllowedRoots by antonis in #6068
  • test(profiling): pin Android RNSentryStart wiring of _experiments.profilingOptions by antonis in #6060
  • refactor(ios): remove dead SentrySDKWrapper init surface by antonis in #6059
  • chore(deps): update Bundler Plugins to v5.2.1 by github-actions in #6067
  • chore(deps): update CLI to v3.4.1 by github-actions in #6066
  • fix(ci): Grant statuses: write to changelog-preview caller by antonis in #6063
  • fix(android): Use safeExtGet for compileSdkVersion in expo-handler by lucas-zimerman in #6061
  • fix(core): Restrict getDataFromUri native bridge methods by antonis in #6045
  • chore(deps): bump postcss to ^8.5.10 by antonis in #6058
  • ref: Remove enableSessionReplayInUnreliableEnvironment use by itaybre in #6046
  • fix(core): Harden metro dev helpers by antonis in #6044
  • fix(android): Mask auth token in sentry.gradle upload-task log by antonis in #6057
  • fix(tracing): Discard invalid navigation transactions via event processor by alwx in #6051
  • ci: Restore changelog-preview workflow with hardened craft 2.26.2 by antonis in #6056
  • chore(deps): update Maestro to v2.5.0 by github-actions in #6053
  • chore(deps): bump getsentry/craft from 2.25.4 to 2.26.2 by dependabot in #6050
  • chore: Back-merge release/8.9.1 into main by antonis in #6055
  • feat(core): Add rage tap detection with ui.frustration breadcrumbs by alwx in #5992
  • chore(deps): bump fast-xml-parser to ^5.7.0 by antonis in #6043
  • chore(deps): bump @xmldom/xmldom to 0.8.13/0.9.10 by antonis in #6042
  • chore(deps-dev): Remove unused uuid devDependency by antonis in #6041
  • feat(core): Add includeFeedback Metro option to exclude feedback widget from bundle by antonis in #6025
  • chore(deps): update JavaScript SDK to v10.50.0 by github-actions in #6040

Plus 2 more


🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 00db39c

antonis and others added 2 commits April 29, 2026 17:18
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Apr 29, 2026

@sentry review

@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Apr 29, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 00db39c. Configure here.

@antonis antonis marked this pull request as ready for review April 29, 2026 15:29
Copy link
Copy Markdown
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice little fix!

@antonis antonis merged commit 5953fd6 into main Apr 30, 2026
58 of 64 checks passed
@antonis antonis deleted the antonis/feat/sentry-release-dist-env-vars branch April 30, 2026 06:57
antonis added a commit to getsentry/sentry-docs that referenced this pull request Apr 30, 2026
…upport (#17546)

## DESCRIBE YOUR PR

Documents the `SENTRY_RELEASE` and `SENTRY_DIST` build-time environment
variable overrides for `sentry.options.json` in the
app-start-error-capture guide.

⚠️ Based on #17540

**Changes:**
- Added "Setting Release and Distribution" env var usage with CLI
example
- Updated EAS Build profiles example to include `SENTRY_RELEASE` and
`SENTRY_DIST`

⚠️ Should be merged after getsentry/sentry-react-native#6070  ships

## IS YOUR CHANGE URGENT?

- [ ] Urgent deadline (GA date, etc.)
- [ ] Other deadline
- [x] None: Not urgent, can wait up to 1 week+

## PRE-MERGE CHECKLIST

- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support SENTRY_RELEASE and SENTRY_DIST env vars in build scripts for sentry.options.json

2 participants