From 035c9b72ac24d400ee591555468382e980af4e86 Mon Sep 17 00:00:00 2001 From: Cody Kaup Date: Fri, 4 Oct 2024 09:46:40 -0500 Subject: [PATCH] Use custom build script to temporarily bump version and build --- package.json | 2 +- scripts/versionAndBuild.mjs | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 scripts/versionAndBuild.mjs diff --git a/package.json b/package.json index 7daf4bdd7..16517b38b 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": "yarn run build && auto shipit", + "release": "./scripts/versionAndBuild.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 new file mode 100644 index 000000000..e84f9ffc1 --- /dev/null +++ b/scripts/versionAndBuild.mjs @@ -0,0 +1,26 @@ +#!/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 $`yarn build`; + + console.info('๐Ÿงน Resetting changes to let `auto` do its thing'); + await $`git reset --hard`; + + console.info('โœ… Build with new version completed'); +} + +main();