Skip to content

Commit

Permalink
feat: add support for external increment management
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-de-Jong committed Aug 31, 2023
1 parent 39af284 commit e55ef7f
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 66 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
| `files` | NO | Multiline list of files (paths) to upload as a [GitHub Release asset](./docs/asset-management.md) |
| `versioning` | NO | [Versioning strategy](#versioning-strategies) to apply. MUST be one of `semver` or `calver`. Default: `semver` |
| `release-notes` | NO | Path towards a file containing the release notes to include in the GitHub release (Markdown format recommended) |
| `increment-type` | NO | Enforce a specific increment type, please refer to the [Versioning Strategies](./docs/versioning-strategies.md) for more details |

## Outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ inputs:
description: 'External Release Notes file to include in the GitHub Release'
required: false

increment-type:
description: 'Increment type to apply to the version'
required: false

outputs:
created:
description: 'Boolean indicating if a release was created'
Expand Down
103 changes: 89 additions & 14 deletions lib/get/index.js

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

138 changes: 113 additions & 25 deletions lib/main/index.js

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

38 changes: 25 additions & 13 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,38 @@ export async function run(): Promise<void> {
latestVersion = versionScheme.initialVersion();
}

const delta = await releasing.getChangesSince(latestRef);
core.info(`ℹ️ Changes since: ${delta.length} commits`);

const commits = filterConventionalCommits(delta);
core.info(`ℹ️ Conventional Commits since: ${commits.length} commits`);
const increments: versioning.VersionIncrement[] = [];
const commits: commitLib.IConventionalCommit[] = [];
if (core.getInput("increment-type")) {
increments.push(...core.getInput("increment-type").split("|").map(inc => versioning.getIncrementType(versionScheme, inc)));
} else {
const delta = await releasing.getChangesSince(latestRef);
core.info(`ℹ️ Changes since: ${delta.length} commits`);

commits.push(...filterConventionalCommits(delta));
core.info(`ℹ️ Conventional Commits since: ${commits.length} commits`);

const increment = versionScheme.determineIncrementType(commits)
if (increment === undefined) {
core.info("⚠️ No increment required, skipping...");
core.endGroup();
return;
}
increments.push(increment);
}
core.endGroup();

const increment = versionScheme.determineIncrementType(commits);
core.setOutput("previous-version", latestVersion.toString());
const newVersion = versioning.incrementVersion(latestVersion, increments);
core.setOutput("incremented-version", newVersion.toString());

if (increment === undefined) {
core.info("⚠️ No increment required, skipping...");
core.endGroup();
if (!core.getBooleanInput("create-release")) {
return;
}
core.endGroup();

const newVersion = versioning.incrementVersion(latestVersion, increment);

core.startGroup(`📦 Creating GitHub Release...`);

const body = core.getInput("release-notes", undefined)
const body = core.getInput("release-notes")
? await changelog.readChangelogFromFile(core.getInput("release-notes"))
: await changelog.generateChangelog(versionScheme, commits);

Expand Down
Loading

0 comments on commit e55ef7f

Please sign in to comment.