Skip to content

Commit

Permalink
build: publish docker images (#27179)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Feb 9, 2024
1 parent 1163c55 commit 552a2d9
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 195 deletions.
102 changes: 0 additions & 102 deletions .github/workflows/release.yml

This file was deleted.

38 changes: 0 additions & 38 deletions tools/dispatch-release.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion tools/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ program
)
.action(async (opts) => {
logger.info('Building docker images ...');
await bake('build', opts, opts.tries - 1);
await bake('build', opts);
});

program
Expand Down
28 changes: 28 additions & 0 deletions tools/docker/bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ variable "FILE" {
variable "RENOVATE_VERSION" {
default = "unknown"
}
variable "RENOVATE_MAJOR_VERSION" {
default = ""
}
variable "RENOVATE_MAJOR_MINOR_VERSION" {
default = ""
}

variable "APT_HTTP_PROXY" {
default = ""
Expand Down Expand Up @@ -64,8 +70,24 @@ target "slim" {
"type=registry,ref=ghcr.io/${OWNER}/docker-build-cache:${FILE}",
]
tags = [
"ghcr.io/${OWNER}/${FILE}",
"ghcr.io/${OWNER}/${FILE}:${RENOVATE_VERSION}",
"${FILE}/${FILE}",
"${FILE}/${FILE}:${RENOVATE_VERSION}",
notequal("", RENOVATE_MAJOR_VERSION) ? "ghcr.io/${OWNER}/${FILE}:${RENOVATE_MAJOR_VERSION}": "",
notequal("", RENOVATE_MAJOR_MINOR_VERSION) ? "ghcr.io/${OWNER}/${FILE}:${RENOVATE_MAJOR_MINOR_VERSION}": "",
notequal("", RENOVATE_MAJOR_VERSION) ? "${FILE}/${FILE}:${RENOVATE_MAJOR_VERSION}": "",
notequal("", RENOVATE_MAJOR_MINOR_VERSION) ? "${FILE}/${FILE}:${RENOVATE_MAJOR_MINOR_VERSION}": "",

// TODO: legacy, remove on next major
"ghcr.io/${OWNER}/${FILE}-slim",
"ghcr.io/${OWNER}/${FILE}:${RENOVATE_VERSION}-slim",
"${FILE}/${FILE}-slim",
"${FILE}/${FILE}:${RENOVATE_VERSION}-slim",
notequal("", RENOVATE_MAJOR_VERSION) ? "ghcr.io/${OWNER}/${FILE}:${RENOVATE_MAJOR_VERSION}-slim": "",
notequal("", RENOVATE_MAJOR_MINOR_VERSION) ? "ghcr.io/${OWNER}/${FILE}:${RENOVATE_MAJOR_MINOR_VERSION}-slim": "",
notequal("", RENOVATE_MAJOR_VERSION) ? "${FILE}/${FILE}:${RENOVATE_MAJOR_VERSION}-slim": "",
notequal("", RENOVATE_MAJOR_MINOR_VERSION) ? "${FILE}/${FILE}:${RENOVATE_MAJOR_MINOR_VERSION}-slim": "",
]
}

Expand All @@ -78,7 +100,13 @@ target "full" {
]
tags = [
"ghcr.io/${OWNER}/${FILE}:${RENOVATE_VERSION}-full",
"ghcr.io/${OWNER}/${FILE}:full",
"${FILE}/${FILE}:full",
"${FILE}/${FILE}:${RENOVATE_VERSION}-full",
notequal("", RENOVATE_MAJOR_VERSION) ? "ghcr.io/${OWNER}/${FILE}:${RENOVATE_MAJOR_VERSION}-full": "",
notequal("", RENOVATE_MAJOR_MINOR_VERSION) ? "ghcr.io/${OWNER}/${FILE}:${RENOVATE_MAJOR_MINOR_VERSION}-full": "",
notequal("", RENOVATE_MAJOR_VERSION) ? "${FILE}/${FILE}:${RENOVATE_MAJOR_VERSION}-full": "",
notequal("", RENOVATE_MAJOR_MINOR_VERSION) ? "${FILE}/${FILE}:${RENOVATE_MAJOR_MINOR_VERSION}-full": "",
]
}

Expand Down
7 changes: 3 additions & 4 deletions tools/prepare-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ const program = new Command('pnpm release:prepare')
'delay between tries for docker build (eg. 5s, 10m, 1h)',
'30s',
)
.option('--exit-on-error [boolean]', 'exit on docker error', (s) =>
.option('--exit-on-error <boolean>', 'exit on docker error', (s) =>
s ? s !== 'false' : undefined,
)
.option('-d, --debug', 'output docker build');
);

void (async () => {
await program.parseAsync();
const opts = program.opts();
logger.info(`Preparing v${opts.version} ...`);
await generateDocs();
await bake('build', opts, opts.tries);
await bake('build', opts);
})();
32 changes: 27 additions & 5 deletions tools/publish-release.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from 'commander';
import { logger } from '../lib/logger';
import { parseVersion } from './utils';
import { bake } from './utils/docker';
import { bake, sign } from './utils/docker';

process.on('unhandledRejection', (err) => {
// Will print "unhandledRejection err is not defined"
Expand All @@ -13,13 +13,35 @@ 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('--exit-on-error', 'exit on docker error')
.option('-d, --debug', 'output docker build');
.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}...`);
logger.info(`TODO: publish docker images`);
await bake('push-cache', opts);
const meta = await bake('push', opts);

if (meta?.['build-slim']?.['containerimage.digest']) {
sign(
`ghcr.io/${process.env.OWNER}/${process.env.FILE}${meta['build-slim']['containerimage.digest']}`,
opts,
);
sign(
`${process.env.FILE}/${process.env.FILE}${meta['build-slim']['containerimage.digest']}`,
opts,
);
}

if (meta?.['build-full']?.['containerimage.digest']) {
sign(
`ghcr.io/${process.env.OWNER}/${process.env.FILE}@${meta['build-full']['containerimage.digest']}`,
opts,
);
sign(
`${process.env.FILE}/${process.env.FILE}@${meta['build-full']['containerimage.digest']}`,
opts,
);
}
})();
Loading

0 comments on commit 552a2d9

Please sign in to comment.