Fixes pipelines (#4107)

pull/4105/head^2 v0.41.0-dev-20230731
Henning Dieterichs 2 years ago committed by GitHub
parent e637c1f34c
commit 50a8a5ffbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,15 +25,13 @@ resources:
parameters: parameters:
- name: vscodeRef - name: vscodeRef
displayName: The VS Code commit id. When left empty, the main branched is used. displayName: The VS Code commit id.
type: string type: string
default: '' default: 'main'
required: false
- name: prereleaseVersion - name: prereleaseVersion
displayName: The prerelease version. When left empty, dev-${today} is used. displayName: The prerelease version.
type: string type: string
default: '' default: 'dev-${today}'
required: false
extends: extends:
template: azure-pipelines/npm-package/pipeline.yml@templates template: azure-pipelines/npm-package/pipeline.yml@templates

@ -1,6 +1,15 @@
export function getEnv(): { interface Env {
VSCODE_REF: string | undefined; VSCODE_REF: string;
PRERELEASE_VERSION: string | undefined; PRERELEASE_VERSION: string;
} { }
return process.env as any;
export function getNightlyEnv(): Env {
const env: Env = process.env as any;
if (!env.PRERELEASE_VERSION) {
throw new Error(`Missing PRERELEASE_VERSION in process.env`);
}
if (!env.VSCODE_REF) {
throw new Error(`Missing VSCODE_REF in process.env`);
}
return env;
} }

@ -1,7 +1,7 @@
import { mkdir, rm } from 'fs/promises'; import { mkdir, rm } from 'fs/promises';
import { join, resolve } from 'path'; import { join, resolve } from 'path';
import { PackageJson, group, gitShallowClone, run, writeJsonFile, getNightlyVersion } from '../lib'; import { PackageJson, group, gitShallowClone, run, writeJsonFile, getNightlyVersion } from '../lib';
import { getEnv } from './env'; import { getNightlyEnv } from './env';
const selfPath = __dirname; const selfPath = __dirname;
const rootPath = join(selfPath, '..', '..'); const rootPath = join(selfPath, '..', '..');
@ -22,8 +22,11 @@ async function prepareMonacoEditorCoreReleaseStableOrNightly() {
version = monacoEditorPackageJson.version; version = monacoEditorPackageJson.version;
ref = monacoEditorPackageJson.vscodeRef; ref = monacoEditorPackageJson.vscodeRef;
} else if (arg === 'nightly') { } else if (arg === 'nightly') {
version = getNightlyVersion(monacoEditorPackageJson.version, getEnv().PRERELEASE_VERSION); version = getNightlyVersion(
ref = getEnv().VSCODE_REF || 'main'; monacoEditorPackageJson.version,
getNightlyEnv().PRERELEASE_VERSION
);
ref = getNightlyEnv().VSCODE_REF;
} else { } else {
throw new Error('Invalid argument'); throw new Error('Invalid argument');
} }

@ -1,7 +1,7 @@
import { readFile } from 'fs/promises'; import { readFile } from 'fs/promises';
import { join, resolve } from 'path'; import { join, resolve } from 'path';
import { PackageJson, getNightlyVersion, group, run, writeJsonFile, gitCommitId } from '../lib'; import { PackageJson, getNightlyVersion, group, run, writeJsonFile, gitCommitId } from '../lib';
import { getEnv } from './env'; import { getNightlyEnv } from './env';
const selfPath = __dirname; const selfPath = __dirname;
const rootPath = join(selfPath, '..', '..'); const rootPath = join(selfPath, '..', '..');
@ -24,7 +24,10 @@ async function prepareMonacoEditorReleaseStableOrNightly() {
if (arg === 'stable') { if (arg === 'stable') {
version = monacoEditorPackageJson.version; version = monacoEditorPackageJson.version;
} else if (arg === 'nightly') { } else if (arg === 'nightly') {
version = getNightlyVersion(monacoEditorPackageJson.version, getEnv().PRERELEASE_VERSION); version = getNightlyVersion(
monacoEditorPackageJson.version,
getNightlyEnv().PRERELEASE_VERSION
);
} else { } else {
throw new Error('Invalid argument'); throw new Error('Invalid argument');
} }

@ -73,7 +73,7 @@ export async function writeJsonFile(filePath: string, jsonData: unknown): Promis
await writeFile(filePath, JSON.stringify(jsonData, null, '\t') + '\n'); await writeFile(filePath, JSON.stringify(jsonData, null, '\t') + '\n');
} }
export function getNightlyVersion(version: string, prerelease: string | undefined): string { export function getNightlyVersion(version: string, prerelease: string): string {
const pieces = version.split('.'); const pieces = version.split('.');
const minor = parseInt(pieces[1], 10); const minor = parseInt(pieces[1], 10);
const date = new Date(); const date = new Date();
@ -81,7 +81,6 @@ export function getNightlyVersion(version: string, prerelease: string | undefine
const mm = String(date.getUTCMonth() + 1).padStart(2, '0'); const mm = String(date.getUTCMonth() + 1).padStart(2, '0');
const dd = String(date.getUTCDate()).padStart(2, '0'); const dd = String(date.getUTCDate()).padStart(2, '0');
prerelease = prerelease || 'dev-${today}';
prerelease = prerelease.replace('${today}', `${yyyy}${mm}${dd}`); prerelease = prerelease.replace('${today}', `${yyyy}${mm}${dd}`);
return `0.${minor + 1}.0-${prerelease}`; return `0.${minor + 1}.0-${prerelease}`;

Loading…
Cancel
Save