Skip to content

Commit ac7e9e0

Browse files
authored
feat(docs): enable sourcemap upload, releases, and environment tracking (#705)
## Summary Enable sourcemap resolution and environment tracking for the docs site (cli.sentry.dev / `cli-website` Sentry project). - Sourcemaps uploaded to Sentry after each docs build using our own CLI (no 20MB `@sentry/cli` binary) - Environment tracking: `production` on main/release, `staging` on PR previews, `development` locally - Release names match the CLI version from `package.json` - `cli-website` project associated with CLI releases in `sentry-release.yml` ## Changes - **`docs/astro.config.mjs`**: Disable `@sentry/astro` plugin upload, enable Vite sourcemap generation (`hidden`), add `environment` and `release` - **`docs/sentry.client.config.js`**: Add `environment` from `PUBLIC_SENTRY_ENVIRONMENT` - **`docs/sentry.server.config.js`**: Add `environment` from `PUBLIC_SENTRY_ENVIRONMENT` - **`.github/workflows/ci.yml`**: Post-build `sentry sourcemap inject` + `upload` (push to main/release only) - **`.github/workflows/docs-preview.yml`**: Same post-build inject+upload for PR previews - **`.github/workflows/sentry-release.yml`**: Add `cli-website` to `--project` in release create
1 parent 4599ad1 commit ac7e9e0

6 files changed

Lines changed: 79 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ jobs:
662662

663663
build-docs:
664664
name: Build Docs
665-
needs: [lint]
665+
needs: [lint, build-binary]
666666
runs-on: ubuntu-latest
667667
steps:
668668
- uses: actions/checkout@v6
@@ -674,18 +674,50 @@ jobs:
674674
key: node-modules-${{ hashFiles('bun.lock', 'patches/**') }}
675675
- if: steps.cache.outputs.cache-hit != 'true'
676676
run: bun install --frozen-lockfile
677+
- name: Get CLI version
678+
id: version
679+
run: echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT"
680+
- name: Download compiled CLI binary
681+
uses: actions/download-artifact@v8
682+
with:
683+
name: sentry-linux-x64
684+
path: dist-bin
685+
- name: Make binary executable
686+
run: chmod +x dist-bin/sentry-linux-x64
677687
- name: Generate docs content
678688
run: bun run generate:schema && bun run generate:docs
679689
- name: Build Docs
680690
working-directory: docs
691+
env:
692+
PUBLIC_SENTRY_ENVIRONMENT: production
693+
SENTRY_RELEASE: ${{ steps.version.outputs.version }}
694+
PUBLIC_SENTRY_RELEASE: ${{ steps.version.outputs.version }}
681695
run: |
682696
bun install --frozen-lockfile
683697
bun run build
698+
# Inject debug IDs and upload sourcemaps. The inject step adds
699+
# //# debugId= and the _sentryDebugIds IIFE to deployed JS files.
700+
# Both steps require SENTRY_AUTH_TOKEN (the CLI checks auth on startup).
701+
- name: Inject debug IDs and upload sourcemaps
702+
if: github.event_name == 'push' && env.SENTRY_AUTH_TOKEN != ''
703+
env:
704+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
705+
SENTRY_ORG: sentry
706+
SENTRY_PROJECT: cli-website
707+
run: |
708+
./dist-bin/sentry-linux-x64 sourcemap inject docs/dist/
709+
./dist-bin/sentry-linux-x64 sourcemap upload docs/dist/ \
710+
--release "${{ steps.version.outputs.version }}" \
711+
--url-prefix "~/"
712+
# Remove .map files — they were uploaded to Sentry but shouldn't
713+
# be deployed to production.
714+
- name: Remove sourcemaps from output
715+
run: find docs/dist -name '*.map' -delete
684716
- name: Package Docs
685717
run: |
686718
cp .nojekyll docs/dist/
687719
cd docs/dist && zip -r ../../gh-pages.zip .
688-
- name: Upload artifact
720+
- name: Upload docs artifact
689721
uses: actions/upload-artifact@v7
690722
with:
691723
name: gh-pages

.github/workflows/docs-preview.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
- if: steps.cache.outputs.cache-hit != 'true'
3232
run: bun install --frozen-lockfile
3333

34+
- name: Get CLI version
35+
id: version
36+
run: echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT"
37+
3438
- name: Generate docs content
3539
run: bun run generate:schema && bun run generate:docs
3640

@@ -39,10 +43,29 @@ jobs:
3943
env:
4044
# Override base path for PR preview (no /cli prefix since preview domain is different)
4145
DOCS_BASE_PATH: /pr-preview/pr-${{ github.event.pull_request.number }}
46+
PUBLIC_SENTRY_ENVIRONMENT: staging
47+
SENTRY_RELEASE: ${{ steps.version.outputs.version }}
48+
PUBLIC_SENTRY_RELEASE: ${{ steps.version.outputs.version }}
4249
run: |
4350
bun install --frozen-lockfile
4451
bun run build
4552
53+
- name: Inject debug IDs and upload sourcemaps
54+
if: env.SENTRY_AUTH_TOKEN != ''
55+
env:
56+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
57+
SENTRY_ORG: sentry
58+
SENTRY_PROJECT: cli-website
59+
run: |
60+
bun run --bun src/bin.ts sourcemap inject docs/dist/
61+
bun run --bun src/bin.ts sourcemap upload docs/dist/ \
62+
--release "${{ steps.version.outputs.version }}" \
63+
--url-prefix "~/"
64+
65+
# Remove .map files — uploaded to Sentry but shouldn't be deployed.
66+
- name: Remove sourcemaps from output
67+
run: find docs/dist -name '*.map' -delete
68+
4669
- name: Ensure .nojekyll at gh-pages root
4770
run: |
4871
git config user.name "github-actions[bot]"

.github/workflows/sentry-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
# The org/ prefix is how org is specified — it is NOT part of the version.
4848
# The version portion must match Sentry.init({ release }) exactly.
4949
- name: Create release
50-
run: sentry release create "sentry/${VERSION}" --project cli
50+
run: sentry release create "sentry/${VERSION}" --project cli,cli-website
5151

5252
# --auto matches the local origin remote against Sentry repo integrations.
5353
# continue-on-error: integration may not be configured for all orgs.

docs/astro.config.mjs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,27 @@ export default defineConfig({
1111
markdown: {
1212
smartypants: false,
1313
},
14+
// Generate sourcemaps for Sentry. "hidden" produces .map files without
15+
// adding //# sourceMappingURL comments to the output (the debug IDs
16+
// injected post-build by `sentry sourcemap inject` are used instead).
17+
vite: {
18+
build: {
19+
sourcemap: "hidden",
20+
},
21+
},
1422
integrations: [
1523
sentry({
1624
project: "cli-website",
1725
org: "sentry",
18-
authToken: process.env.SENTRY_AUTH_TOKEN,
19-
sourceMapsUploadOptions: {
20-
enabled: !!process.env.SENTRY_AUTH_TOKEN,
21-
},
26+
environment: process.env.PUBLIC_SENTRY_ENVIRONMENT ?? "development",
27+
// Note: @sentry/astro v10 does not support the `release` build-time
28+
// option (todo(v11) in the source). Release is set in Sentry.init()
29+
// via PUBLIC_SENTRY_RELEASE / SENTRY_RELEASE env vars instead.
30+
//
31+
// Disable the plugin's sourcemap upload — it pulls in @sentry/cli
32+
// (20+ MB binary download). We use our own CLI post-build instead
33+
// (see CI workflow: `sentry sourcemap inject` + `sentry sourcemap upload`).
34+
sourceMapsUploadOptions: { enabled: false },
2235
}),
2336
starlight({
2437
title: "Sentry CLI",

docs/sentry.client.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as Sentry from "@sentry/astro";
22

33
Sentry.init({
44
dsn: "https://2aca5fe97c71868bc3aa7fb48620dc39@o1.ingest.us.sentry.io/4510798755856384",
5+
environment: import.meta.env.PUBLIC_SENTRY_ENVIRONMENT ?? "development",
6+
release: import.meta.env.PUBLIC_SENTRY_RELEASE || undefined,
57
sendDefaultPii: true,
68
integrations: [
79
Sentry.browserTracingIntegration(),

docs/sentry.server.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as Sentry from "@sentry/astro";
22

33
Sentry.init({
44
dsn: "https://2aca5fe97c71868bc3aa7fb48620dc39@o1.ingest.us.sentry.io/4510798755856384",
5+
environment: process.env.PUBLIC_SENTRY_ENVIRONMENT ?? "development",
6+
release: process.env.SENTRY_RELEASE || undefined,
57
sendDefaultPii: true,
68
enableLogs: true,
79
tracesSampleRate: 1.0,

0 commit comments

Comments
 (0)