Skip to content

Commit

Permalink
bcv
Browse files Browse the repository at this point in the history
  • Loading branch information
marikaner committed Sep 12, 2024
1 parent b66edd7 commit d3bce12
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 77 deletions.
11 changes: 2 additions & 9 deletions .github/actions/changesets-fixed-version-bump/action.yml
Original file line number Diff line number Diff line change
@@ -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'
17 changes: 1 addition & 16 deletions .github/actions/changesets-fixed-version-bump/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ jobs:
run: |
git config --global user.email "[email protected]"
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`
Expand All @@ -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 }}
21 changes: 2 additions & 19 deletions build-packages/changesets-fixed-version-bump/index.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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();
24 changes: 0 additions & 24 deletions scripts/before-bump.ts

This file was deleted.

25 changes: 25 additions & 0 deletions scripts/update-documentation-md.ts
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit d3bce12

Please sign in to comment.