diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9b6a0141..9aab34a69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,22 +39,12 @@ jobs: - run: corepack enable - name: Install dependencies run: yarn install --immutable - - name: Get Next Version - id: next_version - run: | - export NEXT_VERSION="$(./scripts/getNextVersion.mjs)" - echo "Next Version: $NEXT_VERSION" - echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT" - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} - 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 }} - NEXT_VERSION: ${{ steps.next_version.outputs.version }} - SENTRY_RELEASE: ${{ steps.next_version.outputs.version }} SENTRY_ORG: chromatic-lt SENTRY_PROJECT: cli SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} diff --git a/package.json b/package.json index 5bbf78ce6..04f2b71ff 100644 --- a/package.json +++ b/package.json @@ -73,11 +73,6 @@ "build-storybook": "storybook build --stats-json", "build-test-storybook": "cross-env SMOKE_TEST=true storybook build -o test-storybook --stats-json", "build-subdir": "cd subdir ; yarn build ; cd ..", - "sentry": "yarn sentry:sourcemaps:cli && yarn sentry:sourcemaps:action && yarn sentry:release && yarn sentry:release:commits", - "sentry:sourcemaps:cli": "sentry-cli sourcemaps inject dist && sentry-cli sourcemaps upload dist", - "sentry:sourcemaps:action": "sentry-cli sourcemaps inject action && sentry-cli sourcemaps upload action", - "sentry:release": "sentry-cli releases new -p cli $NEXT_VERSION", - "sentry:release:commits": "sentry-cli releases set-commits --auto $NEXT_VERSION", "chromatic": "./dist/bin.js", "chromatic-prebuilt": "./dist/bin.js --storybook-build-dir=\"storybook-static\"", "chromatic-staging": "CHROMATIC_INDEX_URL=https://www.staging-chromatic.com ./dist/bin.js", @@ -85,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 && yarn sentry && yarn clean:sourcemaps && auto shipit", + "release": "./scripts/versionAndBuildForRelease.mjs && auto shipit", "prepack": "clean-package", "postpack": "clean-package restore", "publish-action": "./scripts/publish-action.mjs", diff --git a/scripts/versionAndBuild.mjs b/scripts/versionAndBuild.mjs deleted file mode 100755 index a0c252705..000000000 --- a/scripts/versionAndBuild.mjs +++ /dev/null @@ -1,30 +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 nextVersion = process.env.NEXT_VERSION; - if (!nextVersion) { - console.error('โ—๏ธ NEXT_VERSION environment variable is required'); - return; - } - - 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..ab626a438 --- /dev/null +++ b/scripts/versionAndBuildForRelease.mjs @@ -0,0 +1,47 @@ +#!/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 $`sentry-cli sourcemaps inject dist`; + await $`sentry-cli sourcemaps upload dist`; + await $`sentry-cli sourcemaps inject action`; + await $`sentry-cli sourcemaps upload action`; + + console.info('๐Ÿš€ Creating new release in Sentry'); + await $`sentry-cli releases new -p cli ${nextVersion}`; + + console.info('๐Ÿ”— Associating commits with release'); + await $`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();