From d907ca50aac6040b598559b2ed1b5f7ada6292e0 Mon Sep 17 00:00:00 2001 From: Rhys Koedijk Date: Sat, 9 Nov 2024 18:39:25 +1300 Subject: [PATCH] Use timestamp as local package revision number, for uniqueness --- task/task.json | 2 +- vss-extension.json | 2 +- vss-extension.version.increment.js | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/task/task.json b/task/task.json index 50d72d0..793e9c4 100644 --- a/task/task.json +++ b/task/task.json @@ -12,7 +12,7 @@ "runsOn": ["Agent"], "author": "Rhys Koedijk", "version": { - "Major": 1, + "Major": 0, "Minor": 0, "Patch": 0 }, diff --git a/vss-extension.json b/vss-extension.json index 3b5e531..fac6af8 100644 --- a/vss-extension.json +++ b/vss-extension.json @@ -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": [ diff --git a/vss-extension.version.increment.js b/vss-extension.version.increment.js index 49aacbb..3c20f49 100644 --- a/vss-extension.version.increment.js +++ b/vss-extension.version.increment.js @@ -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)); } }