Skip to content

Commit a989df4

Browse files
fix: patch version with semantic release
1 parent 23e45f4 commit a989df4

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

index.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,33 @@ const runSemanticRelease = (isDryRun = false) => {
330330
childProcess.execSync(`npx semantic-release ${isDryRun ? '--dryRun' : ''}`, {
331331
stdio: 'inherit',
332332
cwd: msDir,
333-
env: {
334-
...process.env,
335-
SEMANTIC_WORKING_DIR: msDir,
336-
SEMANTIC_ROOT_DIR: rootDir,
337-
},
333+
env: { ...process.env },
338334
});
339335

340-
console.info(chalk.green(`Semantic release done: ${msDir}`));
336+
let nextVersion = 'unknown';
337+
338+
try {
339+
const versionFile = findFile(['.version'], `${rootDir}/${msDir}`);
340+
341+
if (!versionFile) {
342+
throw new Error("Package file version doesn't exist.");
343+
}
344+
345+
nextVersion = (fs.readFileSync(versionFile, { encoding: 'utf-8' }) || '').trim();
346+
347+
if (!nextVersion) {
348+
throw new Error('Package version is empty.');
349+
}
350+
351+
childProcess.execSync(`npx @lomray/microservices-cli patch-package-version --package-version ${nextVersion} --dir ${msDir}`, {
352+
stdio: 'inherit',
353+
env: { ...process.env },
354+
});
355+
} catch (e) {
356+
console.info(chalk.yellow(`Failed get package version: ${e.message}`));
357+
}
358+
359+
console.info(chalk.green(`Semantic release done: ${msDir}. Version: ${nextVersion}`));
341360
}
342361
};
343362

0 commit comments

Comments
 (0)