Skip to content

Commit

Permalink
Use timestamp as local package revision number, for uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyskoedijk committed Nov 9, 2024
1 parent 1759cf2 commit d907ca5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"runsOn": ["Agent"],
"author": "Rhys Koedijk",
"version": {
"Major": 1,
"Major": 0,
"Minor": 0,
"Patch": 0
},
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": "sbom-tool-local",
"name": "SBOM Tool [LOCALHOST]",
"description": "SBOM Tool. Generate SPDX 2.2 compatible SBOMs from Azure DevOps repository artifacts.",
"version": "1.0.0",
"version": "0.0.0.0",
"public": false,
"scopes": ["vso.build"],
"targets": [
Expand Down
9 changes: 7 additions & 2 deletions vss-extension.version.increment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ const path = require('path');
function incrementPatchVersion(vssExtensionJsonPath, taskJsonPath) {
const vssExtensionJson = JSON.parse(fs.readFileSync(vssExtensionJsonPath));
const taskJson = JSON.parse(fs.readFileSync(taskJsonPath));
const version = taskJson.version || { Major: 1, Minor: 0, Patch: 0 };
const version = taskJson.version || { Major: 0, Minor: 0, Patch: 0 };
version.Patch += 1;
if (taskJson) {
taskJson.version = version;
fs.writeFileSync(taskJsonPath, JSON.stringify(taskJson, null, 2));
}
if (vssExtensionJson) {
vssExtensionJson.version = taskJson.version.Major + '.' + taskJson.version.Minor + '.' + taskJson.version.Patch;
const revisionTimestamp = new Date()
.toISOString()
.replace(/[^0-9]/g, '')
.slice(3, 12); // YMMDDHHmm
vssExtensionJson.version =
taskJson.version.Major + '.' + taskJson.version.Minor + '.' + taskJson.version.Patch + '.' + revisionTimestamp;
fs.writeFileSync(vssExtensionJsonPath, JSON.stringify(vssExtensionJson, null, 2));
}
}
Expand Down

0 comments on commit d907ca5

Please sign in to comment.