From 1160858c06d4772e3e61cb6fdcbff867e657d7ff Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Wed, 16 Nov 2022 13:39:25 +0100 Subject: [PATCH] Adds nightly release --- .azure-pipelines/publish-nightly.yml | 55 +++++++++++++++++++ .../{pipeline.yml => publish-stable.yml} | 15 ++--- ...table.ts => prepare-monaco-editor-core.ts} | 25 ++++++--- ...tor-stable.ts => prepare-monaco-editor.ts} | 20 +++++-- scripts/lib/index.ts | 10 ++++ 5 files changed, 103 insertions(+), 22 deletions(-) create mode 100644 .azure-pipelines/publish-nightly.yml rename .azure-pipelines/{pipeline.yml => publish-stable.yml} (89%) rename scripts/ci/{prepare-monaco-editor-core-stable.ts => prepare-monaco-editor-core.ts} (72%) mode change 100755 => 100644 rename scripts/ci/{prepare-monaco-editor-stable.ts => prepare-monaco-editor.ts} (69%) mode change 100755 => 100644 diff --git a/.azure-pipelines/publish-nightly.yml b/.azure-pipelines/publish-nightly.yml new file mode 100644 index 00000000..6985364e --- /dev/null +++ b/.azure-pipelines/publish-nightly.yml @@ -0,0 +1,55 @@ +############################################################################################### +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +############################################################################################### +name: $(Date:yyyyMMdd)$(Rev:.r) + +trigger: none +pr: none + +schedules: + - cron: '0 7 * * *' + displayName: Daily release + branches: + include: + - main + +resources: + repositories: + - repository: templates + type: github + name: microsoft/vscode-engineering + ref: main + endpoint: Monaco + +extends: + template: azure-pipelines/npm-package/pipeline.yml@templates + parameters: + npmPackages: + - name: monaco-editor-core + workingDirectory: $(Build.SourcesDirectory)/dependencies/vscode/out-monaco-editor-core + testPlatforms: [] + buildSteps: + - script: npm ci + displayName: Install NPM dependencies + + - script: yarn ts-node ./scripts/ci/prepare-monaco-editor-core nightly + displayName: Setup, Build & Test monaco-editor-core + + tag: next + publishPackage: true + publishRequiresApproval: false + + - name: monaco-editor + workingDirectory: $(Build.SourcesDirectory)/release + testPlatforms: [] + buildSteps: + - script: npm ci + displayName: Install NPM dependencies + + - script: yarn ts-node ./scripts/ci/prepare-monaco-editor nightly + displayName: Setup, Build & Test monaco-editor + + tag: next + publishPackage: true + publishRequiresApproval: false diff --git a/.azure-pipelines/pipeline.yml b/.azure-pipelines/publish-stable.yml similarity index 89% rename from .azure-pipelines/pipeline.yml rename to .azure-pipelines/publish-stable.yml index afdbed19..2190aa47 100644 --- a/.azure-pipelines/pipeline.yml +++ b/.azure-pipelines/publish-stable.yml @@ -16,13 +16,6 @@ resources: endpoint: Monaco parameters: - - name: quality - displayName: Quality - type: string - default: latest - values: - - latest - - next - name: publishMonacoEditorCore displayName: 🚀 Publish Monaco Editor Core type: boolean @@ -43,10 +36,10 @@ extends: - script: npm ci displayName: Install NPM dependencies - - script: yarn ts-node ./scripts/ci/prepare-monaco-editor-core-stable + - script: yarn ts-node ./scripts/ci/prepare-monaco-editor-core stable displayName: Setup, Build & Test monaco-editor-core - tag: ${{ parameters.quality }} + tag: latest publishPackage: ${{ parameters.publishMonacoEditorCore }} publishRequiresApproval: false @@ -57,9 +50,9 @@ extends: - script: npm ci displayName: Install NPM dependencies - - script: yarn ts-node ./scripts/ci/prepare-monaco-editor-stable + - script: yarn ts-node ./scripts/ci/prepare-monaco-editor stable displayName: Setup, Build & Test monaco-editor - tag: ${{ parameters.quality }} + tag: latest publishPackage: ${{ parameters.publishMonacoEditor }} publishRequiresApproval: false diff --git a/scripts/ci/prepare-monaco-editor-core-stable.ts b/scripts/ci/prepare-monaco-editor-core.ts old mode 100755 new mode 100644 similarity index 72% rename from scripts/ci/prepare-monaco-editor-core-stable.ts rename to scripts/ci/prepare-monaco-editor-core.ts index d6cb240c..606304ea --- a/scripts/ci/prepare-monaco-editor-core-stable.ts +++ b/scripts/ci/prepare-monaco-editor-core.ts @@ -1,6 +1,6 @@ import { mkdir, rm } from 'fs/promises'; import { join, resolve } from 'path'; -import { group, gitShallowClone, run, writeJsonFile } from '../lib'; +import { group, gitShallowClone, run, writeJsonFile, getNightlyVersion } from '../lib'; const selfPath = __dirname; const rootPath = join(selfPath, '..', '..'); @@ -8,15 +8,26 @@ const dependenciesPath = join(rootPath, 'dependencies'); const vscodePath = resolve(dependenciesPath, 'vscode'); const monacoEditorPackageJsonPath = resolve(rootPath, 'package.json'); -async function prepareMonacoEditorCoreReleaseStable() { +async function prepareMonacoEditorCoreReleaseStableOrNightly() { const monacoEditorPackageJson = require(monacoEditorPackageJsonPath) as { version: string; vscodeRef: string; }; - await prepareMonacoEditorCoreRelease( - monacoEditorPackageJson.version, - monacoEditorPackageJson.vscodeRef - ); + let version: string; + let ref: string; + + const arg = process.argv[2]; + if (arg === 'stable') { + version = monacoEditorPackageJson.version; + ref = monacoEditorPackageJson.vscodeRef; + } else if (arg === 'nightly') { + version = getNightlyVersion(monacoEditorPackageJson.version); + ref = 'main'; + } else { + throw new Error('Invalid argument'); + } + + await prepareMonacoEditorCoreRelease(version, ref); // npm package is now in dependencies/vscode/out-monaco-editor-core, ready to be published } @@ -53,4 +64,4 @@ async function prepareMonacoEditorCoreRelease(version: string, vscodeRef: string }); } -prepareMonacoEditorCoreReleaseStable(); +prepareMonacoEditorCoreReleaseStableOrNightly(); diff --git a/scripts/ci/prepare-monaco-editor-stable.ts b/scripts/ci/prepare-monaco-editor.ts old mode 100755 new mode 100644 similarity index 69% rename from scripts/ci/prepare-monaco-editor-stable.ts rename to scripts/ci/prepare-monaco-editor.ts index f01137fb..ec20e602 --- a/scripts/ci/prepare-monaco-editor-stable.ts +++ b/scripts/ci/prepare-monaco-editor.ts @@ -1,16 +1,28 @@ import { readFile } from 'fs/promises'; import { join, resolve } from 'path'; -import { group, run, writeJsonFile } from '../lib'; +import { getNightlyVersion, group, run, writeJsonFile } from '../lib'; const selfPath = __dirname; const rootPath = join(selfPath, '..', '..'); const monacoEditorPackageJsonPath = resolve(rootPath, 'package.json'); -async function prepareMonacoEditorReleaseStable() { +async function prepareMonacoEditorReleaseStableOrNightly() { const monacoEditorPackageJson = JSON.parse( await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' }) ) as { version: string }; - await prepareMonacoEditorRelease(monacoEditorPackageJson.version); + + let version: string; + + const arg = process.argv[2]; + if (arg === 'stable') { + version = monacoEditorPackageJson.version; + } else if (arg === 'nightly') { + version = getNightlyVersion(monacoEditorPackageJson.version); + } else { + throw new Error('Invalid argument'); + } + + await prepareMonacoEditorRelease(version); // npm package is now in ./release, ready to be published } @@ -35,4 +47,4 @@ async function prepareMonacoEditorRelease(version: string) { }); } -prepareMonacoEditorReleaseStable(); +prepareMonacoEditorReleaseStableOrNightly(); diff --git a/scripts/lib/index.ts b/scripts/lib/index.ts index de59ac6f..62f3c9ec 100644 --- a/scripts/lib/index.ts +++ b/scripts/lib/index.ts @@ -43,3 +43,13 @@ export async function group(name: string, body: () => Promise): Promise { await writeFile(filePath, JSON.stringify(jsonData, null, '\t') + '\n'); } + +export function getNightlyVersion(version: string): string { + const pieces = version.split('.'); + const minor = parseInt(pieces[1], 10); + const date = new Date(); + const yyyy = date.getUTCFullYear(); + const mm = String(date.getUTCMonth() + 1).padStart(2, '0'); + const dd = String(date.getUTCDate()).padStart(2, '0'); + return `0.${minor + 1}.0-dev.${yyyy}${mm}${dd}`; +}