diff --git a/.github/actions/changesets-fixed-version-bump/index.js b/.github/actions/changesets-fixed-version-bump/index.js index 894ad21d44..6875c4b099 100644 --- a/.github/actions/changesets-fixed-version-bump/index.js +++ b/.github/actions/changesets-fixed-version-bump/index.js @@ -89069,11 +89069,7 @@ async function bump() { const version = await (0, util_2.getNextVersion)(); (0, core_1.info)(`Bumping to version ${version}`); process.env.NEXT_PACKAGE_VERSION = version; - const beforeBumpScript = (0, core_1.getInput)('before-bump'); - (0, core_1.info)(`executing before script`); - if (beforeBumpScript) { - await (0, execa_1.command)(beforeBumpScript); - } + await executeCustomScript((0, core_1.getInput)('before-bump')); (0, core_1.info)(`updating root package.json`); await updateRootPackageJson(version); // TODO: what if I use pnpm? either pass the command or package manager? @@ -89081,10 +89077,7 @@ async function bump() { await (0, execa_1.command)('yarn changeset version'); // after bump (0, core_1.info)(`executing after script`); - const afterBumpScript = (0, core_1.getInput)('after-bump'); - if (afterBumpScript) { - await (0, execa_1.command)(afterBumpScript); - } + await executeCustomScript((0, core_1.getInput)('after-bump')); await commitAndTag(version).catch(err => { (0, core_1.error)(err); process.exit(1); @@ -89107,6 +89100,14 @@ async function commitAndTag(version) { (0, core_1.info)(`push`); await (0, execa_1.command)('git push'); // --follow-tags'); } +async function executeCustomScript(script) { + if (script) { + const commands = script.split('\n'); + for (const cmd of commands) { + await (0, execa_1.command)(cmd); + } + } +} bump(); })(); diff --git a/build-packages/changesets-fixed-version-bump/index.ts b/build-packages/changesets-fixed-version-bump/index.ts index 8992ceda3c..1c6b2ecb6b 100644 --- a/build-packages/changesets-fixed-version-bump/index.ts +++ b/build-packages/changesets-fixed-version-bump/index.ts @@ -12,11 +12,7 @@ async function bump() { const version = await getNextVersion(); info(`Bumping to version ${version}`); process.env.NEXT_PACKAGE_VERSION = version; - const beforeBumpScript = getInput('before-bump'); - info(`executing before script`); - if (beforeBumpScript) { - await command(beforeBumpScript); - } + await executeCustomScript(getInput('before-bump')); info(`updating root package.json`); await updateRootPackageJson(version); @@ -26,10 +22,8 @@ async function bump() { // after bump info(`executing after script`); - const afterBumpScript = getInput('after-bump'); - if (afterBumpScript) { - await command(afterBumpScript); - } + await executeCustomScript(getInput('after-bump')); + await commitAndTag(version).catch(err => { error(err); process.exit(1); @@ -58,4 +52,13 @@ async function commitAndTag(version: string) { await command('git push'); // --follow-tags'); } +async function executeCustomScript(script: string) { + if (script) { + const commands = script.split('\n'); + for (const cmd of commands) { + await command(cmd); + } + } +} + bump();