Skip to content

Commit

Permalink
🔧 add automagic to synchronise assembly version info with csproj
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffynuts committed Sep 18, 2020
1 parent af29a3d commit 67fd5a1
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 173 deletions.
51 changes: 51 additions & 0 deletions local-tasks/update-version-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const
gulp = requireModule("gulp");

gulp.task("update-version-info", async () => {
// the version as per the .csproj is the correct version, but there
// are other places where the version string is set via [assembly]
// attributes, so we need to re-align them all
const
Git = require("simple-git/promise"),
readTextFile = requireModule("read-text-file"),
writeTextFile = requireModule("write-text-file"),
readCsProjVersion = requireModule("read-csproj-version"),
currentVersion = await readCsProjVersion("src/log4net/log4net.csproj"),
assemblyInfo = "src/log4net/AssemblyInfo.cs",
assemblyVersionInfo = "src/log4net/AssemblyVersionInfo.cs",
versionString = sanitiseVersion(currentVersion);

await updateVersionsIn(assemblyInfo, versionString);
await updateVersionsIn(assemblyVersionInfo, versionString);

const git = new Git(".");
await git.add([
assemblyInfo,
assemblyVersionInfo
]);
await git.commit(`:bookmark: update versioning to ${versionString}`);

async function updateVersionsIn(
filePath,
newVersion
) {
const
contents = await readTextFile(filePath),
updated = contents
// specific matches for "x.x.x.x"
.replace(/"\d+\.\d+\.\d+\.\d+"/g, `"${newVersion}"`)
// matches for "x.x.x.x- as found in AssemblyVersionInfo.cs
.replace(/"\d+\.\d+\.\d+\.\d+-/g, `"${newVersion}-`);
await writeTextFile(filePath, updated);
}

function sanitiseVersion(version) {
const parts = version.split(".");
while (parts.length < 4) {
parts.push("0");
}
return parts.slice(0, 4).join(".");
}
});


34 changes: 30 additions & 4 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"build-site": "run-s \"zarro build-site\"",
"prepare-build-artifacts": "run-s \"zarro prepare-build-artifacts\"",
"dump-env": "node -e \"console.log(process.env);\"",
"release": "run-s build-release prepare-build-artifacts build-site",
"zarro": "cross-env BUILD_INCLUDE=src/log4net.sln zarro"
"release": "run-s update-version-info build-release prepare-build-artifacts build-site",
"zarro": "cross-env BUILD_INCLUDE=src/log4net.sln zarro",
"update-version-info": "run-s \"zarro update-version-info\""
},
"repository": {
"type": "git",
Expand All @@ -29,6 +30,7 @@
"gulp-zip": "^5.0.1",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"simple-git": "^2.20.1",
"which": "^2.0.2",
"yafs": "^1.5.0",
"zarro": "^1.78.0"
Expand Down
46 changes: 23 additions & 23 deletions src/log4net/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,77 +54,77 @@
//

#if (CLI_1_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.CLI 1.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.CLI 1.0")]
[assembly: AssemblyTitle("Apache log4net for CLI 1.0 Compatible Frameworks")]
#elif (NET_1_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET 1.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET 1.0")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework 1.0")]
#elif (NET_1_1)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET 1.1")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET 1.1")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework 1.1")]
#elif (NET_4_5)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET 4.5")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET 4.5")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework 4.5")]
#elif (NET_4_0)
#if CLIENT_PROFILE
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET 4.0 CP")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET 4.0 CP")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework 4.0 Client Profile")]
#else
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET 4.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET 4.0")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework 4.0")]
#endif // Client Profile
#elif (NET_3_5)
#if CLIENT_PROFILE
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET 3.5 CP")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET 3.5 CP")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework 3.5 Client Profile")]
#else
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET 3.5")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET 3.5")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework 3.5")]
#endif // Client Profile
#elif (NET_2_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET 2.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET 2.0")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework 2.0")]
#elif (NETCF_1_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NETCF 1.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NETCF 1.0")]
[assembly: AssemblyTitle("Apache log4net for .NET Compact Framework 1.0")]
#elif (NETCF_2_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NETCF 2.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NETCF 2.0")]
[assembly: AssemblyTitle("Apache log4net for .NET Compact Framework 2.0")]
#elif (MONO_1_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-Mono 1.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-Mono 1.0")]
[assembly: AssemblyTitle("Apache log4net for Mono 1.0")]
#elif (MONO_2_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-Mono 2.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-Mono 2.0")]
[assembly: AssemblyTitle("Apache log4net for Mono 2.0")]
#elif (MONO_3_5)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-Mono 3.5")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-Mono 3.5")]
[assembly: AssemblyTitle("Apache log4net for Mono 3.5")]
#elif (MONO_4_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-Mono 4.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-Mono 4.0")]
[assembly: AssemblyTitle("Apache log4net for Mono 4.0")]
#elif (SSCLI_1_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-SSCLI 1.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-SSCLI 1.0")]
[assembly: AssemblyTitle("Apache log4net for Shared Source CLI 1.0")]
#elif (NET)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET")]
[assembly: AssemblyTitle("Apache log4net for .NET Framework")]
#elif (NETSTANDARD1_3)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET Standard 1.3")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET Standard 1.3")]
[assembly: AssemblyTitle("Apache log4net for .NET Standard 1.3")]
#elif (NETSTANDARD2_0)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET Standard 2.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NET Standard 2.0")]
[assembly: AssemblyTitle("Apache log4net for .NET Standard 2.0")]
#elif (NETCF)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NETCF")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-.NETCF")]
[assembly: AssemblyTitle("Apache log4net for .NET Compact Framework")]
#elif (MONO)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-Mono")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-Mono")]
[assembly: AssemblyTitle("Apache log4net for Mono")]
#elif (SSCLI)
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-SSCLI")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0-SSCLI")]
[assembly: AssemblyTitle("Apache log4net for Shared Source CLI")]
#else
[assembly: AssemblyInformationalVersionAttribute("2.0.9.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.11.0")]
[assembly: AssemblyTitle("Apache log4net")]
#endif

Expand Down
48 changes: 0 additions & 48 deletions src/log4net/AssemblyVersionInfo.cpp

This file was deleted.

49 changes: 0 additions & 49 deletions src/log4net/AssemblyVersionInfo.js

This file was deleted.

46 changes: 0 additions & 46 deletions src/log4net/AssemblyVersionInfo.vb

This file was deleted.

2 changes: 1 addition & 1 deletion src/log4net/log4net.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>log4net</PackageId>
<Version>2.0.10</Version>
<Version>2.0.11</Version>
<Title>Apache log4net</Title>
<Product>Apache log4net</Product>
<Description>
Expand Down

0 comments on commit 67fd5a1

Please sign in to comment.