Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VersionPrefix support to csproj, vbproj, fsproj, and props files #8

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
vers-one marked this conversation as resolved.
Show resolved Hide resolved
* `<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