Skip to content

Commit

Permalink
Merge pull request #1084 from chromaui/jmhobbs/cap-2192-add-releases
Browse files Browse the repository at this point in the history
Add Sentry Releases
  • Loading branch information
jmhobbs authored Oct 8, 2024
2 parents d642d22 + 22b76e8 commit be33c60
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/package-size-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/package-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
3 changes: 2 additions & 1 deletion node-src/errorMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
},
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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",
Expand Down
26 changes: 0 additions & 26 deletions scripts/versionAndBuild.mjs

This file was deleted.

55 changes: 55 additions & 0 deletions scripts/versionAndBuildForRelease.mjs
Original file line number Diff line number Diff line change
@@ -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();
8 changes: 6 additions & 2 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
{
Expand All @@ -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',
},
},
]);
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
},
});
103 changes: 102 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit be33c60

Please sign in to comment.