a4f52386ba
CD / Release (push) Successful in 42s
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [conventional-commits-parser](https://conventional-changelog.js.org/commits-parser/) ([source](https://github.com/conventional-changelog/conventional-changelog/tree/HEAD/packages/conventional-commits-parser)) | [`3.2.4` → `7.1.1`](https://renovatebot.com/diffs/npm/conventional-commits-parser/3.2.4/7.1.1) |  |  | --- ### Release Notes <details> <summary>conventional-changelog/conventional-changelog (conventional-commits-parser)</summary> ### [`v7.1.1`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#711-2026-07-26) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v7.1.0...conventional-commits-parser-v7.1.1) ##### Bug Fixes - do not treat indented lines as footers ([#​1513](https://github.com/conventional-changelog/conventional-changelog/issues/1513)) ([c01c3c4](https://github.com/conventional-changelog/conventional-changelog/commit/c01c3c477ea350cabb43eae13dab965a0dc54b29)), closes [#​1512](https://github.com/conventional-changelog/conventional-changelog/issues/1512) ### [`v7.1.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#710-2026-07-09) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v7.0.1...conventional-commits-parser-v7.1.0) ##### Features - replace `meow` with `argue-cli` ([#​1505](https://github.com/conventional-changelog/conventional-changelog/issues/1505)) ([1ad6177](https://github.com/conventional-changelog/conventional-changelog/commit/1ad6177da0b9da2df4fffc41e0b6caf9b76bf200)) ### [`v7.0.1`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#701-2026-07-04) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v7.0.0...conventional-commits-parser-v7.0.1) ##### Bug Fixes - point package homepages and docs to documentation website ([04796e2](https://github.com/conventional-changelog/conventional-changelog/commit/04796e22a649a14647feea99b445df2eb1c3acad)) ### [`v7.0.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#700-2026-06-26) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v6.4.0...conventional-commits-parser-v7.0.0) ##### ⚠ BREAKING CHANGES - packages now require Node.js 22 or newer. ##### Features - require node 22 ([de5e136](https://github.com/conventional-changelog/conventional-changelog/commit/de5e1368096ea0805e51e20df587ce528ca0575b)) ##### Bug Fixes - keep footers out of breaking notes ([#​1485](https://github.com/conventional-changelog/conventional-changelog/issues/1485)) ([f9195d5](https://github.com/conventional-changelog/conventional-changelog/commit/f9195d5d27642599a7737d46f98fe5f8be57dc48)) ### [`v6.4.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#640-2026-03-29) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v6.3.0...conventional-commits-parser-v6.4.0) ##### Features - support RegExp in noteKeywords, issuePrefixes, and referenceActions ([#​1441](https://github.com/conventional-changelog/conventional-changelog/issues/1441)) ([f84bfc4](https://github.com/conventional-changelog/conventional-changelog/commit/f84bfc4cc8656d6c70d40ba3a4f35161ba9a2cf9)), closes [#​1436](https://github.com/conventional-changelog/conventional-changelog/issues/1436) ### [`v6.3.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#630-2026-03-01) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v6.2.1...conventional-commits-parser-v6.3.0) ##### Features - use utils from simple-libs ([#​1432](https://github.com/conventional-changelog/conventional-changelog/issues/1432)) ([7d27d06](https://github.com/conventional-changelog/conventional-changelog/commit/7d27d0673878b995e9c0c82641d9d70eb9561024)) ##### Bug Fixes - deduplicate references when the same issue appears multiple times ([#​1425](https://github.com/conventional-changelog/conventional-changelog/issues/1425)) ([836ac77](https://github.com/conventional-changelog/conventional-changelog/commit/836ac77b4164e4c3708e709aea44ef62556fab99)) - default gitlab revert message does not use a final dot in commit message. ([#​1422](https://github.com/conventional-changelog/conventional-changelog/issues/1422)) ([7391edf](https://github.com/conventional-changelog/conventional-changelog/commit/7391edf52cc1edf04f8946410ddb382c0e590aeb)) - escape special chars in tokens ([#​1418](https://github.com/conventional-changelog/conventional-changelog/issues/1418)) ([2536e21](https://github.com/conventional-changelog/conventional-changelog/commit/2536e2125c575548e8dde41d7b6ffaf4944dcb99)) ### [`v6.2.1`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#621-2025-10-20) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v6.2.0...conventional-commits-parser-v6.2.1) ##### Bug Fixes - support ClickUp-style issue IDs ending with letters ([#​1407](https://github.com/conventional-changelog/conventional-changelog/issues/1407)) ([557450b](https://github.com/conventional-changelog/conventional-changelog/commit/557450b85425f43cfc62176e85976eb98a752317)) ### [`v6.2.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#620-2025-06-09) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v6.1.0...conventional-commits-parser-v6.2.0) ##### Features - named capturing groups support for regex patterns ([#​1372](https://github.com/conventional-changelog/conventional-changelog/issues/1372)) ([a63c3f3](https://github.com/conventional-changelog/conventional-changelog/commit/a63c3f3102893d03b90e767bee220d72c1cefdcb)) ##### Bug Fixes - respect comment char while truncate to scissors ([#​1373](https://github.com/conventional-changelog/conventional-changelog/issues/1373)) ([a964ccc](https://github.com/conventional-changelog/conventional-changelog/commit/a964ccc23440805baa17c731fea707a10059d15a)) ### [`v6.1.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#610-2025-01-15) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v6.0.0...conventional-commits-parser-v6.1.0) ##### Features - **conventional-commits-parser:** allow @​ in scope part of the header ([#​1283](https://github.com/conventional-changelog/conventional-changelog/issues/1283)) ([d48c660](https://github.com/conventional-changelog/conventional-changelog/commit/d48c660e849868e0f014cb0634bc37b7b4086d49)) ##### Bug Fixes - **conventional-commits-parser:** give a possible 'header' merge pattern correspondence a priority over the next line ([#​1311](https://github.com/conventional-changelog/conventional-changelog/issues/1311)) ([373d330](https://github.com/conventional-changelog/conventional-changelog/commit/373d330c76c54de7b6214a27e5b1577b243ed029)) - **conventional-commits-parser:** ignore irrelevant references ([#​1288](https://github.com/conventional-changelog/conventional-changelog/issues/1288)) ([115d5d0](https://github.com/conventional-changelog/conventional-changelog/commit/115d5d0bcc10df793c6156d041fb9957314b4ccb)) ### [`v6.0.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#600-2024-04-26) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v5.0.0...conventional-commits-parser-v6.0.0) ##### ⚠ BREAKING CHANGES - Node >= 18 is required - **conventional-recommended-bump:** new `Bumper` exported class ([#​1218](https://github.com/conventional-changelog/conventional-changelog/issues/1218)) - **conventional-commits-filter:** rewrite to TypeScript ([#​1178](https://github.com/conventional-changelog/conventional-changelog/issues/1178)) - **conventional-commits-parser:** rewrite to TypeScript ([#​1126](https://github.com/conventional-changelog/conventional-changelog/issues/1126)) - Now all packages, except gulp-conventional-changelog, are ESM-only. - **git-semver-tags,conventional-recommended-bump:** gitSemverTags and conventionalRecommendedBump now return promises - **standard-changelog:** createIfMissing method now returns a promise ##### Features - **conventional-commits-filter:** rewrite to TypeScript ([#​1178](https://github.com/conventional-changelog/conventional-changelog/issues/1178)) ([e0c7b06](https://github.com/conventional-changelog/conventional-changelog/commit/e0c7b060202100ab82d858986ce43ba1b310d496)) - **conventional-commits-parser:** add parseCommits method to work with async iterables ([#​1180](https://github.com/conventional-changelog/conventional-changelog/issues/1180)) ([7ee67ec](https://github.com/conventional-changelog/conventional-changelog/commit/7ee67ec5602d052d62ed2072760fe29c98e5c36a)) - **conventional-commits-parser:** rewrite to TypeScript ([#​1126](https://github.com/conventional-changelog/conventional-changelog/issues/1126)) ([9e280d8](https://github.com/conventional-changelog/conventional-changelog/commit/9e280d89f33e2185643e2531edb668bd0e0df22c)) - **conventional-recommended-bump:** new `Bumper` exported class ([#​1218](https://github.com/conventional-changelog/conventional-changelog/issues/1218)) ([0ddc8cd](https://github.com/conventional-changelog/conventional-changelog/commit/0ddc8cdceb91f838f9f73e0bff8e3f140176a13a)) - drop node 16 support ([#​1226](https://github.com/conventional-changelog/conventional-changelog/issues/1226)) ([ec69cfd](https://github.com/conventional-changelog/conventional-changelog/commit/ec69cfdf0040f73ec0eadc4779c37874e71f3dff)) - **git-semver-tags,conventional-recommended-bump:** refactoring to use promises instead of callbacks ([#​1112](https://github.com/conventional-changelog/conventional-changelog/issues/1112)) ([1697ecd](https://github.com/conventional-changelog/conventional-changelog/commit/1697ecdf4c2329732e612cc1bd3323e84f046f3a)) - move from CommonJS to ESM ([#​1144](https://github.com/conventional-changelog/conventional-changelog/issues/1144)) ([c5b859d](https://github.com/conventional-changelog/conventional-changelog/commit/c5b859d201e124822002eb54574f003f074216e2)) - **standard-changelog:** use promises ([#​1111](https://github.com/conventional-changelog/conventional-changelog/issues/1111)) ([5015ab7](https://github.com/conventional-changelog/conventional-changelog/commit/5015ab71de7a3db9cbcbbabd0cc25502f1cd0109)) ##### Bug Fixes - **conventional-commits-parser:** parse header if subject includes ! to indicate breaking change ([#​1213](https://github.com/conventional-changelog/conventional-changelog/issues/1213)) ([30cfa82](https://github.com/conventional-changelog/conventional-changelog/commit/30cfa8276436415b994599ab55db3a723d136e03)) - **deps:** update dependency meow to v13 ([#​1190](https://github.com/conventional-changelog/conventional-changelog/issues/1190)) ([862f66b](https://github.com/conventional-changelog/conventional-changelog/commit/862f66ba99989af2d44a524b11bc3a873426b00b)) ### [`v5.0.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#500-2023-08-26) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v4.0.0...conventional-commits-parser-v5.0.0) ##### ⚠ BREAKING CHANGES - Node >= 16 is required ##### Features - drop node 14 support ([#​1085](https://github.com/conventional-changelog/conventional-changelog/issues/1085)) ([1bce036](https://github.com/conventional-changelog/conventional-changelog/commit/1bce0362dbb624a869eb01fd7724ab7f81d337e6)) ##### Bug Fixes - **deps:** update dependency is-text-path to v2 ([#​903](https://github.com/conventional-changelog/conventional-changelog/issues/903)) ([8568ee4](https://github.com/conventional-changelog/conventional-changelog/commit/8568ee4bcd66ceeb85444dc71342bcb2b11db9ca)) - **deps:** update dependency split2 to v4 ([#​1032](https://github.com/conventional-changelog/conventional-changelog/issues/1032)) ([d16ccc5](https://github.com/conventional-changelog/conventional-changelog/commit/d16ccc5df75f2c728417d20324b6eb6e746633ab)) - fix semver vulnerability ([#​1071](https://github.com/conventional-changelog/conventional-changelog/issues/1071)) ([3f5c99d](https://github.com/conventional-changelog/conventional-changelog/commit/3f5c99d503ea1bf01df679f4180c39516e190b21)), closes [#​1019](https://github.com/conventional-changelog/conventional-changelog/issues/1019) ### [`v4.0.0`](https://github.com/conventional-changelog/conventional-changelog/blob/HEAD/packages/conventional-commits-parser/CHANGELOG.md#400-2023-06-06) [Compare Source](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v3.2.4...conventional-commits-parser-v4.0.0) ##### ⚠ BREAKING CHANGES - Node >= 14 is required ##### Code Refactoring - drop lodash from dependencies where it possible ([#​959](https://github.com/conventional-changelog/conventional-changelog/issues/959)) ([a8b4e12](https://github.com/conventional-changelog/conventional-changelog/commit/a8b4e12883021231befc6bdfeb95a9b50637f361)) ##### [3.2.4](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v3.2.3...conventional-commits-parser-v3.2.4) (2021-12-29) ##### Bug Fixes - support BREAKING-CHANGE alongside BREAKING CHANGE ([#​882](https://github.com/conventional-changelog/conventional-changelog/issues/882)) ([e6f44ad](https://github.com/conventional-changelog/conventional-changelog/commit/e6f44adcf1ac5abbb85bdac73237c331c6594177)) ##### [3.2.3](https://www.github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v3.2.2...conventional-commits-parser-v3.2.3) (2021-10-23) ##### Bug Fixes - address ReDoS issue ([#​861](https://www.github.com/conventional-changelog/conventional-changelog/issues/861)) ([c696fa3](https://www.github.com/conventional-changelog/conventional-changelog/commit/c696fa35f93e0ee13728d6cf1221587ac6386311)) ##### [3.2.2](https://www.github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser-v3.2.1...conventional-commits-parser-v3.2.2) (2021-09-09) ##### Bug Fixes - **conventional-commits-parser:** address CVE-2021-23425 ([#​841](https://www.github.com/conventional-changelog/conventional-changelog/issues/841)) ([02b3d53](https://www.github.com/conventional-changelog/conventional-changelog/commit/02b3d53a0c142f0c28ee7d190d210c76a62887c2)) ##### [3.2.1](https://www.github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.2.0...v3.2.1) (2021-02-15) ##### Bug Fixes - handle missing header in merge commit ([#​757](https://www.github.com/conventional-changelog/conventional-changelog/issues/757)) ([d189d3e](https://www.github.com/conventional-changelog/conventional-changelog/commit/d189d3e45b82e7141115ce8eccd95c8cf2d7db77)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMzMuNCIsInVwZGF0ZWRJblZlciI6IjQzLjI2My45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBzIiwibnBtIl19--> --------- Co-authored-by: Timo Behrendt <t.behrendt@t00n.de> Reviewed-on: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment/pulls/84 Reviewed-by: t.behrendt <2+t.behrendt@noreply.localhost> Co-authored-by: Renovate Bot <renovate@t00n.de> Co-committed-by: Renovate Bot <renovate@t00n.de>
320 lines
9.5 KiB
TypeScript
320 lines
9.5 KiB
TypeScript
import * as core from "@actions/core";
|
|
import { CommitParser } from "conventional-commits-parser";
|
|
import type { Commit } from "conventional-commits-parser";
|
|
import { execSync } from "child_process";
|
|
|
|
export enum IncrementType {
|
|
MAJOR = "major",
|
|
MINOR = "minor",
|
|
PATCH = "patch",
|
|
}
|
|
|
|
export type Tag = {
|
|
major: number;
|
|
minor: number;
|
|
patch: number;
|
|
};
|
|
|
|
export interface GitService {
|
|
listTags(perPage: number): Promise<{ name: string }[]>;
|
|
getCommit(ref: string): Promise<{ commit: { message: string } }>;
|
|
testConnection(): Promise<void>;
|
|
}
|
|
|
|
export interface CoreService {
|
|
getInput(name: string): string;
|
|
info(message: string): void;
|
|
warning(message: string): void;
|
|
setOutput(name: string, value: string): void;
|
|
setFailed(message: string): void;
|
|
}
|
|
|
|
export class ConventionalCommitAnalyzer {
|
|
private commitParser = new CommitParser();
|
|
|
|
analyzeCommit(message: string): Commit {
|
|
return this.commitParser.parse(message);
|
|
}
|
|
|
|
determineIncrementType(analyzedCommit: Commit): IncrementType {
|
|
if (
|
|
analyzedCommit.breaking ||
|
|
analyzedCommit.header?.includes("!") ||
|
|
analyzedCommit.notes.some((note: any) => note.title === "BREAKING CHANGE")
|
|
) {
|
|
return IncrementType.MAJOR;
|
|
} else if (analyzedCommit.type === "feat") {
|
|
return IncrementType.MINOR;
|
|
} else {
|
|
return IncrementType.PATCH;
|
|
}
|
|
}
|
|
}
|
|
|
|
export class TagService {
|
|
bumpTag(tag: Tag, incrementType: IncrementType): Tag {
|
|
switch (incrementType) {
|
|
case IncrementType.MAJOR:
|
|
return {
|
|
major: tag.major + 1,
|
|
minor: 0,
|
|
patch: 0,
|
|
};
|
|
case IncrementType.MINOR:
|
|
return {
|
|
major: tag.major,
|
|
minor: tag.minor + 1,
|
|
patch: 0,
|
|
};
|
|
case IncrementType.PATCH:
|
|
return {
|
|
major: tag.major,
|
|
minor: tag.minor,
|
|
patch: tag.patch + 1,
|
|
};
|
|
}
|
|
}
|
|
|
|
renderTag(tag: Tag, prefix: string = "", prereleaseSuffix: string = ""): string {
|
|
return `${prefix}${tag.major}.${tag.minor}.${tag.patch}${prereleaseSuffix}`;
|
|
}
|
|
|
|
parseTag(tagString: string): Tag {
|
|
if (!/^v?\d+\.\d+\.\d+$/.test(tagString)) {
|
|
throw new Error(`Invalid tag format: ${tagString}. Expected semantic version (e.g., 1.2.3)`);
|
|
}
|
|
|
|
const versionMatch = tagString.match(/^v?(\d+)\.(\d+)\.(\d+)$/);
|
|
if (!versionMatch) {
|
|
throw new Error(`Could not parse version from tag: ${tagString}`);
|
|
}
|
|
|
|
return {
|
|
major: parseInt(versionMatch[1]),
|
|
minor: parseInt(versionMatch[2]),
|
|
patch: parseInt(versionMatch[3]),
|
|
};
|
|
}
|
|
}
|
|
|
|
export class TagIncrementer {
|
|
constructor(
|
|
private gitService: GitService,
|
|
private coreService: CoreService,
|
|
private commitAnalyzer: ConventionalCommitAnalyzer,
|
|
private tagService: TagService,
|
|
) {}
|
|
|
|
async getBaseTag(lastTag: string | undefined, maxTags: number = 50): Promise<string> {
|
|
if (lastTag) {
|
|
this.coreService.info(`Using provided tag: ${lastTag}`);
|
|
return lastTag;
|
|
}
|
|
|
|
this.coreService.info(`Fetching up to ${maxTags} tags from local repository`);
|
|
const tags = await this.gitService.listTags(maxTags);
|
|
|
|
if (tags.length === 0) {
|
|
this.coreService.warning("No tags found in repository, defaulting to 0.0.0");
|
|
return "0.0.0";
|
|
}
|
|
|
|
const realTags = tags.filter((tag) => !tag.name.includes("-rc-"));
|
|
|
|
if (realTags.length === 0) {
|
|
this.coreService.warning("No real tags found (only pre-release tags), defaulting to 0.0.0");
|
|
return "0.0.0";
|
|
}
|
|
|
|
const baseTag = realTags[0].name;
|
|
this.coreService.info(`Using latest real tag: ${baseTag}`);
|
|
return baseTag;
|
|
}
|
|
|
|
async determineIncrementType(ref: string): Promise<IncrementType> {
|
|
this.coreService.info(`Fetching commit ${ref}`);
|
|
|
|
try {
|
|
const { commit } = await this.gitService.getCommit(ref);
|
|
this.coreService.info(`Successfully fetched commit: ${commit.message.substring(0, 100)}...`);
|
|
|
|
const analyzedCommit = this.commitAnalyzer.analyzeCommit(commit.message);
|
|
this.coreService.info(
|
|
`Analyzed commit - type: ${analyzedCommit.type}, breaking: ${analyzedCommit.breaking}`,
|
|
);
|
|
|
|
const incrementType = this.commitAnalyzer.determineIncrementType(analyzedCommit);
|
|
this.coreService.info(`Determined increment type: ${incrementType}`);
|
|
|
|
return incrementType;
|
|
} catch (error) {
|
|
this.coreService.info(
|
|
`Error fetching commit ${ref}: ${error instanceof Error ? error.message : String(error)}`,
|
|
);
|
|
|
|
// Additional debugging for commit-related errors
|
|
if (error instanceof Error && error.message.includes("404")) {
|
|
this.coreService.info(`404 error suggests commit ${ref} was not found in repository`);
|
|
this.coreService.info(
|
|
`This could indicate: 1) SHA doesn't exist, 2) Repository access issue, 3) API endpoint mismatch`,
|
|
);
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
async incrementTag(
|
|
lastTag: string | undefined,
|
|
ref: string,
|
|
maxTags: number = 50,
|
|
prerelease: boolean = false,
|
|
githubSha: string = "",
|
|
): Promise<string> {
|
|
this.coreService.info(`Starting tag increment process at ref ${ref}`);
|
|
|
|
const baseTag = await this.getBaseTag(lastTag, maxTags);
|
|
const parsedTag = this.tagService.parseTag(baseTag);
|
|
|
|
this.coreService.info(
|
|
`Parsed version: ${parsedTag.major}.${parsedTag.minor}.${parsedTag.patch}`,
|
|
);
|
|
|
|
const incrementType = await this.determineIncrementType(ref);
|
|
|
|
const newTag = this.tagService.bumpTag(parsedTag, incrementType);
|
|
|
|
const prereleaseSuffix = prerelease && githubSha ? `-rc-${githubSha}` : "";
|
|
const renderedTag = this.tagService.renderTag(newTag, "", prereleaseSuffix);
|
|
|
|
this.coreService.info(`New tag: ${renderedTag}`);
|
|
this.coreService.info(
|
|
`Successfully determined new tag: ${renderedTag} (${incrementType} increment)`,
|
|
);
|
|
|
|
return renderedTag;
|
|
}
|
|
}
|
|
|
|
export class LocalGitService implements GitService {
|
|
async listTags(perPage: number): Promise<{ name: string }[]> {
|
|
try {
|
|
const tags = execSync("git tag --sort=-version:refname", { encoding: "utf8" })
|
|
.split("\n")
|
|
.filter(Boolean)
|
|
.slice(0, perPage);
|
|
|
|
return tags.map((name) => ({ name }));
|
|
} catch (error) {
|
|
// If no tags exist, return empty array
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async getCommit(ref: string): Promise<{ commit: { message: string } }> {
|
|
try {
|
|
const message = execSync(`git log -1 --pretty=%B ${ref}`, { encoding: "utf8" }).trim();
|
|
return { commit: { message } };
|
|
} catch (error) {
|
|
throw new Error(
|
|
`Failed to get commit ${ref}: ${error instanceof Error ? error.message : String(error)}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
async testConnection(): Promise<void> {
|
|
try {
|
|
// Test if we're in a git repository
|
|
execSync("git rev-parse --git-dir", { stdio: "pipe" });
|
|
} catch (error) {
|
|
throw new Error("Not in a git repository. Please ensure this action runs after checkout.");
|
|
}
|
|
}
|
|
}
|
|
|
|
export class LocalCoreService implements CoreService {
|
|
getInput(name: string): string {
|
|
return core.getInput(name);
|
|
}
|
|
|
|
info(message: string): void {
|
|
core.info(message);
|
|
}
|
|
|
|
warning(message: string): void {
|
|
core.warning(message);
|
|
}
|
|
|
|
setOutput(name: string, value: string): void {
|
|
core.setOutput(name, value);
|
|
}
|
|
|
|
setFailed(message: string): void {
|
|
core.setFailed(message);
|
|
}
|
|
}
|
|
|
|
export async function run(): Promise<void> {
|
|
try {
|
|
const coreService = new LocalCoreService();
|
|
|
|
const lastTag = coreService.getInput("last-tag");
|
|
const maxTagsInput = coreService.getInput("max-tags");
|
|
const maxTags = parseInt(maxTagsInput || "50", 10);
|
|
const prereleaseInput = coreService.getInput("prerelease");
|
|
const prerelease = prereleaseInput === "true";
|
|
const githubSha = process.env.GITHUB_SHA || "";
|
|
const ref = "HEAD";
|
|
|
|
if (prerelease && !githubSha) {
|
|
const errorMessage =
|
|
"Prerelease is enabled but GITHUB_SHA environment variable is not available. This is required for prerelease tags.";
|
|
coreService.setFailed(errorMessage);
|
|
return;
|
|
}
|
|
|
|
// Log context information for debugging
|
|
coreService.info(`Working with local git repository`);
|
|
coreService.info(`Commit ref: ${ref}`);
|
|
coreService.info(`Last tag input: ${lastTag || "undefined"}`);
|
|
coreService.info(`Max tags limit: ${maxTags}`);
|
|
coreService.info(`Prerelease: ${prerelease}`);
|
|
coreService.info(`GitHub SHA: ${githubSha || "undefined"}`);
|
|
|
|
const gitService = new LocalGitService();
|
|
const commitAnalyzer = new ConventionalCommitAnalyzer();
|
|
const tagService = new TagService();
|
|
const tagIncrementer = new TagIncrementer(gitService, coreService, commitAnalyzer, tagService);
|
|
|
|
coreService.info("Starting tag increment process...");
|
|
|
|
// Test the connection first
|
|
coreService.info("Testing git repository connection...");
|
|
await gitService.testConnection();
|
|
coreService.info("Git repository connection successful");
|
|
|
|
const newTag = await tagIncrementer.incrementTag(
|
|
lastTag || undefined,
|
|
ref,
|
|
maxTags,
|
|
prerelease,
|
|
githubSha,
|
|
);
|
|
|
|
coreService.info(`Process completed successfully. New tag: ${newTag}`);
|
|
coreService.setOutput("new-tag", newTag);
|
|
} catch (error) {
|
|
const coreService = new LocalCoreService();
|
|
|
|
// Enhanced error logging
|
|
if (error instanceof Error) {
|
|
coreService.info(`Error details: ${error.message}`);
|
|
coreService.info(`Error stack: ${error.stack}`);
|
|
coreService.setFailed(error.message);
|
|
} else {
|
|
coreService.info(`Unknown error: ${String(error)}`);
|
|
coreService.setFailed("An unknown error occurred");
|
|
}
|
|
}
|
|
}
|