Skip to content

Commit

Permalink
Bundle all the release steps together
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhobbs committed Oct 7, 2024
1 parent 45eadeb commit dcaf0a3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 46 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,14 @@
"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",
"chromatic-verbose": "cross-env LOG_LEVEL=verbose ./dist/bin.js",
"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",
Expand Down
30 changes: 0 additions & 30 deletions scripts/versionAndBuild.mjs

This file was deleted.

47 changes: 47 additions & 0 deletions scripts/versionAndBuildForRelease.mjs
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit dcaf0a3

Please sign in to comment.