semantic-release-monorepo
semantic-release-monorepo copied to clipboard
[Feature] allow customizing the monorepo tag format injected in `context.nextRelease`
Hi @pmowrer
First of all, thanks for this awesome project! Exactly what I was looking for to release my Nx-based monorepo (https://github.com/tinesoft/nxrocks).
Is it possible to allow customizing the default monorepo tag format injected in context.nextRelease
? (currently it is <package-name>-v-<version>
)
In my case, one of the packages in the monorepo is named: @nxrocks/nx-spring-boot
. So the plugin
renders @nxrocks/nx-spring-boot-v-<version>
, while I would like simply nx-spring-boot/v-<version>
...
With the global tagFormat
I was able to change the name of the created tag, but this name is not applied everywhere, in particular not in the context.nextRelease.version
. Instead, the default format is picked up by the other plugins like @semantic-release/release-notes-generator
.
Here is a sample: https://github.com/tinesoft/nxrocks/releases/tag/nx-spring-boot%2Fv2.0.0-beta.1
I believe it is because the default monorepo tag format is hardcoded here: https://github.com/pmowrer/semantic-release-monorepo/blob/413a5702f2381365526fe8928cf56781ea156ddf/src/version-to-git-tag.js#L9
the name
is read from the package via const { name } = await readPkg();
An option could be added to allow customizing it.
This is what my .releaserc
file looks like:
{
extends: 'semantic-release-monorepo',
preset: 'angular',
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/changelog',
'@semantic-release/github',
['@semantic-release/npm', { pkgRoot: relativeBuildOutput }],
[
'@semantic-release/exec',
{
prepareCmd: [
formatFile(`${projectRoot}/CHANGELOG.md`),
copyFile(`${projectRoot}/CHANGELOG.md`, buildOutput),
copyFile(`${projectRoot}/README.md`, buildOutput),
copyFile(`LICENSE`, buildOutput),
].join(' && '),
execCwd: relativeWorkspaceRoot,
},
],
[
'@semantic-release/git',
{
message: releaseCommit,
},
],
],
tagFormat: `${projectScope}/v\${version}` // note: projectScope is dynamically injected
}