diff --git a/.github/workflows/package-size-main.yml b/.github/workflows/package-size-main.yml index 1b9149320..a6e9c5470 100644 --- a/.github/workflows/package-size-main.yml +++ b/.github/workflows/package-size-main.yml @@ -22,6 +22,9 @@ jobs: run: yarn install --immutable - name: build run: yarn build + - name: Remove Sourcemaps + run: | + yarn clean:sourcemaps - name: Get Package Size id: package_size run: | diff --git a/.github/workflows/package-size.yml b/.github/workflows/package-size.yml index 2b73a5030..2149bf028 100644 --- a/.github/workflows/package-size.yml +++ b/.github/workflows/package-size.yml @@ -24,6 +24,9 @@ jobs: run: yarn install --immutable - name: build run: yarn build + - name: Remove Sourcemaps + run: | + yarn clean:sourcemaps - name: Get Package Size id: package_size run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 19f399d14..9aab34a69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,10 +39,12 @@ jobs: - run: corepack enable - name: Install dependencies run: yarn install --immutable - - name: Create Release run: yarn run release env: GH_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SENTRY_ORG: chromatic-lt + SENTRY_PROJECT: cli + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} diff --git a/node-src/errorMonitoring.ts b/node-src/errorMonitoring.ts index 7f4e43bc2..7c2f08714 100644 --- a/node-src/errorMonitoring.ts +++ b/node-src/errorMonitoring.ts @@ -48,6 +48,8 @@ export function filterBreadcrumb(breadcrumb: Sentry.Breadcrumb) { Sentry.init({ dsn: 'https://4fa173db2ef3fb073b8ea153a5466d28@o4504181686599680.ingest.us.sentry.io/4507930289373184', + release: process.env.SENTRY_RELEASE || process.env.npm_package_version, + dist: process.env.SENTRY_DIST, sampleRate: 1, environment: process.env.SENTRY_ENVIRONMENT, enabled: @@ -57,7 +59,6 @@ Sentry.init({ integrations: [], initialScope: { tags: { - entrypoint: process.env.CI && process.env.GITHUB_RUN_ID ? 'action' : 'cli', version: process.env.npm_package_version, index_url: process.env.CHROMATIC_INDEX_URL, }, diff --git a/package.json b/package.json index 16517b38b..04f2b71ff 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "lint": "yarn lint:js bin-src node-src test-stories ./isChromatic.js ./isChromatic.mjs", "lint:js": "cross-env NODE_ENV=production eslint --cache --cache-location=.cache/eslint --report-unused-disable-directives", "lint:package": "sort-package-json", - "release": "./scripts/versionAndBuild.mjs && auto shipit", + "release": "./scripts/versionAndBuildForRelease.mjs && auto shipit", "prepack": "clean-package", "postpack": "clean-package restore", "publish-action": "./scripts/publish-action.mjs", @@ -90,7 +90,8 @@ "test": "vitest run --coverage && vitest run -c vitest.no-threads.config.ts", "typescript:check": "tsc --project ./tsconfig.json --noEmit", "prepare": "yarn run build", - "dev": "tsup --watch" + "dev": "tsup --watch", + "clean:sourcemaps": "rm -f dist/*.map && rm -f action/*.map" }, "resolutions": { "any-observable": "^0.5.1" @@ -103,6 +104,7 @@ "@auto-it/slack": "^11.1.6", "@discoveryjs/json-ext": "^0.5.7", "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0", + "@sentry/cli": "^2.37.0", "@sentry/node": "^8.30.0", "@storybook/addon-essentials": "^8.1.5", "@storybook/addon-webpack5-compiler-swc": "^1.0.3", diff --git a/scripts/versionAndBuild.mjs b/scripts/versionAndBuild.mjs deleted file mode 100755 index 328284923..000000000 --- a/scripts/versionAndBuild.mjs +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env node - -import { $ } from 'execa'; - -async function main() { - const { stdout: status } = await $`git status --porcelain`; - if (status) { - console.error(`โ—๏ธ Working directory is not clean:\n${status}`); - return; - } - - const { stdout: nextVersion } = await $`auto shipit --dry-run --quiet`; - - console.info(`๐Ÿ“Œ Temporarily bumping version to '${nextVersion}' for build step`); - await $`npm --no-git-tag-version version ${nextVersion}`; - - console.info('๐Ÿ“ฆ Building with new version'); - await $({ stdio: 'inherit' })`yarn build`; - - console.info('๐Ÿงน Resetting changes to let `auto` do its thing'); - await $`git reset --hard`; - - console.info('โœ… Build with new version completed'); -} - -main(); diff --git a/scripts/versionAndBuildForRelease.mjs b/scripts/versionAndBuildForRelease.mjs new file mode 100755 index 000000000..2908aab72 --- /dev/null +++ b/scripts/versionAndBuildForRelease.mjs @@ -0,0 +1,55 @@ +#!/usr/bin/env node + +import { $ } from 'execa'; + +async function main() { + const { stdout: status } = await $`git status --porcelain`; + if (status) { + console.error(`โ—๏ธ Working directory is not clean:\n${status}`); + return; + } + + const { stdout: nextVersion } = await $`auto shipit --dry-run --quiet`; + + console.info(`๐Ÿ“Œ Temporarily bumping version to '${nextVersion}' for build step`); + await $`npm --no-git-tag-version version ${nextVersion}`; + + console.info('๐Ÿ“ฆ Building with new version'); + await $({ + stdio: 'inherit', + env: { + ...process.env, + SENTRY_RELEASE: nextVersion, + }, + })`yarn build`; + + console.info('๐Ÿงน Resetting changes to let `auto` do its thing'); + await $`git reset --hard`; + + console.info('๐ŸŒ Sending sourcemaps to Sentry'); + await $({ stdout: 'inherit', stderr: 'inherit' })`sentry-cli sourcemaps inject dist action`; + await $({ + stdout: 'inherit', + stderr: 'inherit', + })`sentry-cli sourcemaps upload --release=${nextVersion} --dist=cli dist`; + await $({ + stdout: 'inherit', + stderr: 'inherit', + })`sentry-cli sourcemaps upload --release=${nextVersion} --dist=action action`; + + console.info('๐Ÿš€ Creating new release in Sentry'); + await $({ stdout: 'inherit', stderr: 'inherit' })`sentry-cli releases new ${nextVersion}`; + + console.info('๐Ÿ”— Associating commits with release'); + await $({ + stdout: 'inherit', + stderr: 'inherit', + })`sentry-cli releases set-commits --auto ${nextVersion}`; + + console.info('๐Ÿงน Removing sourcemaps from build'); + await $`yarn clean:sourcemaps`; + + console.info('โœ… Build with new version completed, ready for auto!'); +} + +main(); diff --git a/tsup.config.ts b/tsup.config.ts index fa5788fbe..17d8ca027 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -14,12 +14,14 @@ export default defineConfig((options) => [ resolve: true, }, treeshake: true, - sourcemap: false, + sourcemap: true, clean: true, platform: 'node', target: 'node16', // Storybook still supports Node 16 env: { SENTRY_ENVIRONMENT: process.env.CI ? 'production' : 'development', + SENTRY_RELEASE: process.env.SENTRY_RELEASE || 'development', + SENTRY_DIST: 'cli', }, }, { @@ -29,12 +31,14 @@ export default defineConfig((options) => [ minify: !options.watch, format: ['cjs'], treeshake: true, - sourcemap: false, + sourcemap: true, clean: true, platform: 'node', target: 'node20', // Sync with `runs.using` in action.yml env: { SENTRY_ENVIRONMENT: process.env.CI ? 'production' : 'development', + SENTRY_RELEASE: process.env.SENTRY_RELEASE || 'development', + SENTRY_DIST: 'action', }, }, ]); diff --git a/vitest.config.ts b/vitest.config.ts index f27d89016..afb3f2434 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -6,7 +6,7 @@ export default defineConfig({ exclude: [...configDefaults.exclude, '**/getParentCommits.test.ts'], coverage: { provider: 'v8', - exclude: ['vitest.no-threads.config.ts', ...coverageConfigDefaults.exclude], + exclude: ['vitest.no-threads.config.ts', 'scripts/**', ...coverageConfigDefaults.exclude], }, }, }); diff --git a/yarn.lock b/yarn.lock index ecc4242f8..1d308070b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3655,6 +3655,92 @@ __metadata: languageName: node linkType: hard +"@sentry/cli-darwin@npm:2.37.0": + version: 2.37.0 + resolution: "@sentry/cli-darwin@npm:2.37.0" + conditions: os=darwin + languageName: node + linkType: hard + +"@sentry/cli-linux-arm64@npm:2.37.0": + version: 2.37.0 + resolution: "@sentry/cli-linux-arm64@npm:2.37.0" + conditions: (os=linux | os=freebsd) & cpu=arm64 + languageName: node + linkType: hard + +"@sentry/cli-linux-arm@npm:2.37.0": + version: 2.37.0 + resolution: "@sentry/cli-linux-arm@npm:2.37.0" + conditions: (os=linux | os=freebsd) & cpu=arm + languageName: node + linkType: hard + +"@sentry/cli-linux-i686@npm:2.37.0": + version: 2.37.0 + resolution: "@sentry/cli-linux-i686@npm:2.37.0" + conditions: (os=linux | os=freebsd) & (cpu=x86 | cpu=ia32) + languageName: node + linkType: hard + +"@sentry/cli-linux-x64@npm:2.37.0": + version: 2.37.0 + resolution: "@sentry/cli-linux-x64@npm:2.37.0" + conditions: (os=linux | os=freebsd) & cpu=x64 + languageName: node + linkType: hard + +"@sentry/cli-win32-i686@npm:2.37.0": + version: 2.37.0 + resolution: "@sentry/cli-win32-i686@npm:2.37.0" + conditions: os=win32 & (cpu=x86 | cpu=ia32) + languageName: node + linkType: hard + +"@sentry/cli-win32-x64@npm:2.37.0": + version: 2.37.0 + resolution: "@sentry/cli-win32-x64@npm:2.37.0" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + +"@sentry/cli@npm:^2.37.0": + version: 2.37.0 + resolution: "@sentry/cli@npm:2.37.0" + dependencies: + "@sentry/cli-darwin": "npm:2.37.0" + "@sentry/cli-linux-arm": "npm:2.37.0" + "@sentry/cli-linux-arm64": "npm:2.37.0" + "@sentry/cli-linux-i686": "npm:2.37.0" + "@sentry/cli-linux-x64": "npm:2.37.0" + "@sentry/cli-win32-i686": "npm:2.37.0" + "@sentry/cli-win32-x64": "npm:2.37.0" + https-proxy-agent: "npm:^5.0.0" + node-fetch: "npm:^2.6.7" + progress: "npm:^2.0.3" + proxy-from-env: "npm:^1.1.0" + which: "npm:^2.0.2" + dependenciesMeta: + "@sentry/cli-darwin": + optional: true + "@sentry/cli-linux-arm": + optional: true + "@sentry/cli-linux-arm64": + optional: true + "@sentry/cli-linux-i686": + optional: true + "@sentry/cli-linux-x64": + optional: true + "@sentry/cli-win32-i686": + optional: true + "@sentry/cli-win32-x64": + optional: true + bin: + sentry-cli: bin/sentry-cli + checksum: 10c0/a6e5e3510b7b6a5b3414a2b2bee3bd9c3066b05f70ff20ff65df1d7fb384458182d12a8a0f0319af02e8dbaf6f5e5d23da394eb6bdb8b9face3909699d0f9495 + languageName: node + linkType: hard + "@sentry/core@npm:8.30.0": version: 8.30.0 resolution: "@sentry/core@npm:8.30.0" @@ -7457,6 +7543,7 @@ __metadata: "@auto-it/slack": "npm:^11.1.6" "@discoveryjs/json-ext": "npm:^0.5.7" "@eslint-community/eslint-plugin-eslint-comments": "npm:^4.3.0" + "@sentry/cli": "npm:^2.37.0" "@sentry/node": "npm:^8.30.0" "@storybook/addon-essentials": "npm:^8.1.5" "@storybook/addon-webpack5-compiler-swc": "npm:^1.0.3" @@ -15780,6 +15867,13 @@ __metadata: languageName: node linkType: hard +"progress@npm:^2.0.3": + version: 2.0.3 + resolution: "progress@npm:2.0.3" + checksum: 10c0/1697e07cb1068055dbe9fe858d242368ff5d2073639e652b75a7eb1f2a1a8d4afd404d719de23c7b48481a6aa0040686310e2dac2f53d776daa2176d3f96369c + languageName: node + linkType: hard + "promise-deferred@npm:^2.0.3": version: 2.0.4 resolution: "promise-deferred@npm:2.0.4" @@ -15849,6 +15943,13 @@ __metadata: languageName: node linkType: hard +"proxy-from-env@npm:^1.1.0": + version: 1.1.0 + resolution: "proxy-from-env@npm:1.1.0" + checksum: 10c0/fe7dd8b1bdbbbea18d1459107729c3e4a2243ca870d26d34c2c1bcd3e4425b7bcc5112362df2d93cc7fb9746f6142b5e272fd1cc5c86ddf8580175186f6ad42b + languageName: node + linkType: hard + "pump@npm:^2.0.0": version: 2.0.1 resolution: "pump@npm:2.0.1" @@ -20026,7 +20127,7 @@ __metadata: languageName: node linkType: hard -"which@npm:^2.0.1": +"which@npm:^2.0.1, which@npm:^2.0.2": version: 2.0.2 resolution: "which@npm:2.0.2" dependencies: