diff --git a/dist/index.js b/dist/index.js index 0d87e2478..9e367a8d0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -129344,12 +129344,16 @@ const generateReleaseInfo = ({ if (tag === undefined) { tag = versionInfo ? template(config['tag-template'] || '', versionInfo) : '' + } else if (versionInfo) { + tag = template(tag, versionInfo) } if (name === undefined) { name = versionInfo ? template(config['name-template'] || '', versionInfo) : '' + } else if (versionInfo) { + name = template(name, versionInfo) } if (commitish === undefined) { diff --git a/lib/releases.js b/lib/releases.js index d251ac193..1022c4b80 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -306,12 +306,16 @@ const generateReleaseInfo = ({ if (tag === undefined) { tag = versionInfo ? template(config['tag-template'] || '', versionInfo) : '' + } else if (versionInfo) { + tag = template(tag, versionInfo) } if (name === undefined) { name = versionInfo ? template(config['name-template'] || '', versionInfo) : '' + } else if (versionInfo) { + name = template(name, versionInfo) } if (commitish === undefined) { diff --git a/test/fixtures/config/config-with-name-and-tag-template.yml b/test/fixtures/config/config-with-name-and-tag-template.yml new file mode 100644 index 000000000..daef573eb --- /dev/null +++ b/test/fixtures/config/config-with-name-and-tag-template.yml @@ -0,0 +1,3 @@ +template: Placeholder with example. Automatically calculated values based on previous releases are next major=$NEXT_MAJOR_VERSION, minor=$NEXT_MINOR_VERSION, patch=$NEXT_PATCH_VERSION. +name-template: 'v$RESOLVED_VERSION-beta (Code name: Hello World)' +tag-template: v$RESOLVED_VERSION-beta diff --git a/test/index.test.js b/test/index.test.js index 106793605..381310591 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -2149,6 +2149,23 @@ describe('release-drafter', () => { }) }) + describe('with just the tag containing variables', () => { + it('gets the version from the tag and expands variables in it', async () => { + return overridesTest( + { + tag: 'v$RESOLVED_VERSION-RC1', + configName: 'config-with-name-and-tag-template.yml', + }, + { + body: `Placeholder with example. Automatically calculated values based on previous releases are next major=3.0.0, minor=2.1.0, patch=2.0.1.`, + draft: true, + name: 'v1.0.0-beta (Code name: Hello World)', + tag_name: 'v1.0.0-RC1', + } + ) + }) + }) + describe('with just the name', () => { it('gets the version from the name and forces using the name', async () => { return overridesTest( @@ -2163,6 +2180,23 @@ describe('release-drafter', () => { }) }) + describe('with just the name containing variables', () => { + it('gets the version from the name and expands variables in it', async () => { + return overridesTest( + { + name: 'v$RESOLVED_VERSION-RC1 (Code name: Hello World)', + configName: 'config-with-name-and-tag-template.yml', + }, + { + body: `Placeholder with example. Automatically calculated values based on previous releases are next major=3.0.0, minor=2.1.0, patch=2.0.1.`, + draft: true, + name: 'v1.0.0-RC1 (Code name: Hello World)', + tag_name: 'v1.0.0-beta', + } + ) + }) + }) + describe('with publish: true', () => { it('immediately publishes the created draft', async () => { return overridesTest(