mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 23:39:13 +00:00
7a50358949
chore: don't include announcement bar in release notes' attachment When building the docs site in CI on `main` (or a release branch), we currently package up the docs site into the GitHub Release. However, this includes the "announcement bar", which can include stale info. In the case where a user is looking to add a mirror for their Renovate CLI docs[0], this means they now see an announcement bar which includes unhelpful - and possibly outdated - information. As noted in #44030, we can improve this to: - not include the announcement bar when preparing the attachment for the release - include the announcement bar only when we're updating the docs site To do this, we need to: - add a new `--no-announcement` flag (which ensures the default is "do add the announcement") - log when we're not using announcements - detect the environment variable when building the mkdocs site locally This means we'll always be rebuilding the docs site (to inject the announcement bar) which is ~16s as of a recent run. [0]: https://www.jvt.me/posts/2024/11/19/renovate-private-docs/ Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
138 lines
4.0 KiB
TypeScript
138 lines
4.0 KiB
TypeScript
import { Command } from 'commander';
|
|
import fs from 'fs-extra';
|
|
import { init, logger } from '../lib/logger/index.ts';
|
|
import { generateDocs } from './docs/index.ts';
|
|
import { bake } from './utils/docker.ts';
|
|
import { exec } from './utils/exec.ts';
|
|
import { parseVersion } from './utils/index.ts';
|
|
|
|
await init();
|
|
|
|
process.on('unhandledRejection', (err) => {
|
|
// Will print "unhandledRejection err is not defined"
|
|
logger.error({ err }, 'unhandledRejection');
|
|
process.exit(-1);
|
|
});
|
|
|
|
const program = new Command('pnpm release:prepare')
|
|
.description('Build docker images')
|
|
.option('--platform <type>', 'docker platforms to build')
|
|
.option('--version <version>', 'version to use as tag', parseVersion)
|
|
.option('--channel <channel>', 'channel to use as tag')
|
|
.option('--sha <type>', 'git sha')
|
|
.option('--tries <tries>', 'number of tries for docker build', parseInt)
|
|
.option(
|
|
'--delay <delay>',
|
|
'delay between tries for docker build (eg. 5s, 10m, 1h)',
|
|
'30s',
|
|
)
|
|
.option('--exit-on-error <boolean>', 'exit on docker error', (s) =>
|
|
s ? s !== 'false' : undefined,
|
|
);
|
|
|
|
void (async () => {
|
|
await program.parseAsync();
|
|
const opts = program.opts();
|
|
logger.info(`Preparing v${opts.version?.toString()} ...`);
|
|
await preparePackageVersion(opts.version?.toString());
|
|
await build();
|
|
await generateDocs(undefined, undefined, opts.version?.toString());
|
|
await buildMkdocs(opts.version?.toString());
|
|
await bake('build', opts);
|
|
})();
|
|
|
|
async function build(): Promise<void> {
|
|
logger.info('Building ...');
|
|
const res = await exec('pnpm', ['build'], { reject: false });
|
|
|
|
if (res.signal) {
|
|
logger.error(`Signal received: ${res.signal}`);
|
|
process.exit(-1);
|
|
} else if (res.exitCode) {
|
|
logger.error(`Error occured:\n${res.stderr || res.stdout}`);
|
|
process.exit(res.exitCode);
|
|
} else if (res.timedOut) {
|
|
logger.error({ res }, 'Process timed out');
|
|
process.exit(-1);
|
|
} else if (res.killed) {
|
|
logger.error({ res }, 'Process was killed');
|
|
process.exit(-1);
|
|
} else if (res.failed) {
|
|
logger.error({ res }, 'Process call failed');
|
|
process.exit(-1);
|
|
} else {
|
|
logger.debug(`Build succeeded:\n${res.stdout || res.stderr}`);
|
|
}
|
|
}
|
|
|
|
async function buildMkdocs(version: string | undefined): Promise<void> {
|
|
logger.info('Building Mkdocs site ...');
|
|
|
|
const mkdocsArgs = ['mkdocs', 'build', '--no-announcement'];
|
|
if (version) {
|
|
mkdocsArgs.push('--version', version);
|
|
}
|
|
|
|
const mkdocsRes = await exec('pnpm', mkdocsArgs, { reject: false });
|
|
|
|
if (mkdocsRes.signal) {
|
|
logger.error(`Signal received: ${mkdocsRes.signal}`);
|
|
process.exit(-1);
|
|
} else if (mkdocsRes.exitCode) {
|
|
logger.error(
|
|
`Error occurred building mkdocs:\n${mkdocsRes.stderr || mkdocsRes.stdout}`,
|
|
);
|
|
process.exit(mkdocsRes.exitCode);
|
|
} else {
|
|
logger.debug(
|
|
`Mkdocs build succeeded:\n${mkdocsRes.stdout || mkdocsRes.stderr}`,
|
|
);
|
|
}
|
|
|
|
// Package the mkdocs site to attach to the release
|
|
logger.info('Packaging Mkdocs site ...');
|
|
await fs.ensureDir('tmp');
|
|
|
|
const tarRes = await exec(
|
|
'tar',
|
|
['-czf', 'tmp/mkdocs-site.tgz', '-C', 'tools/mkdocs/site', '.'],
|
|
{ reject: false },
|
|
);
|
|
|
|
if (tarRes.signal) {
|
|
logger.error(`Signal received: ${tarRes.signal}`);
|
|
process.exit(-1);
|
|
} else if (tarRes.exitCode) {
|
|
logger.error(
|
|
`Error occurred creating mkdocs-site.tgz:\n${tarRes.stderr || tarRes.stdout}`,
|
|
);
|
|
process.exit(tarRes.exitCode);
|
|
} else {
|
|
logger.info('Mkdocs site packaged successfully to tmp/mkdocs-site.tgz');
|
|
}
|
|
}
|
|
async function preparePackageVersion(
|
|
version: string | undefined,
|
|
): Promise<void> {
|
|
if (!version) {
|
|
return;
|
|
}
|
|
const res = await exec(
|
|
'pnpm',
|
|
['version', version, '--no-git-tag-version', '--allow-same-version'],
|
|
{ reject: false },
|
|
);
|
|
|
|
if (res.signal) {
|
|
logger.error(`Signal received: ${res.signal}`);
|
|
process.exit(-1);
|
|
} else if (res.exitCode) {
|
|
logger.error(
|
|
`Error occurred updating package version:\n${res.stderr || res.stdout}`,
|
|
);
|
|
process.exit(res.exitCode);
|
|
} else {
|
|
logger.info('Package version updated');
|
|
}
|
|
}
|