-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔧 add automagic to synchronise assembly version info with csproj
- Loading branch information
1 parent
af29a3d
commit 67fd5a1
Showing
8 changed files
with
109 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("."); | ||
} | ||
}); | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters