chore(release): separate version from build (#3441)
This commit is contained in:
parent
828690cd3b
commit
008fa5b715
@ -157,6 +157,9 @@ jobs:
|
||||
- ~/.cache ## Cache yarn and Cypress
|
||||
key: yarn-packages-{{ checksum "yarn.lock" }}
|
||||
# Build & Test
|
||||
- run:
|
||||
name: 'Perform the versioning before build'
|
||||
command: node ../version.mjs
|
||||
- run:
|
||||
name: 'Build the OHIF Viewer'
|
||||
command: yarn run build
|
||||
@ -273,8 +276,18 @@ jobs:
|
||||
name: Authenticate with NPM registry
|
||||
command:
|
||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
|
||||
- run: yarn run build:package-all
|
||||
- run: yarn run lerna:customVersion
|
||||
- run:
|
||||
name: Increase the event emitter limit
|
||||
command: |
|
||||
node ../increaseEventEmitterLimit.mjs
|
||||
- run:
|
||||
name: build all packages
|
||||
command: |
|
||||
yarn run build:package-all
|
||||
- run:
|
||||
name: version and publish all packages
|
||||
command: |
|
||||
node ../publish.mjs
|
||||
|
||||
DOCKER_RELEASE_PUBLISH:
|
||||
<<: *defaults
|
||||
|
||||
5
increaseEventEmitterLimit.mjs
Normal file
5
increaseEventEmitterLimit.mjs
Normal file
@ -0,0 +1,5 @@
|
||||
// increase the event emitter limit
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
EventEmitter.defaultMaxListeners = 25;
|
||||
@ -55,6 +55,7 @@ Certain scenarios can make the migration process more complex and potentially in
|
||||
OHIF v3 is a major re-architecture of the OHIF v2 to make it more modular and
|
||||
easier to maintain. The main differences are:
|
||||
|
||||
- platform/viewer (@ohif/viewer) has been renamed to platform/app (@ohif/app) (explanation below)
|
||||
- Extensions are available to be used by modes on request, but are still injected as module components.
|
||||
- To use the modules provided by the extensions, you need to write a [Mode](./platform/modes/index.md). Modes
|
||||
are configuration objects that will be used by the viewer to load the modules. This lets users to be able to use common extensions with different configurations, and enhances the customizability of the viewer.
|
||||
@ -78,6 +79,13 @@ New significant additions that might be useful for you that weren't available in
|
||||
- [Hanging Protocols](./platform/services/data/HangingProtocolService.md)
|
||||
- [URL Params](./configuration/url.md)
|
||||
|
||||
## Platform/viewer (@ohif/viewer) -> platform/app (@ohif/app)
|
||||
|
||||
|
||||
To ensure proper versioning of OHIF v3, we have made a decision to rename the platform/viewer to platform/app. Previously, the platform/viewer package followed software engineering versioning (currently at v4.12.51). However, going forward, we aim to align the versioning of platform/app with the product version (e.g., v3.4.0, v3.5.0, etc.).
|
||||
|
||||
Since the platform/viewer (@ohif/viewer) is already at v4.12.51, we opted to rename it as platform/app to enable versioning in accordance with the product versioning approach. If you were utilizing any exports from @ohif/viewer, please update them to use @ohif/app instead.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
127
publish.mjs
Normal file
127
publish.mjs
Normal file
@ -0,0 +1,127 @@
|
||||
import { execa } from 'execa';
|
||||
import fs from 'fs/promises';
|
||||
import glob from 'glob';
|
||||
import path from 'path';
|
||||
|
||||
async function run() {
|
||||
const { stdout: branchName } = await execa('git', [
|
||||
'rev-parse',
|
||||
'--abbrev-ref',
|
||||
'HEAD',
|
||||
]);
|
||||
console.log('Current branch:', branchName);
|
||||
const lernaJson = JSON.parse(await fs.readFile('lerna.json', 'utf-8'));
|
||||
|
||||
// read the current version from ./version.txt
|
||||
const nextVersion = await fs.readFile('./version.txt', 'utf-8');
|
||||
const packages = lernaJson.packages;
|
||||
|
||||
if (!packages) {
|
||||
throw new Error('Could not find packages in lerna.json');
|
||||
}
|
||||
|
||||
// for each package's package.json file, see if there is a peerdependency,
|
||||
// and for each peer dependency see if it includes a package that
|
||||
// starts with @ohif/, if so update the version to the
|
||||
// next version since lerna will not handle this for us
|
||||
|
||||
// Iterate over each package path pattern
|
||||
for (const packagePathPattern of packages) {
|
||||
// Use glob to find all matching directories
|
||||
const matchingDirectories = glob.sync(packagePathPattern);
|
||||
|
||||
for (const packageDirectory of matchingDirectories) {
|
||||
const packageJsonPath = path.join(packageDirectory, 'package.json');
|
||||
|
||||
try {
|
||||
const packageJson = JSON.parse(
|
||||
await fs.readFile(packageJsonPath, 'utf-8')
|
||||
);
|
||||
|
||||
if (!packageJson.peerDependencies) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const peerDependency of Object.keys(
|
||||
packageJson.peerDependencies
|
||||
)) {
|
||||
if (peerDependency.startsWith('@ohif/')) {
|
||||
packageJson.peerDependencies[peerDependency] = nextVersion;
|
||||
|
||||
console.log(
|
||||
'updating peerdependency to ',
|
||||
packageJson.peerDependencies[peerDependency]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await fs.writeFile(
|
||||
packageJsonPath,
|
||||
JSON.stringify(packageJson, null, 2) + '\n'
|
||||
);
|
||||
|
||||
console.log(`Updated ${packageJsonPath}`);
|
||||
} catch (err) {
|
||||
// This could be a directory without a package.json file. Ignore and continue.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Todo: Do we really need to run the build command here?
|
||||
// Maybe we need to hook the netlify deploy preview
|
||||
// await execa('yarn', ['run', 'build']);
|
||||
// console.log('Build command completed');
|
||||
console.log('Committing and pushing changes...');
|
||||
await execa('git', ['add', '-A']);
|
||||
await execa('git', [
|
||||
'commit',
|
||||
'-m',
|
||||
'chore(version): version.json [skip ci]',
|
||||
]);
|
||||
await execa('git', ['push', 'origin', branchName]);
|
||||
|
||||
console.log('Setting the version using lerna...');
|
||||
|
||||
// add a message to the commit to indicate that the version was set using lerna
|
||||
await execa('npx', [
|
||||
'lerna',
|
||||
'version',
|
||||
nextVersion,
|
||||
'--yes',
|
||||
'--exact',
|
||||
'--force-publish',
|
||||
'--message',
|
||||
'chore(version): Update package versions [skip ci]',
|
||||
]);
|
||||
console.log('Version set using lerna');
|
||||
|
||||
// Publishing each package, if on master/main branch publish beta versions
|
||||
// otherwise publish latest
|
||||
if (branchName === 'release') {
|
||||
await execa('npx', [
|
||||
'lerna',
|
||||
'publish',
|
||||
'from-package',
|
||||
'--no-verify-access',
|
||||
'--yes',
|
||||
]);
|
||||
} else {
|
||||
await execa('npx', [
|
||||
'lerna',
|
||||
'publish',
|
||||
'from-package',
|
||||
'--no-verify-access',
|
||||
'--yes',
|
||||
'--dist-tag',
|
||||
'beta',
|
||||
]);
|
||||
}
|
||||
|
||||
console.log('Finished');
|
||||
}
|
||||
|
||||
run().catch(err => {
|
||||
console.error('Error encountered during version bump:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
110
version.mjs
110
version.mjs
@ -1,8 +1,6 @@
|
||||
import { execa } from 'execa';
|
||||
import semver from 'semver';
|
||||
import fs from 'fs/promises';
|
||||
import glob from 'glob';
|
||||
import path from 'path';
|
||||
|
||||
async function run() {
|
||||
const { stdout: branchName } = await execa('git', [
|
||||
@ -74,114 +72,6 @@ async function run() {
|
||||
await fs.writeFile('./commit.txt', versionInfo.commit);
|
||||
|
||||
console.log('Version info saved to version.json');
|
||||
|
||||
// Read the packages from the lerna.json file
|
||||
const packages = lernaJson.packages;
|
||||
|
||||
if (!packages) {
|
||||
throw new Error('Could not find packages in lerna.json');
|
||||
}
|
||||
|
||||
// for each package's package.json file, see if there is a peerdependency,
|
||||
// and for each peer dependency see if it includes a package that
|
||||
// starts with @ohif/, if so update the version to the
|
||||
// next version since lerna will not handle this for us
|
||||
|
||||
// Iterate over each package path pattern
|
||||
for (const packagePathPattern of packages) {
|
||||
// Use glob to find all matching directories
|
||||
const matchingDirectories = glob.sync(packagePathPattern);
|
||||
|
||||
for (const packageDirectory of matchingDirectories) {
|
||||
const packageJsonPath = path.join(packageDirectory, 'package.json');
|
||||
|
||||
try {
|
||||
const packageJson = JSON.parse(
|
||||
await fs.readFile(packageJsonPath, 'utf-8')
|
||||
);
|
||||
|
||||
if (!packageJson.peerDependencies) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const peerDependency of Object.keys(
|
||||
packageJson.peerDependencies
|
||||
)) {
|
||||
if (peerDependency.startsWith('@ohif/')) {
|
||||
packageJson.peerDependencies[peerDependency] = nextVersion;
|
||||
|
||||
console.log(
|
||||
'updating peerdependency to ',
|
||||
packageJson.peerDependencies[peerDependency]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await fs.writeFile(
|
||||
packageJsonPath,
|
||||
JSON.stringify(packageJson, null, 2) + '\n'
|
||||
);
|
||||
|
||||
console.log(`Updated ${packageJsonPath}`);
|
||||
} catch (err) {
|
||||
// This could be a directory without a package.json file. Ignore and continue.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Todo: Do we really need to run the build command here?
|
||||
// Maybe we need to hook the netlify deploy preview
|
||||
// await execa('yarn', ['run', 'build']);
|
||||
// console.log('Build command completed');
|
||||
|
||||
console.log('Committing and pushing changes...');
|
||||
await execa('git', ['add', '-A']);
|
||||
await execa('git', [
|
||||
'commit',
|
||||
'-m',
|
||||
'chore(version): version.json [skip ci]',
|
||||
]);
|
||||
await execa('git', ['push', 'origin', branchName]);
|
||||
|
||||
console.log('Setting the version using lerna...');
|
||||
|
||||
// add a message to the commit to indicate that the version was set using lerna
|
||||
await execa('npx', [
|
||||
'lerna',
|
||||
'version',
|
||||
nextVersion,
|
||||
'--yes',
|
||||
'--exact',
|
||||
'--force-publish',
|
||||
'--message',
|
||||
'chore(version): Update package versions [skip ci]',
|
||||
]);
|
||||
console.log('Version set using lerna');
|
||||
|
||||
// Publishing each package, if on master/main branch publish beta versions
|
||||
// otherwise publish latest
|
||||
if (branchName === 'release') {
|
||||
await execa('npx', [
|
||||
'lerna',
|
||||
'publish',
|
||||
'from-package',
|
||||
'--no-verify-access',
|
||||
'--yes',
|
||||
]);
|
||||
} else {
|
||||
await execa('npx', [
|
||||
'lerna',
|
||||
'publish',
|
||||
'from-package',
|
||||
'--no-verify-access',
|
||||
'--yes',
|
||||
'--dist-tag',
|
||||
'beta',
|
||||
]);
|
||||
}
|
||||
|
||||
console.log('Finished');
|
||||
}
|
||||
|
||||
run().catch(err => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user