Skip to content

Commit

Permalink
feat: Always release when on release branch, enable use of env variab…
Browse files Browse the repository at this point in the history
…les in release templates
  • Loading branch information
Moritz Schmitz von Hülst committed Sep 2, 2021
1 parent b2f3e9c commit 3d6d1f0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ interface Config {
networkConcurrency?: number;

/**
* indicates if a new release created in jira should be set as released
* Indicates if a new release created in jira should be set as released. `true` if the branch is not a prerelease
*/
released?: boolean;
/**
* include the release date when creating a release in jira
* Include the release date when creating a release in jira
*/
setReleaseDate?: boolean;
}
Expand Down
12 changes: 8 additions & 4 deletions lib/success.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ async function findOrCreateVersion(config: PluginConfig, context: GenerateNotesC
} as any;
} else {
const descriptionText = description || '';
newVersion = await jira.projectVersions.createVersion({
const parameters = {
name,
projectId: project.id as any,
description: descriptionText,
released: Boolean(config.released),
releaseDate: config.setReleaseDate ? (new Date().toISOString()) : undefined,
});
};
if (!parameters.released && typeof context.branch !== 'string') {
parameters.released = !context.branch.prerelease;
}
newVersion = await jira.projectVersions.createVersion(parameters);
}

context.logger.info(`Made new release '${newVersion.id}'`);
Expand Down Expand Up @@ -103,10 +107,10 @@ export async function success(config: PluginConfig, context: GenerateNotesContex
context.logger.info(`Found ticket ${tickets.join(', ')}`);

const versionTemplate = _.template(config.releaseNameTemplate ?? DEFAULT_VERSION_TEMPLATE);
const newVersionName = versionTemplate({ version: context.nextRelease.version });
const newVersionName = versionTemplate({ version: context.nextRelease.version, env: context.env });

const descriptionTemplate = _.template(config.releaseDescriptionTemplate ?? DEFAULT_RELEASE_DESCRIPTION_TEMPLATE);
const newVersionDescription = descriptionTemplate({ version: context.nextRelease.version, notes: context.nextRelease.notes });
const newVersionDescription = descriptionTemplate({ version: context.nextRelease.version, notes: context.nextRelease.notes, env: context.env });

context.logger.info(`Using jira release '${newVersionName}'`);

Expand Down
2 changes: 2 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BranchSpec } from 'semantic-release';
import { Signale } from 'signale';

export interface PluginContext {
Expand All @@ -9,6 +10,7 @@ export interface PluginContext {
options: BaseConfig;
stderr: typeof process.stderr;
stdout: typeof process.stdout;
branch: BranchSpec;
}

export interface Person {
Expand Down
26 changes: 23 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@types/jest": "^27.0.1",
"@types/lodash": "^4.14.172",
"@types/node": "^16.7.10",
"@types/semantic-release": "^17.2.1",
"@types/signale": "^1.4.2",
"jest": "^27.1.0",
"madge": "^5.0.1",
Expand Down

0 comments on commit 3d6d1f0

Please sign in to comment.