Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
c978cdc
fix
raeessap Mar 19, 2026
1c069af
fix
raeessap Mar 19, 2026
90adea5
fix
raeessap Mar 19, 2026
114891c
fix
raeessap Mar 19, 2026
d5ba44a
fix
raeessap Mar 19, 2026
3b74a8a
fix
raeessap Mar 19, 2026
02b749d
fix
raeessap Mar 19, 2026
f35b63c
ff
raeessap Mar 19, 2026
0e71307
l
raeessap Mar 19, 2026
e1e99b3
gg
raeessap Mar 19, 2026
134bdcf
lll
raeessap Mar 19, 2026
7229fe0
Update known SapMachine/GardenLinux versions
SapMachine Mar 19, 2026
afb0d54
fixe
raeessap Mar 20, 2026
615d5cc
Update known SapMachine/GardenLinux versions
SapMachine Mar 20, 2026
4184d4e
555
raeessap Mar 20, 2026
e04cbd0
Update known SapMachine/GardenLinux versions
SapMachine Mar 20, 2026
ca51b1f
66
raeessap Mar 20, 2026
145dc71
Update known SapMachine/GardenLinux versions
SapMachine Mar 20, 2026
bb4c85e
test it
raeessap Mar 20, 2026
0a9745a
Merge remote-tracking branch 'refs/remotes/origin/pub_imgs_2' into pu…
raeessap Mar 20, 2026
f1a7694
pp
raeessap Mar 20, 2026
e81e836
oooo
raeessap Mar 20, 2026
5118ae7
Update known SapMachine/GardenLinux versions
SapMachine Mar 20, 2026
7977162
99
raeessap Mar 20, 2026
f47e08b
369
raeessap Mar 20, 2026
df6ddf2
Update known SapMachine/GardenLinux versions
SapMachine Mar 20, 2026
dcfa14a
88
raeessap Mar 20, 2026
f8b10b2
jkjk
raeessap Mar 20, 2026
b2f0170
op
raeessap Mar 20, 2026
5404a37
tex
raeessap Mar 20, 2026
496966d
CVCV
raeessap Mar 20, 2026
4325c48
xxx
raeessap Mar 20, 2026
034db38
kk
raeessap Mar 23, 2026
b4851a4
pp
raeessap Mar 23, 2026
f8c54a1
mm
raeessap Mar 23, 2026
a9c712c
uu
raeessap Mar 23, 2026
e0e2079
oo
raeessap Mar 23, 2026
024ceca
popo
raeessap Mar 23, 2026
ed33a76
Update known SapMachine/GardenLinux versions
SapMachine Mar 23, 2026
c0efe37
Merge remote-tracking branch 'origin/master' into pub_imgs_2
raeessap Mar 23, 2026
6e8f0fd
oo
raeessap Mar 24, 2026
0f3486c
Update known SapMachine/GardenLinux versions
SapMachine Mar 24, 2026
574f3e6
cc
raeessap Mar 24, 2026
097fd86
Update known SapMachine/GardenLinux versions
SapMachine Mar 24, 2026
17470cf
popo
raeessap Mar 24, 2026
e79f77a
Update known SapMachine/GardenLinux versions
SapMachine Mar 24, 2026
f405e89
Real Push of 2150
raeessap Mar 24, 2026
80bda84
9090
raeessap Mar 24, 2026
897fbca
Update known SapMachine/GardenLinux versions
SapMachine Mar 24, 2026
cf81668
Real test of 2150 with several tags
raeessap Mar 24, 2026
2676c38
Update known SapMachine/GardenLinux versions
SapMachine Mar 24, 2026
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
12 changes: 12 additions & 0 deletions .github/known-versions/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"sapmachine": {
"26": "26",
"25": "25.0.2",
"21": "21.0.10.0.1",
"17": "17.0.18"
},
"gardenlinux": {
"2150": "2150.0.0",
"1877": "1877.14"
}
}
300 changes: 300 additions & 0 deletions .github/scripts/detect-new-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
#!/usr/bin/env bash
# ==============================================================================
# detect-new-versions.sh
#
# Detects newer versions of SapMachine and GardenLinux compared to the known
# versions stored in .github/known-versions/versions.json
#
# GardenLinux is tracked as a map of {major: latest_minor_version} so we can
# detect both new majors and new minor patch releases within a major.
# The minor version is used in Dockerfiles for reproducibility:
# FROM ghcr.io/gardenlinux/gardenlinux:1592.18
#
# Outputs (as GitHub Actions outputs via $GITHUB_OUTPUT):
# new_sm_versions - JSON array of {major, version} objects for new SapMachine releases
# new_gl_versions - JSON array of {major, version} objects for new GardenLinux releases
# has_new_versions - "true" if any new version was detected
# build_matrix - JSON matrix of {sm_major, sm_version, gl_major, gl_version} combinations
# ==============================================================================
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
KNOWN_VERSIONS_FILE="${REPO_ROOT}/.github/known-versions/versions.json"

