Skip to content
Open
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
4 changes: 2 additions & 2 deletions functions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Utlity functions
# Utility functions
# Don't change this file unless needed
# The GitHub Action for automating new builds rely on this file

Expand All @@ -19,7 +19,7 @@ fatal() {
#
# This is used to get the target architecture for docker image.
# For crossing building, we need a way to specify the target
# architecutre manually.
# architecture manually.
function get_arch() {
local arch
case $(uname -m) in
Expand Down
4 changes: 2 additions & 2 deletions genMatrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const getChildDirectories = (parent) => fs.readdirSync(parent, { withFileTypes:
.filter((dirent) => dirent.isDirectory())
.map(({ name }) => path.resolve(parent, name));

const getNodeVerionDirs = (base) => getChildDirectories(base)
const getNodeVersionDirs = (base) => getChildDirectories(base)
.filter((childPath) => nodeDirRegex.test(path.basename(childPath)));

// Returns the paths of Dockerfiles that are at: base/*/Dockerfile
const getDockerfilesInChildDirs = (base) => getChildDirectories(base)
.map((childDir) => path.resolve(childDir, 'Dockerfile'));

const getAllDockerfiles = (base) => getNodeVerionDirs(base).flatMap(getDockerfilesInChildDirs);
const getAllDockerfiles = (base) => getNodeVersionDirs(base).flatMap(getDockerfilesInChildDirs);

const getAffectedDockerfiles = (filesAdded, filesModified, filesRenamed) => {
const files = [
Expand Down
50 changes: 23 additions & 27 deletions stackbrew.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ const versions = Object.keys(config).reverse()
let midnight = new Date()
midnight.setHours(0, 0, 0, 0)
const now = midnight.getTime()
const aplineRE = new RegExp(/alpine*/);
const alpineRE = new RegExp(/alpine*/);
const slimRE = new RegExp(/\*-slim/);
let foundLTS = false;
let foundCurrent = false;

for (version of versions) {
for (const version of versions) {
let lts = new Date(`${config[version].lts}T00:00:00.00`).getTime();
let maintenance = new Date(`${config[version].maintenance}T00:00:00.00`).getTime();
let isCurrent = foundCurrent ? false : isNaN(lts) || lts >= now;
foundCurrent = isCurrent || foundCurrent;
let isLTS = foundLTS ? false : (now >= lts);
Expand All @@ -44,53 +43,52 @@ for (version of versions) {
let defaultAlpine = config[version]['alpine-default']
let defaultDebian = config[version]['debian-default']
let variants = config[version].variants
let fullversion;
for (variant in variants) {
for (const variant in variants) {
let dockerfilePath = path.join(version, variant, 'Dockerfile');
let isAlpine = aplineRE.test(variant)
let isAlpine = alpineRE.test(variant)
let isSlim = slimRE.test(variant)
let isDefaultSlim = new RegExp(`${defaultDebian}-slim`).test(variant)

// Get full version from the Dockerfile
let dockerfile = fs.readFileSync(dockerfilePath, 'utf-8')
fullversion = dockerfile.match(/ENV NODE_VERSION=(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/)
let fullVersion = dockerfile.match(/ENV NODE_VERSION=(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/)

let tags = [
`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-${variant}`,
`${fullversion.groups.major}.${fullversion.groups.minor}-${variant}`,
`${fullversion.groups.major}-${variant}`,
`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-${variant}`,
`${fullVersion.groups.major}.${fullVersion.groups.minor}-${variant}`,
`${fullVersion.groups.major}-${variant}`,
]

if (codename) {
tags.push(`${codename}-${variant}`)
}

if (variant === defaultAlpine) {
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-alpine`)
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}-alpine`)
tags.push(`${fullversion.groups.major}-alpine`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-alpine`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}-alpine`)
tags.push(`${fullVersion.groups.major}-alpine`)
if (codename) {
tags.push(`${codename}-alpine`)
}
}

if (variant === defaultDebian) {
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}`)
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}`)
tags.push(`${fullversion.groups.major}`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}`)
tags.push(`${fullVersion.groups.major}`)
if (isSlim) {
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-slim`)
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}-slim`)
tags.push(`${fullversion.groups.major}-slim`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-slim`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}-slim`)
tags.push(`${fullVersion.groups.major}-slim`)
}
if (codename) {
tags.push(`${codename}`)
}
}
if (isDefaultSlim) {
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-slim`)
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}-slim`)
tags.push(`${fullversion.groups.major}-slim`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-slim`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}-slim`)
tags.push(`${fullVersion.groups.major}-slim`)
if (codename) {
tags.push(`${codename}-slim`)
}
Expand All @@ -99,9 +97,9 @@ for (version of versions) {
if (isCurrent) {
if (variant === defaultAlpine) {
tags.push(variant)
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-alpine`)
tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}-alpine`)
tags.push(`${fullversion.groups.major}-alpine`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-alpine`)
tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}-alpine`)
tags.push(`${fullVersion.groups.major}-alpine`)
tags.push('alpine')
tags.push('current-alpine')
}
Expand All @@ -126,8 +124,6 @@ for (version of versions) {

if (isLTS) {
tags.push(`lts-${variant}`)
if (variant === defaultAlpine) {
}
if (variant === defaultDebian) {
tags.push('lts')
if (codename) {
Expand Down