Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Update Docker Hub README with supported tags on release (#85101)

Chris Vandoodewaard17c6e29b0557
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index ef869e27f11..4fa3f58eb22 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -429,6 +429,72 @@ jobs:
tag_oss: ${{ contains(matrix.tag, 'v0') || !startsWith(matrix.tag, 'v') }}
dot-x-tag: ${{ startsWith(matrix.tag, 'v') }}
+ update-docker-readme:
+ needs: [add-extra-tags]
+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
+ continue-on-error: true
+ timeout-minutes: 10
+ strategy:
+ matrix:
+ include:
+ - edition: oss
+ repository: ${{ vars.DOCKERHUB_REPO }}
+ template: bin/docker/README.md
+ - edition: ee
+ repository: ${{ vars.DOCKERHUB_REPO }}-enterprise
+ template: bin/docker/README-enterprise.md
+ concurrency:
+ group: update-docker-readme-${{ matrix.edition }}
+ cancel-in-progress: false
+ env:
+ AWS_S3_STATIC_BUCKET: ${{ vars.AWS_S3_STATIC_BUCKET }}
+ AWS_REGION: ${{ vars.AWS_REGION }}
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ sparse-checkout: |
+ release
+ .github
+ bin/docker
+ - name: Prepare release scripts
+ uses: ./.github/actions/prepare-release-scripts
+ - name: Update Docker Hub README (${{ matrix.edition }})
+ working-directory: release
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ GITHUB_OWNER: ${{ github.repository_owner }}
+ GITHUB_REPO: ${{ github.event.repository.name }}
+ LATEST_MAJOR_VERSION: ${{ vars.LATEST_MAJOR_VERSION }}
+ DOCKERHUB_RELEASE_USERNAME: ${{ secrets.DOCKERHUB_RELEASE_USERNAME }}
+ DOCKERHUB_RELEASE_TOKEN: ${{ secrets.DOCKERHUB_RELEASE_TOKEN }}
+ EDITION: ${{ matrix.edition }}
+ TEMPLATE: ${{ github.workspace }}/${{ matrix.template }}
+ REPOSITORY: ${{ vars.DOCKERHUB_OWNER }}/${{ matrix.repository }}
+ run: |
+ bun run docker-readme \
+ --edition "$EDITION" \
+ --template "$TEMPLATE" \
+ --repository "$REPOSITORY" \
+ --publish
+ - name: Send Docker Hub README failure message
+ if: failure()
+ uses: actions/github-script@v9
+ env:
+ SLACK_RELEASE_CHANNEL: ${{ vars.SLACK_RELEASE_CHANNEL }}
+ SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
+ with:
+ script: | # js
+ const { sendDockerReadmeFailureMessage } = require('${{ github.workspace }}/release/dist/index.cjs');
+
+ await sendDockerReadmeFailureMessage({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ version: '${{ inputs.version }}',
+ runId: context.runId,
+ channelName: '${{ vars.SLACK_RELEASE_CHANNEL }}',
+ edition: '${{ matrix.edition }}',
+ }).catch(console.error);
+
trigger-cloud-issues:
# Only create issues in the cloud ops repository if this release happens in https://github.com/metabase/metabase.
if: ${{ github.repository == 'metabase/metabase' && (needs.check-version.outputs.kind == 'minor' || needs.check-version.outputs.kind == 'major') }}
diff --git a/bin/docker/README-enterprise.md b/bin/docker/README-enterprise.md
new file mode 100644
index 00000000000..3dec936b94a
--- /dev/null
+++ b/bin/docker/README-enterprise.md
@@ -0,0 +1,20 @@
+# Quick Reference
+- **Maintained by:** [Metabase](https://www.metabase.com/)
+- **Where to get help:** [Metabase Documentation](https://www.metabase.com/help) | [Enterprise Support](https://www.metabase.com/product/enterprise)
+
+# Supported Tags
+{{SUPPORTED_TAGS_TABLE}}
+
+Our [version support policy](https://www.metabase.com/version-support).
+
+# Getting started
+[Metabase Enterprise Edition](https://www.metabase.com/product/enterprise) is a paid version of Metabase that includes [additional features](https://www.metabase.com/docs/latest/paid-features/overview) for managing large deployments or delivering interactive embedded analytics to your customers.
+
+To activate these paid features, you'll need a [license key](https://www.metabase.com/docs/latest/paid-features/activating-the-enterprise-edition#how-to-activate-your-token-when-self-hosting).
+
+To get started, check out our docs:
+
+- [Pro or Enterprise quick start with Docker](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker#pro-or-enterprise-quick-start).
+- [Running Metabase in production](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker#production-installation).
+
+If you’d prefer Metabase host your instance and application database for you, check out [Metabase Cloud](https://www.metabase.com/pricing/).
diff --git a/bin/docker/README.md b/bin/docker/README.md
new file mode 100644
index 00000000000..dea587d084e
--- /dev/null
+++ b/bin/docker/README.md
@@ -0,0 +1,17 @@
+# Quick Reference
+- **Maintained by:** [Metabase](https://www.metabase.com/)
+- **Where to get help:** [Metabase Documentation](https://www.metabase.com/help) | [Enterprise Support](https://www.metabase.com/product/enterprise)
+
+# Supported Tags
+{{SUPPORTED_TAGS_TABLE}}
+
+Our [version support policy](https://www.metabase.com/version-support).
+
+# Getting started
+This image contains the open-source version of Metabase. For the Metabase with all of the bells and whistles, check out [Metabase Enterprise](https://www.metabase.com/product/enterprise).
+
+To get started, check out our docs:
+- [Running Metabase on Docker](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker)
+- [Running Metabase in production](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker#production-installation)
+
+If you’d prefer Metabase host your instance and application database for you, check out [Metabase Cloud](https://www.metabase.com/pricing).
\ No newline at end of file
diff --git a/release/docker-readme.ts b/release/docker-readme.ts
new file mode 100644
index 00000000000..f454e6cab42
--- /dev/null
+++ b/release/docker-readme.ts
@@ -0,0 +1,120 @@
+import { readFile } from "node:fs/promises";
+import path from "node:path";
+import { parseArgs } from "node:util";
+
+import { Octokit } from "@octokit/rest";
+
+import {
+ type DockerEdition,
+ generateDockerReadme,
+ pushDockerReadme,
+} from "./src/docker-readme";
+
+const DEFAULT_TEMPLATE_PATHS: Record<DockerEdition, string> = {
+ oss: path.join(import.meta.dirname, "../bin/docker/README.md"),
+ ee: path.join(import.meta.dirname, "../bin/docker/README-enterprise.md"),
+};
+
+const USAGE = `Usage:
+ bun docker-readme [--edition oss|ee] [--latest-major 64] [--template path] [--repository owner/name] [--publish]
+
+Prints the generated Docker Hub README. With --publish, also pushes it to the repository.
+
+--edition oss (default) or ee. Picks v0 or v1 tags.
+--latest-major defaults to LATEST_MAJOR_VERSION
+--template defaults to bin/docker/README.md (oss) or bin/docker/README-enterprise.md (ee)
+--repository defaults to DOCKERHUB_OWNER/DOCKERHUB_REPO (oss) or DOCKERHUB_OWNER/DOCKERHUB_REPO-enterprise (ee)
+
+Env: GITHUB_TOKEN, AWS_S3_STATIC_BUCKET, AWS_REGION,
+ DOCKERHUB_RELEASE_USERNAME and DOCKERHUB_RELEASE_TOKEN (for --publish)`;
+
+const isDockerEdition = (value: string): value is DockerEdition =>
+ value === "oss" || value === "ee";
+
+async function main() {
+ const { values } = parseArgs({
+ options: {
+ edition: { type: "string", default: "oss" },
+ "latest-major": { type: "string" },
+ template: { type: "string" },
+ repository: { type: "string" },
+ publish: { type: "boolean", default: false },
+ help: { type: "boolean", short: "h", default: false },
+ },
+ });
+
+ if (values.help) {
+ console.log(USAGE);
+ return;
+ }
+
+ const {
+ GITHUB_TOKEN,
+ GITHUB_OWNER = "metabase",
+ GITHUB_REPO = "metabase",
+ LATEST_MAJOR_VERSION,
+ DOCKERHUB_OWNER,
+ DOCKERHUB_REPO,
+ DOCKERHUB_RELEASE_USERNAME,
+ DOCKERHUB_RELEASE_TOKEN,
+ } = process.env;
+
+ const { edition } = values;
+ if (!isDockerEdition(edition)) {
+ throw new Error(`Invalid --edition: ${edition}\n\n${USAGE}`);
+ }
+
+ const latestMajorVersion = values["latest-major"] ?? LATEST_MAJOR_VERSION;
+ if (!latestMajorVersion) {
+ throw new Error(`Missing --latest-major\n\n${USAGE}`);
+ }
+
+ const readme = await generateDockerReadme({
+ github: new Octokit({ auth: GITHUB_TOKEN }),
+ owner: GITHUB_OWNER,
+ repo: GITHUB_REPO,
+ latestMajorVersion,
+ edition,
+ template: await readFile(
+ values.template ?? DEFAULT_TEMPLATE_PATHS[edition],
+ "utf8",
+ ),
+ });
+
+ console.log(readme);
+
+ if (!values.publish) {
+ return;
+ }
+
+ const repository =
+ values.repository ??
+ (DOCKERHUB_OWNER && DOCKERHUB_REPO
+ ? `${DOCKERHUB_OWNER}/${DOCKERHUB_REPO}${edition === "ee" ? "-enterprise" : ""}`
+ : undefined);
+ if (!repository) {
+ throw new Error(`Missing --repository\n\n${USAGE}`);
+ }
+ if (!DOCKERHUB_RELEASE_USERNAME || !DOCKERHUB_RELEASE_TOKEN) {
+ throw new Error(
+ "Missing DOCKERHUB_RELEASE_USERNAME or DOCKERHUB_RELEASE_TOKEN",
+ );
+ }
+
+ await pushDockerReadme({
+ readme,
+ repository,
+ username: DOCKERHUB_RELEASE_USERNAME,
+ token: DOCKERHUB_RELEASE_TOKEN,
+ });
+
+ console.log(`\nPublished README to https://hub.docker.com/r/${repository}`);
+}
+
+try {
+ await main();
+} catch (error) {
+ const message = error instanceof Error ? error.message : String(error);
+ console.error(message);
+ process.exit(1);
+}
diff --git a/release/package.json b/release/package.json
index dc35fb1e399..c69fe4d1b3d 100644
--- a/release/package.json
+++ b/release/package.json
@@ -11,6 +11,7 @@
"build": "esbuild src/index.ts --bundle --outfile=dist/index.cjs --platform=node --target=node16",
"generate-changelog": "bun generate-changelog.ts",
"alert-upgrade-versions": "bun alert-upgrade-versions.ts",
+ "docker-readme": "bun docker-readme.ts",
"format": "oxfmt --write",
"release-offline": "tsx release-offline.ts",
"test:unit": "jest --testPathPattern unit",
diff --git a/release/src/docker-readme.ts b/release/src/docker-readme.ts
new file mode 100644
index 00000000000..af9452d903c
--- /dev/null
+++ b/release/src/docker-readme.ts
@@ -0,0 +1,202 @@
+import fetch from "node-fetch";
+
+import type { GithubProps, VersionInfoFile } from "./types";
+import {
+ getCanonicalVersion,
+ getLastReleaseTag,
+ getOSSVersion,
+ getRollingTagsForVersion,
+} from "./version-helpers";
+import { getSupportedMajorVersions, getVersionInfoUrl } from "./version-info";
+
+export const SUPPORTED_TAGS_PLACEHOLDER = "{{SUPPORTED_TAGS_TABLE}}";
+
+export type DockerEdition = "oss" | "ee";
+
+export type DockerTagRow = {
+ major: number;
+ status: "Beta" | "LTS" | "Supported";
+ version: string;
+ isLatest: boolean;
+ lts: boolean;
+};
+
+export const getDockerTagsForVersion = (props: {
+ version: string;
+ isLatest: boolean;
+ isLts: boolean;
+}) => [...getRollingTagsForVersion(props), props.version];
+
+export const getDockerTagRowStatus = ({
+ version,
+ lts,
+}: {
+ version: string;
+ lts: boolean;
+}): DockerTagRow["status"] => {
+ const [_prefix, _major, minor] = getOSSVersion(version).split(/\.|\-/g);
+ if (Number(minor) === 0) {
+ return "Beta";
+ }
+ return lts ? "LTS" : "Supported";
+};
+
+export const buildSupportedTagsTable = (rows: DockerTagRow[]) =>
+ [
+ "| Version | Status | Tags |",
+ "|---|---|---|",
+ ...rows.map(({ major, status, version, isLatest, lts }) => {
+ const tags = getDockerTagsForVersion({
+ version,
+ isLatest,
+ isLts: lts,
+ });
+ return `| ${major} | ${status} | ${tags.map((tag) => `\`${tag}\``).join(", ")} |`;
+ }),
+ ].join("\n");
+
+export const renderDockerReadme = ({
+ template,
+ rows,
+}: {
+ template: string;
+ rows: DockerTagRow[];
+}) => {
+ if (!template.includes(SUPPORTED_TAGS_PLACEHOLDER)) {
+ throw new Error(
+ `Docker README template has no ${SUPPORTED_TAGS_PLACEHOLDER} placeholder`,
+ );
+ }
+ return template.replace(SUPPORTED_TAGS_PLACEHOLDER, () =>
+ buildSupportedTagsTable(rows),
+ );
+};
+
+export async function getDockerTagRows({
+ github,
+ owner,
+ repo,
+ latestMajorVersion,
+ edition,
+ today = new Date().toISOString().slice(0, 10),
+}: GithubProps & {
+ latestMajorVersion: string;
+ edition: DockerEdition;
+ today?: string;
+}) {
+ const latestMajor = Number(latestMajorVersion);
+ if (!Number.isInteger(latestMajor) || latestMajor <= 0) {
+ throw new Error(`Invalid latest major version: ${latestMajorVersion}`);
+ }
+
+ const versionInfoUrl = getVersionInfoUrl("v0");
+ const versionInfoResponse = await fetch(versionInfoUrl);
+ if (!versionInfoResponse.ok) {
+ throw new Error(
+ `Failed to fetch ${versionInfoUrl}: ${versionInfoResponse.status} ${await versionInfoResponse.text()}`,
+ );
+ }
+ const versionInfo = (await versionInfoResponse.json()) as VersionInfoFile;
+
+ const rows: DockerTagRow[] = [];
+
+ for (const major of getSupportedMajorVersions(versionInfo, today)) {
+ const ossVersion = await getLastReleaseTag({
+ github,
+ owner,
+ repo,
+ version: `v0.${major}.0`,
+ });
+
+ if (!ossVersion) {
+ console.warn(`No release tag found for major version ${major}, skipping`);
+ continue;
+ }
+
+ const version = getCanonicalVersion(ossVersion, edition);
+
+ const lts = !!versionInfo.major_version_support?.some(
+ (line) => line.major === major && line.lts,
+ );
+ const status = getDockerTagRowStatus({ version, lts });
+
+ rows.push({
+ major,
+ status,
+ version,
+ isLatest: major === latestMajor,
+ lts,
+ });
+ }
+
+ return rows;
+}
+
+export async function generateDockerReadme({
+ template,
+ ...props
+}: GithubProps & {
+ template: string;
+ latestMajorVersion: string;
+ edition: DockerEdition;
+ today?: string;
+}) {
+ const rows = await getDockerTagRows(props);
+ return renderDockerReadme({ template, rows });
+}
+
+const DOCKER_HUB_API_URL = "https://hub.docker.com/v2";
+
+export async function pushDockerReadme({
+ readme,
+ repository,
+ username,
+ token,
+}: {
+ readme: string;
+ repository: string;
+ username: string;
+ token: string;
+}) {
+ const authResponse = await fetch(`${DOCKER_HUB_API_URL}/auth/token`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ identifier: username, secret: token }),
+ });
+
+ if (!authResponse.ok) {
+ throw new Error(
+ `Docker Hub authentication failed: ${authResponse.status} ${await authResponse.text()}`,
+ );
+ }
+
+ const authBody: unknown = await authResponse.json();
+ const access_token =
+ typeof authBody === "object" &&
+ authBody !== null &&
+ "access_token" in authBody &&
+ typeof authBody.access_token === "string"
+ ? authBody.access_token
+ : undefined;
+ if (!access_token) {
+ throw new Error("Docker Hub authentication response has no access_token");
+ }
+
+ const response = await fetch(
+ `${DOCKER_HUB_API_URL}/repositories/${repository}/`,
+ {
+ method: "PATCH",
+ headers: {
+ Authorization: `Bearer ${access_token}`,
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ full_description: readme }),
+ },
+ );
+
+ if (!response.ok) {
+ throw new Error(
+ `Docker Hub README update for ${repository} failed: ${response.status} ${await response.text()}`,
+ );
+ }
+}
diff --git a/release/src/docker-readme.unit.spec.ts b/release/src/docker-readme.unit.spec.ts
new file mode 100644
index 00000000000..dd7efbdb813
--- /dev/null
+++ b/release/src/docker-readme.unit.spec.ts
@@ -0,0 +1,217 @@
+import fetch from "node-fetch";
+
+import {
+ SUPPORTED_TAGS_PLACEHOLDER,
+ generateDockerReadme,
+ getDockerTagRowStatus,
+ pushDockerReadme,
+ renderDockerReadme,
+} from "./docker-readme";
+
+jest.mock("node-fetch", () => ({
+ __esModule: true,
+ default: jest.fn(),
+}));
+
+const mockFetch = jest.mocked(fetch);
+
+const response = (ok: boolean, body: object = {}) =>
+ ({
+ ok,
+ status: ok ? 200 : 401,
+ json: async () => body,
+ text: async () => JSON.stringify(body),
+ }) as any;
+
+describe("docker-readme", () => {
+ beforeEach(() => {
+ mockFetch.mockReset();
+ });
+
+ describe("getDockerTagRowStatus", () => {
+ it.each([
+ ["v0.65.0-beta", false, "Beta"],
+ ["v0.64.0.3", true, "Beta"],
+ ["v0.64.1", true, "LTS"],
+ ])("%s with lts=%s is %s", (version, lts, status) => {
+ expect(getDockerTagRowStatus({ version, lts })).toBe(status);
+ });
+ });
+
+ describe("renderDockerReadme", () => {
+ it("throws when the template has no placeholder", () => {
+ expect(() =>
+ renderDockerReadme({ template: "# Tags", rows: [] }),
+ ).toThrow(SUPPORTED_TAGS_PLACEHOLDER);
+ });
+ });
+
+ describe("generateDockerReadme", () => {
+ const tags = [
+ "v0.65.0-beta",
+ "v0.65.x",
+ "v0.64.3",
+ "v0.64.3.1",
+ "v0.64-lts",
+ "v0.63.20",
+ "v0.63.21",
+ "v0.62.10",
+ "v0.58.37",
+ ];
+
+ const makeGithub = (tags: string[]) => ({
+ rest: { git: { listMatchingRefs: "listMatchingRefs" } },
+ paginate: jest.fn((_fn: unknown, { ref }: { ref: string }) =>
+ Promise.resolve(
+ tags
+ .filter((tag) => `tags/${tag}`.startsWith(ref))
+ .map((tag) => ({ ref: `refs/tags/${tag}` })),
+ ),
+ ),
+ });
+
+ const github = makeGithub(tags);
+
+ const line = (major: number, lts: boolean, eol: string) => ({
+ major,
+ lts,
+ eol,
+ });
+
+ it.each([
+ ["oss", "v0"],
+ ["ee", "v1"],
+ ] as const)(
+ "renders a %s row with the newest %s tags for each supported major version that has a release",
+ async (edition, prefix) => {
+ mockFetch.mockResolvedValue(
+ response(true, {
+ major_version_support: [
+ line(65, false, "2027-01-01"),
+ line(64, true, "2027-12-01"),
+ line(63, false, "2026-11-01"),
+ line(62, false, "2026-09-01"),
+ line(61, false, "2027-06-01"),
+ line(58, true, "2027-02-17"),
+ ],
+ }),
+ );
+
+ const readme = await generateDockerReadme({
+ github: github as any,
+ owner: "metabase",
+ repo: "metabase",
+ latestMajorVersion: "64",
+ edition,
+ today: "2026-10-21",
+ template: `# Supported Tags\n${SUPPORTED_TAGS_PLACEHOLDER}\n\nFooter`,
+ });
+
+ expect(readme).toBe(
+ [
+ "# Supported Tags",
+ "| Version | Status | Tags |",
+ "|---|---|---|",
+ `| 65 | Beta | \`${prefix}.65.x\`, \`${prefix}.65.0-beta\` |`,
+ `| 64 | LTS | \`latest\`, \`${prefix}.64-lts\`, \`${prefix}.64.x\`, \`${prefix}.64.3.x\`, \`${prefix}.64.3.1\` |`,
+ `| 63 | Supported | \`${prefix}.63.x\`, \`${prefix}.63.21.x\`, \`${prefix}.63.21\` |`,
+ `| 58 | LTS | \`${prefix}.58-lts\`, \`${prefix}.58.x\`, \`${prefix}.58.37.x\`, \`${prefix}.58.37\` |`,
+ "",
+ "Footer",
+ ].join("\n"),
+ );
+ expect(mockFetch).toHaveBeenCalledTimes(1);
+ },
+ );
+
+ it("adds the -lts tag to an LTS major version that is still in beta", async () => {
+ mockFetch.mockResolvedValue(
+ response(true, {
+ major_version_support: [line(66, true, "2028-01-01")],
+ }),
+ );
+
+ const readme = await generateDockerReadme({
+ github: makeGithub([...tags, "v0.66.0.3"]) as any,
+ owner: "metabase",
+ repo: "metabase",
+ latestMajorVersion: "65",
+ edition: "oss",
+ today: "2026-10-21",
+ template: SUPPORTED_TAGS_PLACEHOLDER,
+ });
+
+ expect(readme).toContain(
+ "| 66 | Beta | `v0.66-lts`, `v0.66.x`, `v0.66.0.x`, `v0.66.0.3` |",
+ );
+ });
+
+ it("throws with the URL when version-info.json cannot be fetched", async () => {
+ mockFetch.mockResolvedValue(response(false));
+
+ await expect(
+ generateDockerReadme({
+ github: github as any,
+ owner: "metabase",
+ repo: "metabase",
+ latestMajorVersion: "64",
+ edition: "oss",
+ template: SUPPORTED_TAGS_PLACEHOLDER,
+ }),
+ ).rejects.toThrow(/Failed to fetch .*version-info\.json: 401/);
+ });
+ });
+
+ describe("pushDockerReadme", () => {
+ const push = (token = "pat") =>
+ pushDockerReadme({
+ readme: "# README",
+ repository: "metabase/metabase",
+ username: "user",
+ token,
+ });
+
+ it("gets an access token and sends the README to the repository", async () => {
+ mockFetch
+ .mockResolvedValueOnce(response(true, { access_token: "jwt" }))
+ .mockResolvedValueOnce(response(true));
+
+ await push();
+
+ expect(mockFetch).toHaveBeenNthCalledWith(
+ 1,
+ "https://hub.docker.com/v2/auth/token",
+ expect.objectContaining({
+ method: "POST",
+ body: JSON.stringify({ identifier: "user", secret: "pat" }),
+ }),
+ );
+ expect(mockFetch).toHaveBeenNthCalledWith(
+ 2,
+ "https://hub.docker.com/v2/repositories/metabase/metabase/",
+ expect.objectContaining({
+ method: "PATCH",
+ headers: expect.objectContaining({ Authorization: "Bearer jwt" }),
+ body: JSON.stringify({ full_description: "# README" }),
+ }),
+ );
+ });
+
+ it("throws when authentication fails", async () => {
+ mockFetch.mockResolvedValueOnce(response(false));
+
+ await expect(push("bad")).rejects.toThrow(
+ "Docker Hub authentication failed: 401",
+ );
+ });
+
+ it("throws when the authentication response has no access token", async () => {
+ mockFetch.mockResolvedValueOnce(response(true, { token: "jwt" }));
+
+ await expect(push()).rejects.toThrow(
+ "Docker Hub authentication response has no access_token",
+ );
+ expect(mockFetch).toHaveBeenCalledTimes(1);
+ });
+ });
+});
diff --git a/release/src/slack.ts b/release/src/slack.ts
index fcce489efc4..b21e88bb21a 100644
--- a/release/src/slack.ts
+++ b/release/src/slack.ts
@@ -567,6 +567,33 @@ export async function sendPublishFailureMessage({
});
}
+export async function sendDockerReadmeFailureMessage({
+ channelName,
+ version,
+ runId,
+ owner,
+ repo,
+ edition,
+}: {
+ channelName: string;
+ version: string;
+ runId: number;
+ owner: string;
+ repo: string;
+ edition: string;
+}) {
+ const message = `:warning: ${githubRunLink(`Updating the ${edition} Docker Hub README for ${getGenericVersion(version)} failed`, runId.toString(), owner, repo)}. The release itself is fine.`;
+
+ const buildThread = await getExistingSlackMessage(version, channelName);
+
+ if (!buildThread?.id) {
+ await sendSlackMessage({ channelName, message });
+ return;
+ }
+
+ await sendSlackReply({ channelName, message, messageId: buildThread.id });
+}
+
export async function sendPublishCompleteMessage({
channelName,
version,
diff --git a/release/src/version-helpers.ts b/release/src/version-helpers.ts
index ea046adacd8..7a4af01b924 100644
--- a/release/src/version-helpers.ts
+++ b/release/src/version-helpers.ts
@@ -154,6 +154,21 @@ const shouldAddLatestTag = ({
return majorVersion === latestMajorVersion;
};
+export const getRollingTagsForVersion = ({
+ version,
+ isLatest,
+ isLts,
+}: {
+ version: string;
+ isLatest: boolean;
+ isLts: boolean;
+}) => [
+ ...(isLatest ? ["latest"] : []),
+ ...(isLts ? [getLtsTag(version)] : []),
+ getDotXs(version, 1),
+ ...(getVersionType(version) !== "major" ? [getDotXs(version, 2)] : []),
+];
+
export const getExtraTagsForVersion = async ({
version,
latestMajorVersion,
@@ -161,25 +176,20 @@ export const getExtraTagsForVersion = async ({
version: string;
latestMajorVersion?: string;
}) => {
- const ossVersion = getOSSVersion(version);
- const eeVersion = getEnterpriseVersion(version);
- const versionType = getVersionType(version);
-
- // eg. v0.23.x / v1.23.x
- const baseTags = [getDotXs(ossVersion, 1), getDotXs(eeVersion, 1)];
- // eg. v0.23.4.x / v1.23.4.x
- const minorTags =
- versionType !== "major"
- ? [getDotXs(ossVersion, 2), getDotXs(eeVersion, 2)]
- : [];
+ const isLatest = shouldAddLatestTag({ version, latestMajorVersion });
+ const isLts = await isLtsVersion({ version });
return [
- ...baseTags,
- ...minorTags,
- ...(shouldAddLatestTag({ version, latestMajorVersion }) ? ["latest"] : []),
- ...((await isLtsVersion({ version }))
- ? [getLtsTag(ossVersion), getLtsTag(eeVersion)]
- : []),
+ ...getRollingTagsForVersion({
+ version: getOSSVersion(version),
+ isLatest,
+ isLts,
+ }),
+ ...getRollingTagsForVersion({
+ version: getEnterpriseVersion(version),
+ isLatest: false,
+ isLts,
+ }),
];
};
diff --git a/release/src/version-helpers.unit.spec.ts b/release/src/version-helpers.unit.spec.ts
index 50cea6ae227..f606180e824 100644
--- a/release/src/version-helpers.unit.spec.ts
+++ b/release/src/version-helpers.unit.spec.ts
@@ -826,15 +826,15 @@ describe("version-helpers", () => {
it("should return the correct extra tags for a minor version", async () => {
expect(await getExtraTagsForVersion({ version: "v1.75.1" })).toEqual([
"v0.75.x",
- "v1.75.x",
"v0.75.1.x",
+ "v1.75.x",
"v1.75.1.x",
]);
expect(await getExtraTagsForVersion({ version: "v0.75.1" })).toEqual([
"v0.75.x",
- "v1.75.x",
"v0.75.1.x",
+ "v1.75.x",
"v1.75.1.x",
]);
});
@@ -842,15 +842,15 @@ describe("version-helpers", () => {
it("should return the correct extra tags for a patch version", async () => {
expect(await getExtraTagsForVersion({ version: "v1.75.1.3" })).toEqual([
"v0.75.x",
- "v1.75.x",
"v0.75.1.x",
+ "v1.75.x",
"v1.75.1.x",
]);
expect(await getExtraTagsForVersion({ version: "v0.75.1.3" })).toEqual([
"v0.75.x",
- "v1.75.x",
"v0.75.1.x",
+ "v1.75.x",
"v1.75.1.x",
]);
});
@@ -861,12 +861,12 @@ describe("version-helpers", () => {
);
expect(await getExtraTagsForVersion({ version: "v1.75.1-beta" })).toEqual(
- ["v0.75.x", "v1.75.x", "v0.75.1.x", "v1.75.1.x"],
+ ["v0.75.x", "v0.75.1.x", "v1.75.x", "v1.75.1.x"],
);
expect(
await getExtraTagsForVersion({ version: "v0.75.1.2-beta" }),
- ).toEqual(["v0.75.x", "v1.75.x", "v0.75.1.x", "v1.75.1.x"]);
+ ).toEqual(["v0.75.x", "v0.75.1.x", "v1.75.x", "v1.75.1.x"]);
});
it("should add latest tag when version major matches latestMajorVersion", async () => {
@@ -875,14 +875,14 @@ describe("version-helpers", () => {
version: "v0.58.1",
latestMajorVersion: "58",
}),
- ).toEqual(["v0.58.x", "v1.58.x", "v0.58.1.x", "v1.58.1.x", "latest"]);
+ ).toEqual(["latest", "v0.58.x", "v0.58.1.x", "v1.58.x", "v1.58.1.x"]);
expect(
await getExtraTagsForVersion({
version: "v1.58.2",
latestMajorVersion: "58",
}),
- ).toEqual(["v0.58.x", "v1.58.x", "v0.58.2.x", "v1.58.2.x", "latest"]);
+ ).toEqual(["latest", "v0.58.x", "v0.58.2.x", "v1.58.x", "v1.58.2.x"]);
});
it("should add latest tag for major versions when major matches latestMajorVersion", async () => {
@@ -891,7 +891,7 @@ describe("version-helpers", () => {
version: "v0.58.0",
latestMajorVersion: "58",
}),
- ).toEqual(["v0.58.x", "v1.58.x", "latest"]);
+ ).toEqual(["latest", "v0.58.x", "v1.58.x"]);
});
it("should add latest tag for patch versions when major matches latestMajorVersion", async () => {
@@ -900,7 +900,7 @@ describe("version-helpers", () => {
version: "v0.58.1.3",
latestMajorVersion: "58",
}),
- ).toEqual(["v0.58.x", "v1.58.x", "v0.58.1.x", "v1.58.1.x", "latest"]);
+ ).toEqual(["latest", "v0.58.x", "v0.58.1.x", "v1.58.x", "v1.58.1.x"]);
});
it("should NOT add latest tag when version major does not match latestMajorVersion", async () => {
@@ -909,7 +909,7 @@ describe("version-helpers", () => {
version: "v0.57.5",
latestMajorVersion: "58",
}),
- ).toEqual(["v0.57.x", "v1.57.x", "v0.57.5.x", "v1.57.5.x"]);
+ ).toEqual(["v0.57.x", "v0.57.5.x", "v1.57.x", "v1.57.5.x"]);
expect(
await getExtraTagsForVersion({
@@ -925,21 +925,21 @@ describe("version-helpers", () => {
version: "v0.58.1-rc1",
latestMajorVersion: "58",
}),
- ).toEqual(["v0.58.x", "v1.58.x", "v0.58.1.x", "v1.58.1.x", "latest"]);
+ ).toEqual(["latest", "v0.58.x", "v0.58.1.x", "v1.58.x", "v1.58.1.x"]);
expect(
await getExtraTagsForVersion({
version: "v0.58.0-beta",
latestMajorVersion: "58",
}),
- ).toEqual(["v0.58.x", "v1.58.x", "latest"]);
+ ).toEqual(["latest", "v0.58.x", "v1.58.x"]);
});
it("should NOT add latest tag when latestMajorVersion is not provided", async () => {
expect(await getExtraTagsForVersion({ version: "v0.58.1" })).toEqual([
"v0.58.x",
- "v1.58.x",
"v0.58.1.x",
+ "v1.58.x",
"v1.58.1.x",
]);
@@ -948,17 +948,17 @@ describe("version-helpers", () => {
version: "v0.58.1",
latestMajorVersion: "",
}),
- ).toEqual(["v0.58.x", "v1.58.x", "v0.58.1.x", "v1.58.1.x"]);
+ ).toEqual(["v0.58.x", "v0.58.1.x", "v1.58.x", "v1.58.1.x"]);
});
it("should append a <major>-lts tag when isLtsVersion is true", async () => {
mockIsLtsVersion.mockResolvedValue(true);
expect(await getExtraTagsForVersion({ version: "v0.75.0" })).toEqual([
- "v0.75.x",
- "v1.75.x",
"v0.75-lts",
+ "v0.75.x",
"v1.75-lts",
+ "v1.75.x",
]);
});
});