# ---------------------------------------------------------------------------
# 1. Load known versions
# ---------------------------------------------------------------------------
echo "::group::Loading known versions"
if [[ ! -f "${KNOWN_VERSIONS_FILE}" ]]; then
echo "ERROR: ${KNOWN_VERSIONS_FILE} not found"
exit 1
fi
cat "${KNOWN_VERSIONS_FILE}"
echo ""
echo "::endgroup::"

#KNOWN_SM_MAJORS=$(jq -r '.sapmachine | keys[]' "${KNOWN_VERSIONS_FILE}")

# ---------------------------------------------------------------------------
# 2. Fetch current SapMachine GA versions
# ---------------------------------------------------------------------------
echo "::group::Fetching SapMachine releases"
SM_JSON=$(curl -fsSL "https://sapmachine.io/assets/data/sapmachine-releases-latest.json")

# Extract GA (non-ea) releases. For each, get the major version and the full
# version from the first release tag. Tag format: "sapmachine-<version>"
declare -A CURRENT_SM_VERSIONS
for key in $(echo "${SM_JSON}" | jq -r 'to_entries[] | select(.value.ea == false) | .key'); do
major="${key}" # e.g. "17", "21", "25", "26"
tag=$(echo "${SM_JSON}" | jq -r --arg k "${key}" '.[$k].releases[0].tag')
# tag is like "sapmachine-17.0.18" or "sapmachine-25.0.2" or "sapmachine-26"
version="${tag#sapmachine-}"
CURRENT_SM_VERSIONS["${major}"]="${version}"
echo " SapMachine ${major} (GA): ${version}"
done
echo "::endgroup::"

# ---------------------------------------------------------------------------
# 3. Fetch current active GardenLinux minor versions (latest per major)
# ---------------------------------------------------------------------------
echo "::group::Fetching GardenLinux active minor versions"
# Use the glrd container with JSON output to get all active minor releases,
# then extract the latest (highest) minor version per major.
GL_JSON=$(docker run --rm ghcr.io/gardenlinux/glrd "glrd --active --type minor --output-format json" 2>/dev/null || echo '{"releases":[]}')

