Skip to content

Commit

Permalink
Add VersionPrefix support to csproj, vbproj, fsproj, and props files (#8
Browse files Browse the repository at this point in the history
)

* 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 <[email protected]>
  • Loading branch information
Invvard and vers-one authored Feb 29, 2024
1 parent 2aae671 commit e4364cf
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* `<Version>...</Version>`;
* `<VersionPrefix>...</VersionPrefix>`;
* `<AssemblyVersion>...</AssemblyVersion>`;
* `<FileVersion>...</FileVersion>`;
* for .nuspec files:
* `<Version>...</Version>`;
* for .cs files:
* `[assembly: AssemblyVersion("...")]`;
* `[assembly: AssemblyFileVersion("...")]`;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/csproj-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Plugin, { PluginVersionRegex, VersionPartDelimiter } from "./plugin";

const VERSION_TAG_REGEX: RegExp = /<Version>(.*)<\/Version>/i;
const VERSION_PREFIX_TAG_REGEX: RegExp = /<VersionPrefix>(.*)<\/VersionPrefix>/i;
const ASSEMBLY_VERSION_TAG_REGEX: RegExp = /<AssemblyVersion>(.*)<\/AssemblyVersion>/i;
const FILE_VERSION_TAG_REGEX: RegExp = /<FileVersion>(.*)<\/FileVersion>/i;

Expand All @@ -15,6 +16,11 @@ export default class CsProjPlugin extends Plugin
versionPartDelimiter: VersionPartDelimiter.DOT,
versionType: "<Version> tag"
},
{
regex: VERSION_PREFIX_TAG_REGEX,
versionPartDelimiter: VersionPartDelimiter.DOT,
versionType: "<VersionPrefix> tag"
},
{
regex: ASSEMBLY_VERSION_TAG_REGEX,
versionPartDelimiter: VersionPartDelimiter.DOT,
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/fsproj-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Plugin, { PluginVersionRegex, VersionPartDelimiter } from "./plugin";

const VERSION_TAG_REGEX: RegExp = /<Version>(.*)<\/Version>/i;
const VERSION_PREFIX_TAG_REGEX: RegExp = /<VersionPrefix>(.*)<\/VersionPrefix>/i;
const ASSEMBLY_VERSION_TAG_REGEX: RegExp = /<AssemblyVersion>(.*)<\/AssemblyVersion>/i;
const FILE_VERSION_TAG_REGEX: RegExp = /<FileVersion>(.*)<\/FileVersion>/i;

Expand All @@ -15,6 +16,11 @@ export default class FsProjPlugin extends Plugin
versionPartDelimiter: VersionPartDelimiter.DOT,
versionType: "<Version> tag"
},
{
regex: VERSION_PREFIX_TAG_REGEX,
versionPartDelimiter: VersionPartDelimiter.DOT,
versionType: "<VersionPrefix> tag"
},
{
regex: ASSEMBLY_VERSION_TAG_REGEX,
versionPartDelimiter: VersionPartDelimiter.DOT,
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/props-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Plugin, { PluginVersionRegex, VersionPartDelimiter } from "./plugin";

const VERSION_TAG_REGEX: RegExp = /<Version>(.*)<\/Version>/i;
const VERSION_PREFIX_TAG_REGEX: RegExp = /<VersionPrefix>(.*)<\/VersionPrefix>/i;
const ASSEMBLY_VERSION_TAG_REGEX: RegExp = /<AssemblyVersion>(.*)<\/AssemblyVersion>/i;
const FILE_VERSION_TAG_REGEX: RegExp = /<FileVersion>(.*)<\/FileVersion>/i;

Expand All @@ -15,6 +16,11 @@ export default class PropsPlugin extends Plugin
versionPartDelimiter: VersionPartDelimiter.DOT,
versionType: "<Version> tag"
},
{
regex: VERSION_PREFIX_TAG_REGEX,
versionPartDelimiter: VersionPartDelimiter.DOT,
versionType: "<VersionPrefix> tag"
},
{
regex: ASSEMBLY_VERSION_TAG_REGEX,
versionPartDelimiter: VersionPartDelimiter.DOT,
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/vbproj-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Plugin, { PluginVersionRegex, VersionPartDelimiter } from "./plugin";

const VERSION_TAG_REGEX: RegExp = /<Version>(.*)<\/Version>/i;
const VERSION_PREFIX_TAG_REGEX: RegExp = /<VersionPrefix>(.*)<\/VersionPrefix>/i;
const ASSEMBLY_VERSION_TAG_REGEX: RegExp = /<AssemblyVersion>(.*)<\/AssemblyVersion>/i;
const FILE_VERSION_TAG_REGEX: RegExp = /<FileVersion>(.*)<\/FileVersion>/i;

Expand All @@ -15,6 +16,11 @@ export default class VbProjPlugin extends Plugin
versionPartDelimiter: VersionPartDelimiter.DOT,
versionType: "<Version> tag"
},
{
regex: VERSION_PREFIX_TAG_REGEX,
versionPartDelimiter: VersionPartDelimiter.DOT,
versionType: "<VersionPrefix> tag"
},
{
regex: ASSEMBLY_VERSION_TAG_REGEX,
versionPartDelimiter: VersionPartDelimiter.DOT,
Expand Down
1 change: 1 addition & 0 deletions test-files/expected-results/Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>4.5.6</Version>
<VersionPrefix>4.5.6</VersionPrefix>
<AssemblyVersion>4.5.6</AssemblyVersion>
<FileVersion>4.5.6</FileVersion>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions test-files/expected-results/Test.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>4.5.6</Version>
<VersionPrefix>4.5.6</VersionPrefix>
<AssemblyVersion>4.5.6</AssemblyVersion>
<FileVersion>4.5.6</FileVersion>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions test-files/expected-results/Test.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<Version>4.5.6</Version>
<VersionPrefix>4.5.6</VersionPrefix>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions test-files/expected-results/Test.vbproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>4.5.6</Version>
<VersionPrefix>4.5.6</VersionPrefix>
<AssemblyVersion>4.5.6</AssemblyVersion>
<FileVersion>4.5.6</FileVersion>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions test-files/input/Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.2.3</Version>
<VersionPrefix>1.2.3</VersionPrefix>
<AssemblyVersion>1.2.3</AssemblyVersion>
<FileVersion>1.2.3</FileVersion>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions test-files/input/Test.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.2.3</Version>
<VersionPrefix>1.2.3</VersionPrefix>
<AssemblyVersion>1.2.3</AssemblyVersion>
<FileVersion>1.2.3</FileVersion>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions test-files/input/Test.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.2.3</Version>
<VersionPrefix>1.2.3</VersionPrefix>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions test-files/input/Test.vbproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.2.3</Version>
<VersionPrefix>1.2.3</VersionPrefix>
<AssemblyVersion>1.2.3</AssemblyVersion>
<FileVersion>1.2.3</FileVersion>
</PropertyGroup>
Expand Down

0 comments on commit e4364cf

Please sign in to comment.