From 822b565d6f11aeb9b101b50d0f93d057176affe2 Mon Sep 17 00:00:00 2001 From: Dave Bartolomeo Date: Fri, 15 Nov 2019 13:24:37 -0700 Subject: [PATCH] A few versioning fixes - Bumps the version of the extension to 1.0.1. We should bump the version immediately after every official release, so that any builds that happen after the release are treated as prerelease versions of the next release. - Separates the components of the timestamp in the version number for non-release builds. This just makes it easier to read. I also left off the milliseconds, which were kind of overkill, and switched to using UTC time to avoid time-zone ambiguity. - Updates the version number in the copy of the extension's `package.json` that winds up in the actual .vsix, so VS Code actually sees the version as being the proper prelease version. --- extensions/ql-vscode/package.json | 2 +- tools/build-tasks/src/deploy.ts | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 38acec5a6..c35594c81 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -4,7 +4,7 @@ "description": "CodeQL for Visual Studio Code", "author": "GitHub", "private": true, - "version": "1.0.0", + "version": "1.0.1", "publisher": "GitHub", "license": "MIT", "icon": "media/VS-marketplace-CodeQL-icon.png", diff --git a/tools/build-tasks/src/deploy.ts b/tools/build-tasks/src/deploy.ts index 6b40a6e2a..a0487847f 100644 --- a/tools/build-tasks/src/deploy.ts +++ b/tools/build-tasks/src/deploy.ts @@ -19,7 +19,19 @@ interface IPackageInfo { async function copyPackage(packageFiles: IPackageInfo, destPath: string): Promise { for (const file of packageFiles.files) { - await fs.copy(path.resolve(packageFiles.sourcePath, file), path.resolve(destPath, file)); + const sourceFilePath = path.resolve(packageFiles.sourcePath, file); + const destFilePath = path.resolve(destPath, file); + if (packageFiles.isRoot && (file === 'package.json')) { + // For non-release builds, we tweak the version number of the extension to add a prerelease + // suffix. Rather than just copying `package.json`, we'll parse the original copy, update the + // `version` property, and write it out to the new location. + const packageJson = jsonc.parse((await fs.readFile(sourceFilePath)).toString()); + packageJson.version = packageFiles.version; + await fs.writeFile(destFilePath, JSON.stringify(packageJson)); + } + else { + await fs.copy(sourceFilePath, destFilePath); + } } } @@ -142,14 +154,17 @@ export async function deployPackage(packageJsonPath: string): Promise name.match(oldDevBuildPattern)).map(build => { + // vscode-codeql-0.0.1-dev.2019.9.27.19.55.20.vsix + (await fs.readdir(distDir)).filter(name => name.match(oldDevBuildPattern)).map(build => { console.log(`Deleting old dev build ${build}...`); fs.unlinkSync(path.join(distDir, build)); }); - rootPackage.version = rootPackage.version + '-dev' + new Date().toISOString().replace(/[^0-9]/g, ''); + const now = new Date(); + rootPackage.version = rootPackage.version + + `-dev.${now.getUTCFullYear()}.${now.getUTCMonth() + 1}.${now.getUTCDate()}` + + `.${now.getUTCHours()}.${now.getUTCMinutes()}.${now.getUTCSeconds()}`; } const distPath = path.join(distDir, rootPackage.name);