Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes pipelines #4107

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .azure-pipelines/publish-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ resources:

parameters:
- name: vscodeRef
displayName: The VS Code commit id. When left empty, the main branched is used.
displayName: The VS Code commit id.
type: string
default: ''
required: false
default: 'main'
- name: prereleaseVersion
displayName: The prerelease version. When left empty, dev-${today} is used.
displayName: The prerelease version.
type: string
default: ''
required: false
default: 'dev-${today}'

extends:
template: azure-pipelines/npm-package/pipeline.yml@templates
Expand Down
19 changes: 14 additions & 5 deletions scripts/ci/env.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
export function getEnv(): {
VSCODE_REF: string | undefined;
PRERELEASE_VERSION: string | undefined;
} {
return process.env as any;
interface Env {
VSCODE_REF: string;
PRERELEASE_VERSION: string;
}

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;
}
9 changes: 6 additions & 3 deletions scripts/ci/monaco-editor-core-prepare.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mkdir, rm } from 'fs/promises';
import { join, resolve } from 'path';
import { PackageJson, group, gitShallowClone, run, writeJsonFile, getNightlyVersion } from '../lib';
import { getEnv } from './env';
import { getNightlyEnv } from './env';

const selfPath = __dirname;
const rootPath = join(selfPath, '..', '..');
Expand All @@ -22,8 +22,11 @@ async function prepareMonacoEditorCoreReleaseStableOrNightly() {
version = monacoEditorPackageJson.version;
ref = monacoEditorPackageJson.vscodeRef;
} else if (arg === 'nightly') {
version = getNightlyVersion(monacoEditorPackageJson.version, getEnv().PRERELEASE_VERSION);
ref = getEnv().VSCODE_REF || 'main';
version = getNightlyVersion(
monacoEditorPackageJson.version,
getNightlyEnv().PRERELEASE_VERSION
);
ref = getNightlyEnv().VSCODE_REF;
} else {
throw new Error('Invalid argument');
}
Expand Down
7 changes: 5 additions & 2 deletions scripts/ci/monaco-editor-prepare.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile } from 'fs/promises';
import { join, resolve } from 'path';
import { PackageJson, getNightlyVersion, group, run, writeJsonFile, gitCommitId } from '../lib';
import { getEnv } from './env';
import { getNightlyEnv } from './env';

const selfPath = __dirname;
const rootPath = join(selfPath, '..', '..');
Expand All @@ -24,7 +24,10 @@ async function prepareMonacoEditorReleaseStableOrNightly() {
if (arg === 'stable') {
version = monacoEditorPackageJson.version;
} else if (arg === 'nightly') {
version = getNightlyVersion(monacoEditorPackageJson.version, getEnv().PRERELEASE_VERSION);
version = getNightlyVersion(
monacoEditorPackageJson.version,
getNightlyEnv().PRERELEASE_VERSION
);
} else {
throw new Error('Invalid argument');
}
Expand Down
3 changes: 1 addition & 2 deletions scripts/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ export async function writeJsonFile(filePath: string, jsonData: unknown): Promis
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 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');

prerelease = prerelease || 'dev-${today}';
prerelease = prerelease.replace('${today}', `${yyyy}${mm}${dd}`);

return `0.${minor + 1}.0-${prerelease}`;
Expand Down