From e4364cfafa012ca83e8489d04daa8999a73bc827 Mon Sep 17 00:00:00 2001 From: Pierre Cavaroc <7305493+Invvard@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:51:58 -0500 Subject: [PATCH] Add VersionPrefix support to csproj, vbproj, fsproj, and props files (#8) * Add VersionPrefix regex to csproj files * Add VersionPrefix regex to props files * Add VersionPrefix regex to fsproj files * Add VersionPrefix regex to vbproj files * docs(README.md): update additional notes section to include support for VersionPrefix in .csproj, .vbproj, .fsproj and .props files and Version in .nuspec files to accurately detect version declarations in the project * Comma --------- Co-authored-by: vers-one <12114169+vers-one@users.noreply.github.com> --- README.md | 5 ++++- src/plugins/csproj-plugin.ts | 6 ++++++ src/plugins/fsproj-plugin.ts | 6 ++++++ src/plugins/props-plugin.ts | 6 ++++++ src/plugins/vbproj-plugin.ts | 6 ++++++ test-files/expected-results/Test.csproj | 1 + test-files/expected-results/Test.fsproj | 1 + test-files/expected-results/Test.props | 1 + test-files/expected-results/Test.vbproj | 1 + test-files/input/Test.csproj | 1 + test-files/input/Test.fsproj | 1 + test-files/input/Test.props | 1 + test-files/input/Test.vbproj | 1 + 13 files changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b65faa3..baa354d 100644 --- a/README.md +++ b/README.md @@ -219,10 +219,13 @@ jobs: ## Additional notes * This action searches for the following version declarations: - * for .csproj, .vbproj, .fsproj, .props, and .nuspec files: + * for .csproj, .vbproj, .fsproj, and .props files: * `...`; + * `...`; * `...`; * `...`; + * for .nuspec files: + * `...`; * for .cs files: * `[assembly: AssemblyVersion("...")]`; * `[assembly: AssemblyFileVersion("...")]`; diff --git a/src/plugins/csproj-plugin.ts b/src/plugins/csproj-plugin.ts index 4cb7a4b..e789a45 100644 --- a/src/plugins/csproj-plugin.ts +++ b/src/plugins/csproj-plugin.ts @@ -1,6 +1,7 @@ import Plugin, { PluginVersionRegex, VersionPartDelimiter } from "./plugin"; const VERSION_TAG_REGEX: RegExp = /(.*)<\/Version>/i; +const VERSION_PREFIX_TAG_REGEX: RegExp = /(.*)<\/VersionPrefix>/i; const ASSEMBLY_VERSION_TAG_REGEX: RegExp = /(.*)<\/AssemblyVersion>/i; const FILE_VERSION_TAG_REGEX: RegExp = /(.*)<\/FileVersion>/i; @@ -15,6 +16,11 @@ export default class CsProjPlugin extends Plugin versionPartDelimiter: VersionPartDelimiter.DOT, versionType: " tag" }, + { + regex: VERSION_PREFIX_TAG_REGEX, + versionPartDelimiter: VersionPartDelimiter.DOT, + versionType: " tag" + }, { regex: ASSEMBLY_VERSION_TAG_REGEX, versionPartDelimiter: VersionPartDelimiter.DOT, diff --git a/src/plugins/fsproj-plugin.ts b/src/plugins/fsproj-plugin.ts index 0637d3e..366ce4a 100644 --- a/src/plugins/fsproj-plugin.ts +++ b/src/plugins/fsproj-plugin.ts @@ -1,6 +1,7 @@ import Plugin, { PluginVersionRegex, VersionPartDelimiter } from "./plugin"; const VERSION_TAG_REGEX: RegExp = /(.*)<\/Version>/i; +const VERSION_PREFIX_TAG_REGEX: RegExp = /(.*)<\/VersionPrefix>/i; const ASSEMBLY_VERSION_TAG_REGEX: RegExp = /(.*)<\/AssemblyVersion>/i; const FILE_VERSION_TAG_REGEX: RegExp = /(.*)<\/FileVersion>/i; @@ -15,6 +16,11 @@ export default class FsProjPlugin extends Plugin versionPartDelimiter: VersionPartDelimiter.DOT, versionType: " tag" }, + { + regex: VERSION_PREFIX_TAG_REGEX, + versionPartDelimiter: VersionPartDelimiter.DOT, + versionType: " tag" + }, { regex: ASSEMBLY_VERSION_TAG_REGEX, versionPartDelimiter: VersionPartDelimiter.DOT, diff --git a/src/plugins/props-plugin.ts b/src/plugins/props-plugin.ts index af34425..76322d2 100644 --- a/src/plugins/props-plugin.ts +++ b/src/plugins/props-plugin.ts @@ -1,6 +1,7 @@ import Plugin, { PluginVersionRegex, VersionPartDelimiter } from "./plugin"; const VERSION_TAG_REGEX: RegExp = /(.*)<\/Version>/i; +const VERSION_PREFIX_TAG_REGEX: RegExp = /(.*)<\/VersionPrefix>/i; const ASSEMBLY_VERSION_TAG_REGEX: RegExp = /(.*)<\/AssemblyVersion>/i; const FILE_VERSION_TAG_REGEX: RegExp = /(.*)<\/FileVersion>/i; @@ -15,6 +16,11 @@ export default class PropsPlugin extends Plugin versionPartDelimiter: VersionPartDelimiter.DOT, versionType: " tag" }, + { + regex: VERSION_PREFIX_TAG_REGEX, + versionPartDelimiter: VersionPartDelimiter.DOT, + versionType: " tag" + }, { regex: ASSEMBLY_VERSION_TAG_REGEX, versionPartDelimiter: VersionPartDelimiter.DOT, diff --git a/src/plugins/vbproj-plugin.ts b/src/plugins/vbproj-plugin.ts index 0c0a80e..5fd7925 100644 --- a/src/plugins/vbproj-plugin.ts +++ b/src/plugins/vbproj-plugin.ts @@ -1,6 +1,7 @@ import Plugin, { PluginVersionRegex, VersionPartDelimiter } from "./plugin"; const VERSION_TAG_REGEX: RegExp = /(.*)<\/Version>/i; +const VERSION_PREFIX_TAG_REGEX: RegExp = /(.*)<\/VersionPrefix>/i; const ASSEMBLY_VERSION_TAG_REGEX: RegExp = /(.*)<\/AssemblyVersion>/i; const FILE_VERSION_TAG_REGEX: RegExp = /(.*)<\/FileVersion>/i; @@ -15,6 +16,11 @@ export default class VbProjPlugin extends Plugin versionPartDelimiter: VersionPartDelimiter.DOT, versionType: " tag" }, + { + regex: VERSION_PREFIX_TAG_REGEX, + versionPartDelimiter: VersionPartDelimiter.DOT, + versionType: " tag" + }, { regex: ASSEMBLY_VERSION_TAG_REGEX, versionPartDelimiter: VersionPartDelimiter.DOT, diff --git a/test-files/expected-results/Test.csproj b/test-files/expected-results/Test.csproj index bd96aca..e468c88 100644 --- a/test-files/expected-results/Test.csproj +++ b/test-files/expected-results/Test.csproj @@ -1,6 +1,7 @@ 4.5.6 + 4.5.6 4.5.6 4.5.6 diff --git a/test-files/expected-results/Test.fsproj b/test-files/expected-results/Test.fsproj index bd96aca..e468c88 100644 --- a/test-files/expected-results/Test.fsproj +++ b/test-files/expected-results/Test.fsproj @@ -1,6 +1,7 @@ 4.5.6 + 4.5.6 4.5.6 4.5.6 diff --git a/test-files/expected-results/Test.props b/test-files/expected-results/Test.props index ec88772..5277b40 100644 --- a/test-files/expected-results/Test.props +++ b/test-files/expected-results/Test.props @@ -1,5 +1,6 @@ 4.5.6 + 4.5.6 diff --git a/test-files/expected-results/Test.vbproj b/test-files/expected-results/Test.vbproj index bd96aca..e468c88 100644 --- a/test-files/expected-results/Test.vbproj +++ b/test-files/expected-results/Test.vbproj @@ -1,6 +1,7 @@ 4.5.6 + 4.5.6 4.5.6 4.5.6 diff --git a/test-files/input/Test.csproj b/test-files/input/Test.csproj index bc6ac4b..7aabc72 100644 --- a/test-files/input/Test.csproj +++ b/test-files/input/Test.csproj @@ -1,6 +1,7 @@ 1.2.3 + 1.2.3 1.2.3 1.2.3 diff --git a/test-files/input/Test.fsproj b/test-files/input/Test.fsproj index bc6ac4b..7aabc72 100644 --- a/test-files/input/Test.fsproj +++ b/test-files/input/Test.fsproj @@ -1,6 +1,7 @@ 1.2.3 + 1.2.3 1.2.3 1.2.3 diff --git a/test-files/input/Test.props b/test-files/input/Test.props index 1a25e79..ecaca05 100644 --- a/test-files/input/Test.props +++ b/test-files/input/Test.props @@ -1,5 +1,6 @@ 1.2.3 + 1.2.3 diff --git a/test-files/input/Test.vbproj b/test-files/input/Test.vbproj index bc6ac4b..7aabc72 100644 --- a/test-files/input/Test.vbproj +++ b/test-files/input/Test.vbproj @@ -1,6 +1,7 @@ 1.2.3 + 1.2.3 1.2.3 1.2.3