Publish docker images to ghcr.io (#5311)
This commit is contained in:
parent
5864c6dd88
commit
5bcde56a0f
|
@ -6,14 +6,13 @@ import {
|
|||
checkDocker,
|
||||
checkTagExists,
|
||||
checkVersionFormat,
|
||||
dryRun,
|
||||
getRepoName,
|
||||
getRepoNames,
|
||||
pressAnyKey,
|
||||
execSync, uploadArtifacts,
|
||||
} from "./lib.mjs";
|
||||
import semver from "semver";
|
||||
|
||||
const repoName = getRepoName();
|
||||
const repoNames = getRepoNames();
|
||||
const version = process.env.RELEASE_BETA_VERSION;
|
||||
const githubToken = process.env.RELEASE_GITHUB_TOKEN;
|
||||
|
||||
|
@ -39,7 +38,7 @@ if (semverIdentifier[0] !== "beta") {
|
|||
checkDocker();
|
||||
|
||||
// Check if the tag exists
|
||||
await checkTagExists(repoName, version);
|
||||
await checkTagExists(repoNames, version);
|
||||
|
||||
// node extra/beta/update-version.js
|
||||
execSync("node ./extra/beta/update-version.js");
|
||||
|
@ -48,16 +47,16 @@ execSync("node ./extra/beta/update-version.js");
|
|||
buildDist();
|
||||
|
||||
// Build slim image (rootless)
|
||||
buildImage(repoName, [ "beta-slim-rootless", ver(version, "slim-rootless") ], "rootless", "BASE_IMAGE=louislam/uptime-kuma:base2-slim");
|
||||
buildImage(repoNames, [ "beta-slim-rootless", ver(version, "slim-rootless") ], "rootless", "BASE_IMAGE=louislam/uptime-kuma:base2-slim");
|
||||
|
||||
// Build full image (rootless)
|
||||
buildImage(repoName, [ "beta-rootless", ver(version, "rootless") ], "rootless");
|
||||
buildImage(repoNames, [ "beta-rootless", ver(version, "rootless") ], "rootless");
|
||||
|
||||
// Build slim image
|
||||
buildImage(repoName, [ "beta-slim", ver(version, "slim") ], "release", "BASE_IMAGE=louislam/uptime-kuma:base2-slim");
|
||||
buildImage(repoNames, [ "beta-slim", ver(version, "slim") ], "release", "BASE_IMAGE=louislam/uptime-kuma:base2-slim");
|
||||
|
||||
// Build full image
|
||||
buildImage(repoName, [ "beta", version ], "release");
|
||||
buildImage(repoNames, [ "beta", version ], "release");
|
||||
|
||||
await pressAnyKey();
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ import {
|
|||
checkDocker,
|
||||
checkTagExists,
|
||||
checkVersionFormat,
|
||||
getRepoName,
|
||||
getRepoNames,
|
||||
pressAnyKey, execSync, uploadArtifacts
|
||||
} from "./lib.mjs";
|
||||
|
||||
const repoName = getRepoName();
|
||||
const repoNames = getRepoNames();
|
||||
const version = process.env.RELEASE_VERSION;
|
||||
const githubToken = process.env.RELEASE_GITHUB_TOKEN;
|
||||
|
||||
|
@ -28,7 +28,7 @@ checkVersionFormat(version);
|
|||
checkDocker();
|
||||
|
||||
// Check if the tag exists
|
||||
await checkTagExists(repoName, version);
|
||||
await checkTagExists(repoNames, version);
|
||||
|
||||
// node extra/beta/update-version.js
|
||||
execSync("node extra/update-version.js");
|
||||
|
@ -37,16 +37,16 @@ execSync("node extra/update-version.js");
|
|||
buildDist();
|
||||
|
||||
// Build slim image (rootless)
|
||||
buildImage(repoName, [ "2-slim-rootless", ver(version, "slim-rootless") ], "rootless", "BASE_IMAGE=louislam/uptime-kuma:base2-slim");
|
||||
buildImage(repoNames, [ "2-slim-rootless", ver(version, "slim-rootless") ], "rootless", "BASE_IMAGE=louislam/uptime-kuma:base2-slim");
|
||||
|
||||
// Build full image (rootless)
|
||||
buildImage(repoName, [ "2-rootless", ver(version, "rootless") ], "rootless");
|
||||
buildImage(repoNames, [ "2-rootless", ver(version, "rootless") ], "rootless");
|
||||
|
||||
// Build slim image
|
||||
buildImage(repoName, [ "next-slim", "2-slim", ver(version, "slim") ], "release", "BASE_IMAGE=louislam/uptime-kuma:base2-slim");
|
||||
buildImage(repoNames, [ "next-slim", "2-slim", ver(version, "slim") ], "release", "BASE_IMAGE=louislam/uptime-kuma:base2-slim");
|
||||
|
||||
// Build full image
|
||||
buildImage(repoName, [ "next", "2", version ], "release");
|
||||
buildImage(repoNames, [ "next", "2", version ], "release");
|
||||
|
||||
await pressAnyKey();
|
||||
|
||||
|
|
|
@ -24,8 +24,15 @@ export function checkDocker() {
|
|||
/**
|
||||
* Get Docker Hub repository name
|
||||
*/
|
||||
export function getRepoName() {
|
||||
return process.env.RELEASE_REPO_NAME || "louislam/uptime-kuma";
|
||||
export function getRepoNames() {
|
||||
if (process.env.RELEASE_REPO_NAMES) {
|
||||
// Split by comma
|
||||
return process.env.RELEASE_REPO_NAMES.split(",").map((name) => name.trim());
|
||||
}
|
||||
return [
|
||||
"louislam/uptime-kuma",
|
||||
"ghcr.io/louislam/uptime-kuma",
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +49,7 @@ export function buildDist() {
|
|||
|
||||
/**
|
||||
* Build docker image and push to Docker Hub
|
||||
* @param {string} repoName Docker Hub repository name
|
||||
* @param {string[]} repoNames Docker Hub repository names
|
||||
* @param {string[]} tags Docker image tags
|
||||
* @param {string} target Dockerfile's target name
|
||||
* @param {string} buildArgs Docker build args
|
||||
|
@ -50,7 +57,7 @@ export function buildDist() {
|
|||
* @param {string} platform Build platform
|
||||
* @returns {void}
|
||||
*/
|
||||
export function buildImage(repoName, tags, target, buildArgs = "", dockerfile = "docker/dockerfile", platform = "linux/amd64,linux/arm64,linux/arm/v7") {
|
||||
export function buildImage(repoNames, tags, target, buildArgs = "", dockerfile = "docker/dockerfile", platform = "linux/amd64,linux/arm64,linux/arm/v7") {
|
||||
let args = [
|
||||
"buildx",
|
||||
"build",
|
||||
|
@ -60,9 +67,11 @@ export function buildImage(repoName, tags, target, buildArgs = "", dockerfile =
|
|||
platform,
|
||||
];
|
||||
|
||||
// Add tags
|
||||
for (let tag of tags) {
|
||||
args.push("-t", `${repoName}:${tag}`);
|
||||
for (let repoName of repoNames) {
|
||||
// Add tags
|
||||
for (let tag of tags) {
|
||||
args.push("-t", `${repoName}:${tag}`);
|
||||
}
|
||||
}
|
||||
|
||||
args = [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { buildDist, buildImage, checkDocker, getRepoName } from "./lib.mjs";
|
||||
import { buildDist, buildImage, checkDocker, getRepoNames } from "./lib.mjs";
|
||||
|
||||
// Docker Hub repository name
|
||||
const repoName = getRepoName();
|
||||
const repoNames = getRepoNames();
|
||||
|
||||
// Check if docker is running
|
||||
checkDocker();
|
||||
|
@ -10,7 +10,7 @@ checkDocker();
|
|||
buildDist();
|
||||
|
||||
// Build full image (rootless)
|
||||
buildImage(repoName, [ "nightly2-rootless" ], "nightly-rootless");
|
||||
buildImage(repoNames, [ "nightly2-rootless" ], "nightly-rootless");
|
||||
|
||||
// Build full image
|
||||
buildImage(repoName, [ "nightly2" ], "nightly");
|
||||
buildImage(repoNames, [ "nightly2" ], "nightly");
|
||||
|
|
Loading…
Reference in New Issue