diff --git a/.github/actions/changesets-fixed-version-bump/action.yml b/.github/actions/changesets-fixed-version-bump/action.yml index 1b8d348e6d..4e92fb7a5a 100644 --- a/.github/actions/changesets-fixed-version-bump/action.yml +++ b/.github/actions/changesets-fixed-version-bump/action.yml @@ -1,15 +1,8 @@ name: 'Fixed version bump' description: 'Bumps version for fixed packages and the root package.json using changests.' -inputs: - before-bump: - description: 'Script to run before bumping the version' - required: false - after-bump: - description: 'Script to run after bumping the version' - required: false outputs: - changelog: - description: 'The current changelog' + version: + description: 'The new version' runs: using: 'node20' main: 'index.js' diff --git a/.github/actions/changesets-fixed-version-bump/index.js b/.github/actions/changesets-fixed-version-bump/index.js index 32359c32fe..246e2094b6 100644 --- a/.github/actions/changesets-fixed-version-bump/index.js +++ b/.github/actions/changesets-fixed-version-bump/index.js @@ -89063,20 +89063,14 @@ const core_1 = __nccwpck_require__(37117); const execa_1 = __nccwpck_require__(30580); const util_2 = __nccwpck_require__(50914); async function bump() { - // before bump const version = await (0, util_2.getNextVersion)(); (0, core_1.info)(`bumping to version ${version}`); - process.env.NEXT_PACKAGE_VERSION = version; - (0, core_1.info)('executing before bump scripts'); - await executeCustomScript((0, core_1.getInput)('before-bump')); + (0, core_1.setOutput)('version', version); (0, core_1.info)('updating root package.json'); await updateRootPackageJson(version); (0, core_1.info)('setting version'); // abstract from different package managers await (0, execa_1.command)('node_modules/@changesets/cli/bin.js version'); - // after bump - (0, core_1.info)('executing after bump scripts'); - await executeCustomScript((0, core_1.getInput)('after-bump')); } async function updateRootPackageJson(version) { await (0, util_2.transformFile)((0, path_1.resolve)('package.json'), packageJson => (0, util_1.formatJson)({ @@ -89084,15 +89078,6 @@ async function updateRootPackageJson(version) { version: `${version}` })); } -async function executeCustomScript(script) { - if (script) { - const commands = script.split('\n'); - for (const cmd of commands) { - (0, core_1.info)(`executing custom script: ${cmd}`); - await (0, execa_1.command)(cmd); - } - } -} bump(); })(); diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index be89357e09..6c95b62cf7 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -30,16 +30,15 @@ jobs: run: | git config --global user.email "cloud-sdk-js@github.com" git config --global user.name "cloud-sdk-js" - # - name: Bump version - # run: yarn run version - name: Bump version + id: bump uses: ./.github/actions/changesets-fixed-version-bump - with: - before-bump: yarn ts-node ${{ github.workspace }}/scripts/before-bump.ts - after-bump: | - yarn generate - yarn doc - + - run: | + yarn ts-node ${{ github.workspace }}/scripts/update-documentation-md.ts + yarn generate + yarn doc + env: + NEXT_PACKAGE_VERSION: ${{ steps.bump.outputs.version }} - id: get-workspaces run: | workspaces=`yarn -s ts-node ${{ github.workspace }}/scripts/get-workspaces.ts` @@ -57,4 +56,4 @@ jobs: - name: Commit and tag uses: ./.github/actions/commit-and-tag with: - version: ${{ steps.merge-changelogs.outputs.changelog }} + version: ${{ steps.bump.outputs.version }} diff --git a/build-packages/changesets-fixed-version-bump/index.ts b/build-packages/changesets-fixed-version-bump/index.ts index 31ac2ae35e..1bcdae5b0f 100644 --- a/build-packages/changesets-fixed-version-bump/index.ts +++ b/build-packages/changesets-fixed-version-bump/index.ts @@ -1,27 +1,20 @@ /* eslint-disable jsdoc/require-jsdoc */ import { resolve } from 'path'; import { formatJson } from '@sap-cloud-sdk/util'; -import { getInput, info } from '@actions/core'; +import { info, setOutput } from '@actions/core'; import { command } from 'execa'; import { transformFile, getNextVersion } from './util'; async function bump() { - // before bump const version = await getNextVersion(); info(`bumping to version ${version}`); - process.env.NEXT_PACKAGE_VERSION = version; - info('executing before bump scripts'); - await executeCustomScript(getInput('before-bump')); + setOutput('version', version); info('updating root package.json'); await updateRootPackageJson(version); info('setting version'); // abstract from different package managers await command('node_modules/@changesets/cli/bin.js version'); - - // after bump - info('executing after bump scripts'); - await executeCustomScript(getInput('after-bump')); } async function updateRootPackageJson(version: string) { @@ -33,14 +26,4 @@ async function updateRootPackageJson(version: string) { ); } -async function executeCustomScript(script: string) { - if (script) { - const commands = script.split('\n'); - for (const cmd of commands) { - info(`executing custom script: ${cmd}`); - await command(cmd); - } - } -} - bump(); diff --git a/scripts/before-bump.ts b/scripts/before-bump.ts deleted file mode 100644 index 9a7e97900b..0000000000 --- a/scripts/before-bump.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { resolve } from 'path'; -import { unixEOL } from '@sap-cloud-sdk/util'; -import { transformFile } from './util'; - -async function updateDocumentationMd(version: string) { - await transformFile(resolve('DOCUMENTATION.md'), documentation => - documentation - .split(unixEOL) - .map(line => - line.startsWith('## Version:') ? `## Version: ${version}` : line - ) - .join(unixEOL) - ); -} - -async function beforeBump() { - console.log('calling before bump', process.env.NEXT_PACKAGE_VERSION); - if (process.env.NEXT_PACKAGE_VERSION) { - return updateDocumentationMd(process.env.NEXT_PACKAGE_VERSION); - } - throw new Error('NEXT_PACKAGE_VERSION is not set!'); -} - -beforeBump(); diff --git a/scripts/update-documentation-md.ts b/scripts/update-documentation-md.ts new file mode 100644 index 0000000000..d1fe7ea1c7 --- /dev/null +++ b/scripts/update-documentation-md.ts @@ -0,0 +1,25 @@ +import { resolve } from 'node:path'; +import { unixEOL } from '@sap-cloud-sdk/util'; +import { transformFile } from './util'; +import { exit } from 'node:process'; + +async function updateDocumentationMd() { + if (!process.env.NEXT_PACKAGE_VERSION) { + throw new Error('NEXT_PACKAGE_VERSION is not set!'); + } + await transformFile(resolve('DOCUMENTATION.md'), documentation => + documentation + .split(unixEOL) + .map(line => + line.startsWith('## Version:') + ? `## Version: ${process.env.NEXT_PACKAGE_VERSION}` + : line + ) + .join(unixEOL) + ); +} + +updateDocumentationMd().catch(err => { + console.error(err); + exit(1); +});