aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/publish-release.ts
blob: 590ef44aab1625503bff33c6255902e025547478 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Command } from 'commander';
import { logger } from '../lib/logger';
import { parseVersion } from './utils';
import { bake, sign } from './utils/docker';

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('--sha <type>', 'git sha')
  .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(`Publishing v${opts.version}...`);
  const meta = await bake('push', opts);

  if (meta?.['push-slim']?.['containerimage.digest']) {
    sign(
      `ghcr.io/renovatebot/renovate@${meta['push-slim']['containerimage.digest']}`,
      opts,
    );
    sign(
      `renovate/renovate@${meta['push-slim']['containerimage.digest']}`,
      opts,
    );
  } else {
    logger.warn('Skip signing, missing metadata for slim image');
  }

  if (meta?.['push-full']?.['containerimage.digest']) {
    sign(
      `ghcr.io/renovatebot/renovate@${meta['push-full']['containerimage.digest']}`,
      opts,
    );
    sign(
      `renovate/renovate@${meta['push-full']['containerimage.digest']}`,
      opts,
    );
  } else {
    logger.warn('Skip signing, missing metadata for full image');
  }
})();