Skip to content

ci: use production environment for sentry-release auth token#645

Merged
BYK merged 1 commit intomainfrom
fix/sentry-release-auth
Apr 2, 2026
Merged

ci: use production environment for sentry-release auth token#645
BYK merged 1 commit intomainfrom
fix/sentry-release-auth

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 2, 2026

Summary

Fixes the second sentry-release failure:

Error: Not authenticated. Run 'sentry auth login' first.

Two issues:

  1. Missing environmentSENTRY_AUTH_TOKEN is scoped to the production environment. Without environment: production on the job, the secret resolves to empty.

  2. Wrong release version — The workflow used sentry/${VERSION} (e.g., sentry/0.24.0) but Sentry.init() and sourcemap uploads both use bare semver (0.24.0). Events would never be associated with the release.

Changes

  • Add environment: production to the finalize job
  • Drop sentry/ prefix from all release version references to match Sentry.init() (release: CLI_VERSION in telemetry.ts:417) and sourcemap uploads (release: VERSION in build.ts:179)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

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


Bug Fixes 🐛

  • (upgrade) Add blank lines around changelog in upgrade output by BYK in #642

Internal Changes 🔧

  • Use production environment for sentry-release auth token by BYK in #645
  • Fix sentry-release workflow Node.js version and add manual trigger by BYK in #643
  • Regenerate skill files and command docs by github-actions[bot] in 59c820e4

🤖 This preview updates automatically when you update the PR.

@BYK BYK changed the title fix(ci): use production environment for sentry-release auth token ci: use production environment for sentry-release auth token Apr 2, 2026
…ntry-release workflow

- Add environment: production so the job can access SENTRY_AUTH_TOKEN
- Drop sentry/ prefix from release version to match Sentry.init() and
  sourcemap uploads which both use bare semver (e.g., '0.24.0')
@BYK BYK force-pushed the fix/sentry-release-auth branch from cccd5d0 to d83e081 Compare April 2, 2026 19:33
@BYK BYK merged commit a0ded19 into main Apr 2, 2026
26 checks passed
@BYK BYK deleted the fix/sentry-release-auth branch April 2, 2026 19:42
BYK added a commit that referenced this pull request Apr 2, 2026
## Summary

Fixes the [third sentry-release
failure](https://github.com/getsentry/cli/actions/runs/23918696701/job/69759189495):
```
Error: Organization is required.
```

The previous PR (#645) mistakenly removed the `sentry/` prefix thinking
it was a version prefix. It's actually the **org slug** —
`parseReleaseArg("sentry/0.24.0")` splits into org=`sentry`,
version=`0.24.0`. Restoring it provides the org without needing
`SENTRY_ORG`.

Fixes #647.
BYK added a commit that referenced this pull request Apr 3, 2026
## Summary

Fixes `set-commits --auto` to properly discover commits and documents
release workflow pitfalls learned from shipping the sentry-release CI
workflow.

Continuation of #643, #645, #648, #649 (all merged).

## Changes

### `set-commits --auto` rewrite (`src/lib/api/releases.ts`)
- **Replace bogus `{repository: "auto", commit: "auto"}`** — list org
repos via paginated API, match against local git remote, send real refs
with HEAD SHA
- **Fetch previous release commit** via `/previous-with-commits/`
endpoint so Sentry can compute the commit range (without this, 0 commits
are reported)
- **Paginate** through all org repos with early-exit
(`listRepositoriesPaginated`)
- Use `ApiError` for no-repos (correct negative caching),
`ValidationError` for local git failures
- Fix `ApiError` constructor: `endpoint` as 4th arg, not 3rd

### Fallback fix (`src/commands/release/set-commits.ts`)
- Catch `ValidationError` in `setCommitsDefault` → fall back to local
git history

### Workflow fixes (`.github/workflows/sentry-release.yml`)
- `actions/checkout@v6` with `fetch-depth: 0` (needed for `--auto` git
discovery)
- Move `--url` from `release create` to `release deploy` (URL belongs on
the deploy)
- Inline comments documenting every pitfall (Node.js version, env
scoping, org prefix)

### Documentation
- **agent-guidance.md**: New "Release Workflow" section with CI/CD setup
notes; new Common Mistakes for version mismatch and `--auto` without
checkout
- **release.md**: CI workflow example + "Important Notes" section
- **create.ts help**: Clarifies `org/version` positional format and
version matching
- **set-commits.ts help**: Clarifies `--auto` requires git checkout;
documents default fallback behavior
- Regenerated SKILL.md + reference files

### Tests
- Isolated tests: repo discovery, pagination, no-match, no-repos,
no-remote, previous commit fetch
- Command tests: `--auto` cwd pass-through, `ValidationError` fallback
in default mode
- Patch coverage: `releases.ts` ~99%, `set-commits.ts` ~75%
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.

1 participant