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

build: publish docker images #27179

Merged
merged 2 commits into from
Feb 9, 2024
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
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
Loading