# Build a map: gl_major → latest minor version string (e.g. "1592" → "1592.18")
# For versions < 2017: format is major.minor (e.g. 1592.18)
# For versions >= 2017: format is major.minor.patch (e.g. 2017.0.0)
declare -A CURRENT_GL_VERSIONS
if [[ "$(echo "${GL_JSON}" | jq '.releases | length')" -gt 0 ]]; then
# Group by major, take the one with the highest minor (and patch) per major
while IFS='|' read -r gl_major gl_minor_ver; do
CURRENT_GL_VERSIONS["${gl_major}"]="${gl_minor_ver}"
echo " GardenLinux ${gl_major} latest minor: ${gl_minor_ver}"
done < <(echo "${GL_JSON}" | jq -r '
[.releases[] | {
major: (.version.major | tostring),
minor: .version.minor,
patch: (.version.patch // null),
version_str: (
if .version.patch != null then
"\(.version.major).\(.version.minor).\(.version.patch)"
else
"\(.version.major).\(.version.minor)"
end
)
}]
| group_by(.major)
| map(sort_by(.minor, .patch) | last)
| .[]
| "\(.major)|\(.version_str)"
')
else
echo " WARNING: Could not fetch GardenLinux versions from glrd container."
echo " Falling back to known versions only."
# Load known versions as fallback
while IFS='=' read -r gl_major gl_ver; do
CURRENT_GL_VERSIONS["${gl_major}"]="${gl_ver}"
done < <(jq -r '.gardenlinux | to_entries[] | "\(.key)=\(.value)"' "${KNOWN_VERSIONS_FILE}")
fi
echo "::endgroup::"

# ---------------------------------------------------------------------------
# 4. Determine new SapMachine versions
# ---------------------------------------------------------------------------
echo "::group::Detecting new SapMachine versions"
declare -a NEW_SM_ITEMS=() # each item: "major:version"

for major in "${!CURRENT_SM_VERSIONS[@]}"; do
current_ver="${CURRENT_SM_VERSIONS[$major]}"
known_ver=$(jq -r --arg m "${major}" '.sapmachine[$m] // ""' "${KNOWN_VERSIONS_FILE}")

if [[ -z "${known_ver}" ]]; then
echo " NEW SapMachine major ${major}: ${current_ver} (not previously tracked)"
NEW_SM_ITEMS+=("${major}:${current_ver}")
elif [[ "${current_ver}" != "${known_ver}" ]]; then
echo " UPDATED SapMachine ${major}: ${known_ver} -> ${current_ver}"
NEW_SM_ITEMS+=("${major}:${current_ver}")
else
echo " SapMachine ${major}: ${current_ver} (unchanged)"
fi
done
echo "::endgroup::"

# ---------------------------------------------------------------------------
# 5. Determine new GardenLinux versions (new major or updated minor)
# ---------------------------------------------------------------------------
echo "::group::Detecting new GardenLinux versions"
declare -a NEW_GL_ITEMS=() # each item: "major:minor_version"

for gl_major in "${!CURRENT_GL_VERSIONS[@]}"; do
current_minor="${CURRENT_GL_VERSIONS[$gl_major]}"
known_minor=$(jq -r --arg m "${gl_major}" '.gardenlinux[$m] // ""' "${KNOWN_VERSIONS_FILE}")

if [[ -z "${known_minor}" ]]; then
echo " NEW GardenLinux major ${gl_major}: ${current_minor} (not previously tracked)"
NEW_GL_ITEMS+=("${gl_major}:${current_minor}")
elif [[ "${current_minor}" != "${known_minor}" ]]; then
echo " UPDATED GardenLinux ${gl_major}: ${known_minor} -> ${current_minor}"
NEW_GL_ITEMS+=("${gl_major}:${current_minor}")
else
echo " GardenLinux ${gl_major}: ${current_minor} (unchanged)"
fi
done
echo "::endgroup::"

# ---------------------------------------------------------------------------
# 6. Build the matrix of (sm_major, sm_version, gl_major, gl_version) combos
# ---------------------------------------------------------------------------
echo "::group::Building matrix"

# Use ONLY the current versions from sources — not the known file.
# This ensures stale versions (no longer active) never appear in the matrix.
# shellcheck disable=SC2034
declare -n ALL_SM_VERSIONS=CURRENT_SM_VERSIONS
# shellcheck disable=SC2034
declare -n ALL_GL_VERSIONS=CURRENT_GL_VERSIONS

MATRIX_JSON="[]"

has_new_sm=$( [[ ${#NEW_SM_ITEMS[@]} -gt 0 ]] && echo "true" || echo "false" )
has_new_gl=$( [[ ${#NEW_GL_ITEMS[@]} -gt 0 ]] && echo "true" || echo "false" )

if [[ "${has_new_sm}" == "true" && "${has_new_gl}" == "true" ]]; then
# Both new → full cross-product of ALL SM × ALL GL
echo " Both SapMachine and GardenLinux have new versions → full rebuild"
for sm_major in "${!ALL_SM_VERSIONS[@]}"; do
sm_ver="${ALL_SM_VERSIONS[$sm_major]}"
for gl_major in "${!ALL_GL_VERSIONS[@]}"; do
gl_ver="${ALL_GL_VERSIONS[$gl_major]}"
MATRIX_JSON=$(echo "${MATRIX_JSON}" | jq \
--arg sm "$sm_major" --arg sv "$sm_ver" --arg gm "$gl_major" --arg gv "$gl_ver" \
'. + [{"sm_major": $sm, "sm_version": $sv, "gl_major": $gm, "gl_version": $gv}]')
done
done

elif [[ "${has_new_sm}" == "true" ]]; then
# Only new SM versions → new SM × ALL GL
echo " Only SapMachine has new versions → new SM × all GL"
for item in "${NEW_SM_ITEMS[@]}"; do
sm_major="${item%%:*}"
sm_ver="${item#*:}"
for gl_major in "${!ALL_GL_VERSIONS[@]}"; do
gl_ver="${ALL_GL_VERSIONS[$gl_major]}"
MATRIX_JSON=$(echo "${MATRIX_JSON}" | jq \
--arg sm "$sm_major" --arg sv "$sm_ver" --arg gm "$gl_major" --arg gv "$gl_ver" \
'. + [{"sm_major": $sm, "sm_version": $sv, "gl_major": $gm, "gl_version": $gv}]')
done
done

elif [[ "${has_new_gl}" == "true" ]]; then
# Only new GL versions → ALL SM × new GL
echo " Only GardenLinux has new versions → all SM × new GL"
for sm_major in "${!ALL_SM_VERSIONS[@]}"; do
sm_ver="${ALL_SM_VERSIONS[$sm_major]}"
for item in "${NEW_GL_ITEMS[@]}"; do
gl_major="${item%%:*}"
gl_ver="${item#*:}"
MATRIX_JSON=$(echo "${MATRIX_JSON}" | jq \
--arg sm "$sm_major" --arg sv "$sm_ver" --arg gm "$gl_major" --arg gv "$gl_ver" \
'. + [{"sm_major": $sm, "sm_version": $sv, "gl_major": $gm, "gl_version": $gv}]')
done
done

else
echo " No new versions detected — nothing to build."
fi

MATRIX_COUNT=$(echo "${MATRIX_JSON}" | jq 'length')
echo " Total build combinations: ${MATRIX_COUNT}"
echo "${MATRIX_JSON}" | jq '.'
echo "::endgroup::"

# ---------------------------------------------------------------------------
# 7. Produce outputs
# ---------------------------------------------------------------------------
HAS_NEW="false"
if [[ "${has_new_sm}" == "true" || "${has_new_gl}" == "true" ]]; then
HAS_NEW="true"
fi

# Build new_sm_versions JSON array
SM_OUT="[]"
if [[ ${#NEW_SM_ITEMS[@]} -gt 0 ]]; then
for item in "${NEW_SM_ITEMS[@]}"; do
major="${item%%:*}"
ver="${item#*:}"
SM_OUT=$(echo "${SM_OUT}" | jq --arg m "${major}" --arg v "${ver}" '. + [{"major": $m, "version": $v}]')
done
fi

# Build new_gl_versions JSON array
GL_OUT="[]"
if [[ ${#NEW_GL_ITEMS[@]} -gt 0 ]]; then
for item in "${NEW_GL_ITEMS[@]}"; do
gl_major="${item%%:*}"
gl_ver="${item#*:}"
GL_OUT=$(echo "${GL_OUT}" | jq --arg m "${gl_major}" --arg v "${gl_ver}" '. + [{"major": $m, "version": $v}]')
done
fi

# Build full current-state JSON maps (for overriding versions.json in Job 3)
ALL_SM_JSON='{}'
for major in "${!CURRENT_SM_VERSIONS[@]}"; do
ver="${CURRENT_SM_VERSIONS[$major]}"
ALL_SM_JSON=$(echo "${ALL_SM_JSON}" | jq -c --arg m "${major}" --arg v "${ver}" '.[$m] = $v')
done

ALL_GL_JSON='{}'
for gl_major in "${!CURRENT_GL_VERSIONS[@]}"; do
gl_ver="${CURRENT_GL_VERSIONS[$gl_major]}"
ALL_GL_JSON=$(echo "${ALL_GL_JSON}" | jq -c --arg m "${gl_major}" --arg v "${gl_ver}" '.[$m] = $v')
done

# Write to GITHUB_OUTPUT – all JSON values MUST be compact (single-line)
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
{
echo "has_new_versions=${HAS_NEW}"
echo "new_sm_versions=$(echo "${SM_OUT}" | jq -c '.')"
echo "new_gl_versions=$(echo "${GL_OUT}" | jq -c '.')"
echo "build_matrix=$(echo "${MATRIX_JSON}" | jq -c '.')"
echo "all_sm_versions=$(echo "${ALL_SM_JSON}" | jq -c '.')"
echo "all_gl_versions=$(echo "${ALL_GL_JSON}" | jq -c '.')"
} >> "${GITHUB_OUTPUT}"
else
# For local testing
echo ""
echo "===== OUTPUTS ====="
echo "has_new_versions=${HAS_NEW}"
echo "new_sm_versions=${SM_OUT}"
echo "new_gl_versions=${GL_OUT}"
echo "build_matrix=${MATRIX_JSON}"
echo "all_sm_versions=${ALL_SM_JSON}"
echo "all_gl_versions=${ALL_GL_JSON}"
fi

# ---------------------------------------------------------------------------
# 8. Override the known versions file with current data from sources
# This completely replaces the file – stale versions (e.g. a GL major
# that is no longer active, or an SM version that was removed) are dropped.
# ---------------------------------------------------------------------------
echo "::group::Overriding known versions file with current source data"

# Build fresh JSON from CURRENT_SM_VERSIONS and CURRENT_GL_VERSIONS only
FRESH_JSON='{"sapmachine": {}, "gardenlinux": {}}'

for major in "${!CURRENT_SM_VERSIONS[@]}"; do
ver="${CURRENT_SM_VERSIONS[$major]}"
FRESH_JSON=$(echo "${FRESH_JSON}" | jq --arg m "${major}" --arg v "${ver}" '.sapmachine[$m] = $v')
done

for gl_major in "${!CURRENT_GL_VERSIONS[@]}"; do
gl_ver="${CURRENT_GL_VERSIONS[$gl_major]}"
FRESH_JSON=$(echo "${FRESH_JSON}" | jq --arg m "${gl_major}" --arg v "${gl_ver}" '.gardenlinux[$m] = $v')
done

echo "${FRESH_JSON}" | jq '.' > "${KNOWN_VERSIONS_FILE}"
echo "Overwritten ${KNOWN_VERSIONS_FILE} with current source data:"
cat "${KNOWN_VERSIONS_FILE}"
echo "::endgroup::"
54 changes: 54 additions & 0 deletions .github/scripts/generate-dockerfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# ==============================================================================
# generate-dockerfile.sh
#
# Generates a Dockerfile for a given SapMachine major version, full version,
# GardenLinux minor version, and flavour (jdk, jdk-headless, jre, jre-headless).
#
# Usage:
# ./generate-dockerfile.sh <sm_major> <sm_version> <gl_version> <flavour> <output_dir>
#
# The gl_version should be the full minor version (e.g. 1592.18) which is used
# as the exact Docker base image tag for reproducibility.
#
# Example:
# ./generate-dockerfile.sh 21 21.0.12 1592.18 jdk /tmp/build
# ==============================================================================
set -euo pipefail

SM_MAJOR="${1:?Usage: $0 <sm_major> <sm_version> <gl_version> <flavour> <output_dir>}"
SM_VERSION="${2:?}"
GL_VERSION="${3:?}"
FLAVOUR="${4:?}"
OUTPUT_DIR="${5:?}"

mkdir -p "${OUTPUT_DIR}"

# Determine CMD based on flavour
if [[ "${FLAVOUR}" == jdk* ]]; then
CMD='["jshell"]'
else
CMD='["bash"]'
fi

cat > "${OUTPUT_DIR}/Dockerfile" <<EOF
FROM ghcr.io/gardenlinux/gardenlinux:${GL_VERSION}

ENV LANG=C.UTF-8
ENV JAVA_VERSION=${SM_VERSION}
ENV MALLOC_ARENA_MAX=1

ADD --chmod=644 --chown=root:root https://dist.sapmachine.io/debian/sapmachine.key /etc/apt/trusted.gpg.d/sapmachine.asc

RUN echo "deb https://dist.sapmachine.io/debian/\$(dpkg --print-architecture)/ ./" > /etc/apt/sources.list.d/sapmachine.list && \\
apt-get update && \\
apt-get -y --no-install-recommends install sapmachine-${SM_MAJOR}-${FLAVOUR}=${SM_VERSION} && \\
rm -rf /var/lib/apt/lists/* && \\
java -XshowSettings:properties -version

ENV JAVA_HOME=/usr/lib/jvm/sapmachine-${SM_MAJOR}

CMD ${CMD}
EOF

echo "Generated Dockerfile at ${OUTPUT_DIR}/Dockerfile"
Loading