Skip to content

Commit

Permalink
fix: patch version with semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewPattell committed Jun 6, 2023
1 parent 23e45f4 commit a989df4
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,33 @@ const runSemanticRelease = (isDryRun = false) => {
childProcess.execSync(`npx semantic-release ${isDryRun ? '--dryRun' : ''}`, {
stdio: 'inherit',
cwd: msDir,
env: {
...process.env,
SEMANTIC_WORKING_DIR: msDir,
SEMANTIC_ROOT_DIR: rootDir,
},
env: { ...process.env },
});

console.info(chalk.green(`Semantic release done: ${msDir}`));
let nextVersion = 'unknown';

try {
const versionFile = findFile(['.version'], `${rootDir}/${msDir}`);

if (!versionFile) {
throw new Error("Package file version doesn't exist.");
}

nextVersion = (fs.readFileSync(versionFile, { encoding: 'utf-8' }) || '').trim();

if (!nextVersion) {
throw new Error('Package version is empty.');
}

childProcess.execSync(`npx @lomray/microservices-cli patch-package-version --package-version ${nextVersion} --dir ${msDir}`, {
stdio: 'inherit',
env: { ...process.env },
});
} catch (e) {
console.info(chalk.yellow(`Failed get package version: ${e.message}`));
}

console.info(chalk.green(`Semantic release done: ${msDir}. Version: ${nextVersion}`));
}
};

Expand Down

0 comments on commit a989df4

Please sign in to comment.