From c02e7b7ad503e28fc1f0b564f1bc7d9939bdab9b Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 9 Nov 2023 09:13:53 -0300 Subject: [PATCH] chore: improving relase routine (#1422) --- .changeset/proud-ducks-travel.md | 2 ++ scripts/changeset-version-with-docs.ts | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .changeset/proud-ducks-travel.md diff --git a/.changeset/proud-ducks-travel.md b/.changeset/proud-ducks-travel.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/proud-ducks-travel.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/scripts/changeset-version-with-docs.ts b/scripts/changeset-version-with-docs.ts index 59f73aa6d50..b6a4912d955 100644 --- a/scripts/changeset-version-with-docs.ts +++ b/scripts/changeset-version-with-docs.ts @@ -1,13 +1,25 @@ #!/usr/bin/env node import { execSync } from 'child_process'; +import { error } from 'console'; (() => { - // Commit versions generated at pre-build step - execSync(`pnpm -C packages/versions prebuild`); - execSync(`git add packages/versions/src/lib/getBuiltinVersions.ts`); - execSync(`git commit -m"ci(scripts): update versions"`); + try { + // Invoke versions' prebuild script (will rewrite version files if needed) + execSync(`pnpm -C packages/versions prebuild`); - // run changeset version - execSync(`changeset version`); + // Checks git status + const isGitClean = !execSync(`git status --porcelain`).toString().trim(); + + // Skip adding/committing/releasing stuff if there's nothing new + if (!isGitClean) { + execSync(`git add packages/versions/src/lib/getBuiltinVersions.ts`); + execSync(`git commit -m"ci(scripts): update versions"`); + + // Run changeset version + execSync(`changeset version`); + } + } catch (err) { + error(err.toString()); + } })();