Repository: angular/angular
File: vscode-ng-language-service/tools/release.mts (TypeScript)

Code before:
  console.log(chalk.blue(`Installing dependencies...`));
  await execAndStream('pnpm', ['install', '--frozen-lockfile']);
  console.log(chalk.green('Successfully installed dependencies.'));
}

/**
 * Builds the VSCode extension.
 *
 * This function first cleans the Bazel output and then executes the `pnpm --filter=ng-template run
 * package` command with additional Bazel release arguments to build and package the VSCode
 * extension.
 */
async function buildExtension(): Promise<void> {
  console.log('');
  console.log(chalk.blue('Building VSCode extension...'));
  await execAndStream('pnpm', ['bazel', 'clean']);
  await execAndStream('pnpm', [
    'pnpm --filter=ng-template run package',
    ...additionBazelReleaseArgs,
  ]);

  console.log(chalk.green(`VSCode extension packaged at ${extensionPath}`));
}

function ensureGithubToken(): string {
  const token = process.env['GITHUB_TOKEN'];
  if (!token) {
    throw new Error('GITHUB_TOKEN environment variable is not set. Cannot create GitHub release.');
  }
  return token;
}

/**
 * Creates a GitHub release and uploads the extension asset.
 *
 * @param version The version of the release.
 * @param changelog The changelog content for the release.
 */
async function createGithubRelease(version: string, changelog: string): Promise<void> {
  const token = ensureGithubToken();

  console.log(chalk.blue('Creating GitHub release...'));

  const commonHeaders = {
    'Authorization': `Bearer ${token}`,
    'X-GitHub-Api-Version': '2022-11-28',
  };
  const {owner, repo} = getRepoDetails(angularRepoRemote);
  const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/releases`, {
    method: 'POST',
    headers: {

Review comment (suggestion):
Suggestion: Check for `GITHUB_TOKEN` and if it doesn't exist, check for `TOKEN`.
```suggestion
  const token = process.env['GITHUB_TOKEN'] ?? process.env['TOKEN'];
```

Code after:
  console.log(chalk.blue(`Installing dependencies...`));
  await execAndStream('pnpm', ['install', '--frozen-lockfile']);
  console.log(chalk.green('Successfully installed dependencies.'));
}

/**
 * Builds the VSCode extension.
 *
 * This function first cleans the Bazel output and then executes the `pnpm --filter=ng-template run
 * package` command with additional Bazel release arguments to build and package the VSCode
 * extension.
 */
async function buildExtension(): Promise<void> {
  console.log('');
  console.log(chalk.blue('Building VSCode extension...'));
  await execAndStream('pnpm', ['bazel', 'clean']);
  await execAndStream('pnpm', [
    'pnpm --filter=ng-template run package',
    ...additionBazelReleaseArgs,
  ]);

  console.log(chalk.green(`VSCode extension packaged at ${extensionPath}`));
}

function ensureGithubToken(): string {
  // https://github.com/angular/dev-infra/blob/8ce8257f740613a7291256173e2706fb2ed8aefa/ng-dev/utils/git/github-yargs.ts#L45
  const token = process.env['GITHUB_TOKEN'] ?? process.env['TOKEN'];
  if (!token) {
    throw new Error(
      'GITHUB_TOKEN nor TOKEN environment variable is not set. Cannot create GitHub release.',
    );
  }
  return token;
}

/**
 * Creates a GitHub release and uploads the extension asset.
 *
 * @param version The version of the release.
 * @param changelog The changelog content for the release.
 */
async function createGithubRelease(version: string, changelog: string): Promise<void> {
  const token = ensureGithubToken();

  console.log(chalk.blue('Creating GitHub release...'));

  const commonHeaders = {
    'Authorization': `Bearer ${token}`,
    'X-GitHub-Api-Version': '2022-11-28',
  };
  const {owner, repo} = getRepoDetails(angularRepoRemote);