Skip to content

Commit 39eeb3a

Browse files
authored
Merge pull request #117 from groovy/multiple-versions
Create images for all supported Groovy versions
2 parents 1f32e09 + 083f73d commit 39eeb3a

File tree

29 files changed

+1270
-58
lines changed

29 files changed

+1270
-58
lines changed

.github/workflows/ci.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,35 @@ jobs:
1616
ci:
1717
runs-on: ubuntu-latest
1818
strategy:
19+
fail-fast: false
1920
matrix:
20-
directory:
21+
groovy-version:
22+
- groovy-3
23+
- groovy-4
24+
- groovy-5
25+
java-version:
26+
- jdk8
2127
- jdk11
2228
- jdk17
2329
- jdk21
30+
variant:
31+
- ''
32+
- '-alpine'
33+
exclude:
34+
- groovy-version: groovy-5
35+
java-version: jdk8
2436
steps:
2537
- name: checkout
2638
uses: actions/checkout@v4
2739
- name: build
2840
run: |
29-
cd "${{ matrix.directory }}"
41+
cd "${{ matrix.groovy-version }}/${{ matrix.java-version }}${{ matrix.variant }}"
3042
grep "FROM " Dockerfile | cut -d' ' -f2 | xargs -I{} docker pull {}
31-
docker build --tag "groovy:${{ matrix.directory }}" .
43+
docker build --tag "groovy:${{ matrix.groovy-version }}-${{ matrix.java-version }}${{ matrix.variant }}" .
3244
- name: test
33-
env:
34-
expectedGroovyVersion: 5.0.4
3545
run: |
46+
# Extract version from Dockerfile
47+
groovyVersion=$(grep "ENV GROOVY_VERSION=" "${{ matrix.groovy-version }}/${{ matrix.java-version }}${{ matrix.variant }}/Dockerfile" | cut -d= -f2)
48+
3649
cd test
37-
./run.sh "groovy:${{ matrix.directory }}" "${expectedGroovyVersion}"
50+
./run.sh "groovy:${{ matrix.groovy-version }}-${{ matrix.java-version }}${{ matrix.variant }}" "${groovyVersion}"

README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,31 @@
22

33
## Supported tags and respective Dockerfile links
44

5-
* [jdk8](https://github.com/groovy/docker-groovy/blob/master/jdk8/Dockerfile)
6-
* [jdk11](https://github.com/groovy/docker-groovy/blob/master/jdk11/Dockerfile)
7-
* [jdk11-alpine](https://github.com/groovy/docker-groovy/blob/master/jdk11-alpine/Dockerfile)
8-
* [jdk17](https://github.com/groovy/docker-groovy/blob/master/jdk17/Dockerfile)
9-
* [jdk17-alpine](https://github.com/groovy/docker-groovy/blob/master/jdk17-alpine/Dockerfile)
10-
* [jdk21](https://github.com/groovy/docker-groovy/blob/master/jdk21/Dockerfile)
11-
* [jdk21-alpine](https://github.com/groovy/docker-groovy/blob/master/jdk21-alpine/Dockerfile)
5+
* Groovy 3
6+
* [jdk8](https://github.com/groovy/docker-groovy/blob/master/groovy-3/jdk8/Dockerfile)
7+
* [jdk8-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-3/jdk8-alpine/Dockerfile)
8+
* [jdk11](https://github.com/groovy/docker-groovy/blob/master/groovy-3/jdk11/Dockerfile)
9+
* [jdk11-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-3/jdk11-alpine/Dockerfile)
10+
* [jdk17](https://github.com/groovy/docker-groovy/blob/master/groovy-3/jdk17/Dockerfile)
11+
* [jdk17-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-3/jdk17-alpine/Dockerfile)
12+
* [jdk21](https://github.com/groovy/docker-groovy/blob/master/groovy-3/jdk21/Dockerfile)
13+
* [jdk21-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-3/jdk21-alpine/Dockerfile)
14+
* Groovy 4
15+
* [jdk8](https://github.com/groovy/docker-groovy/blob/master/groovy-4/jdk8/Dockerfile)
16+
* [jdk8-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-4/jdk8-alpine/Dockerfile)
17+
* [jdk11](https://github.com/groovy/docker-groovy/blob/master/groovy-4/jdk11/Dockerfile)
18+
* [jdk11-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-4/jdk11-alpine/Dockerfile)
19+
* [jdk17](https://github.com/groovy/docker-groovy/blob/master/groovy-4/jdk17/Dockerfile)
20+
* [jdk17-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-4/jdk17-alpine/Dockerfile)
21+
* [jdk21](https://github.com/groovy/docker-groovy/blob/master/groovy-4/jdk21/Dockerfile)
22+
* [jdk21-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-4/jdk21-alpine/Dockerfile)
23+
* Groovy 5
24+
* [jdk11](https://github.com/groovy/docker-groovy/blob/master/groovy-5/jdk11/Dockerfile)
25+
* [jdk11-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-5/jdk11-alpine/Dockerfile)
26+
* [jdk17](https://github.com/groovy/docker-groovy/blob/master/groovy-5/jdk17/Dockerfile)
27+
* [jdk17-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-5/jdk17-alpine/Dockerfile)
28+
* [jdk21](https://github.com/groovy/docker-groovy/blob/master/groovy-5/jdk21/Dockerfile)
29+
* [jdk21-alpine](https://github.com/groovy/docker-groovy/blob/master/groovy-5/jdk21-alpine/Dockerfile)
1230

1331
## What is Groovy?
1432

@@ -70,10 +88,10 @@ Alternatively, you can specify this through the Grapes config, using `-D grape.c
7088
## Instructions for a new Groovy release
7189

7290
1. Run `update.sh <new Groovy version>` or `update.ps1 <new Groovy version>`.
73-
1. If a Groovy contributor did a release for the first time (his/her key added to https://downloads.apache.org/groovy/KEYS),
91+
2. If a Groovy contributor did a release for the first time (his/her key added to https://downloads.apache.org/groovy/KEYS),
7492
add the new key to the list of keys used for verification (this is quite infrequent).
75-
1. Commit and push the changes.
76-
1. Update [official-images](https://github.com/docker-library/official-images) (and [docs](https://github.com/docker-library/docs) if appropriate).
93+
3. Commit and push the changes.
94+
4. Update [official-images](https://github.com/docker-library/official-images) (and [docs](https://github.com/docker-library/docs) if appropriate).
7795

7896
---
7997
[![Build status badge](https://github.com/groovy/docker-groovy/workflows/GitHub%20CI/badge.svg)](https://github.com/groovy/docker-groovy/actions?query=workflow%3A%22GitHub+CI%22)

generate-stackbrew-library.ps1

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ $ErrorActionPreference = "Stop"
77
# front-load the "command-not-found" notices
88
bashbrew --version > $null
99

10-
$gitRemote = (git remote -v | Select-String 'groovy/docker-groovy' | ForEach-Object { $_.Line.Split()[0] })[0]
11-
1210
@"
1311
Maintainers: Keegan Witt <[email protected]> (@keeganwitt)
1412
GitRepo: https://github.com/groovy/docker-groovy.git
@@ -17,10 +15,10 @@ GitRepo: https://github.com/groovy/docker-groovy.git
1715
$usedTags = @{}
1816
$archesLookupCache = @{}
1917

20-
$commit = git rev-parse "refs/remotes/$gitRemote/master"
18+
$commit = git rev-parse HEAD
19+
$branch = git rev-parse --abbrev-ref HEAD
2120
$common = @"
22-
GitFetch: refs/heads/master
23-
GitCommit: $commit
21+
GitFetch: refs/heads/$branch
2422
"@
2523

2624
$allDirectories = git ls-tree -r --name-only "$commit" |
@@ -29,7 +27,12 @@ $allDirectories = git ls-tree -r --name-only "$commit" |
2927

3028
$directoriesWithSortKeys = @()
3129
foreach ($dir in $allDirectories) {
32-
$jdkPart = ($dir -split '-')[0] -replace 'jdk', ''
30+
# dir is like groovy-3/jdk11
31+
$groovyPart = $dir.Split('/')[0].Split('-')[1]
32+
$groovyNum = [int]$groovyPart
33+
$groovySort = -$groovyNum
34+
35+
$jdkPart = $dir.Split('/')[1].Split('-')[0] -replace 'jdk', ''
3336
$jdkNum = [int]$jdkPart
3437

3538
$primaryJdkSort = if ($jdkNum -in @(21, 17, 11, 8)) { 0 } else { 1 }
@@ -43,15 +46,15 @@ foreach ($dir in $allDirectories) {
4346

4447
$directoriesWithSortKeys += [PSCustomObject]@{
4548
Directory = $dir
46-
SortKeys = @($primaryJdkSort, $secondaryJdkSort, $variantSort, $suiteSort, $dir)
49+
SortKeys = @($groovySort, $primaryJdkSort, $secondaryJdkSort, $variantSort, $suiteSort, $dir)
4750
}
4851
}
4952

5053
$directories = $directoriesWithSortKeys |
51-
Sort-Object -Property { $_.SortKeys[0] }, { $_.SortKeys[1] }, { $_.SortKeys[2] }, { $_.SortKeys[3] }, { $_.SortKeys[4] } |
54+
Sort-Object -Property { $_.SortKeys[0] }, { $_.SortKeys[1] }, { $_.SortKeys[2] }, { $_.SortKeys[3] }, { $_.SortKeys[4] }, { $_.SortKeys[5] } |
5255
Select-Object -ExpandProperty Directory
5356

54-
$firstVersion = $null
57+
$firstVersions = @{}
5558
foreach ($dir in $directories) {
5659
if (-not (Test-Path $dir)) {
5760
continue
@@ -65,16 +68,23 @@ foreach ($dir in $directories) {
6568
$version = "$version.0"
6669
}
6770

68-
if (-not $firstVersion) {
69-
$firstVersion = $version
71+
$majorVersion = $version.Split('.')[0]
72+
73+
if (-not $firstVersions.ContainsKey($majorVersion)) {
74+
$firstVersions[$majorVersion] = $version
7075
}
71-
if ($version -ne $firstVersion) {
72-
Write-Error "$dir contains $version (compared to $firstVersion in $($directories[0]))"
76+
if ($version -ne $firstVersions[$majorVersion]) {
77+
Write-Error "$dir contains $version (compared to $($firstVersions[$majorVersion]) in other images of major version $majorVersion)"
7378
}
7479

80+
# Get the git commit for the specific directory
81+
$majorDir = $dir -split '/' | Select-Object -First 1
82+
$commit = git log -1 --format='%H' -- "$majorDir"
83+
7584
$fromTag = $from.Split(':')[-1]
7685
$suite = $fromTag -replace '-jdk$', '' -replace '.*-', ''
77-
$jdk = $dir.Split('-')[0]
86+
$dirName = $dir | Split-Path -Leaf
87+
$jdk = $dirName.Split('-')[0]
7888

7989
switch -wildcard ($dir) {
8090
'*-alpine' { $variant = 'alpine' }
@@ -100,7 +110,9 @@ foreach ($dir in $directories) {
100110
switch ($variant) {
101111
'' {
102112
$tags += $versions | ForEach-Object { "$_-$jdk-$suite" }
103-
$tags += 'latest'
113+
if ($version -match "^5\.") {
114+
$tags += 'latest'
115+
}
104116
$tags += $versions | ForEach-Object { "$_-jdk" }
105117
$tags += $versions
106118
$tags += $versions | ForEach-Object { "$_-jdk-$suite" }
@@ -109,6 +121,9 @@ foreach ($dir in $directories) {
109121
'alpine' {
110122
$tags += $versions | ForEach-Object { "$_-jdk-alpine" }
111123
$tags += $versions | ForEach-Object { "$_-alpine" }
124+
if ($version -match "^5\.") {
125+
$tags += 'alpine'
126+
}
112127
}
113128
}
114129

@@ -136,6 +151,7 @@ foreach ($dir in $directories) {
136151
Tags: $actualTagsString
137152
Architectures: $arches
138153
$common
154+
GitCommit: $commit
139155
Directory: $dir
140156
"@
141157
}

generate-stackbrew-library.sh

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ set -o errexit -o nounset -o pipefail
99
jq --version > /dev/null
1010
bashbrew --version > /dev/null
1111

12-
gitRemote="$(git remote -v | awk '/groovy\/docker-groovy/ { print $1; exit }')"
13-
1412
cat <<-'EOH'
1513
Maintainers: Keegan Witt <[email protected]> (@keeganwitt)
1614
GitRepo: https://github.com/groovy/docker-groovy.git
1715
EOH
1816

19-
declare -A usedTags=() archesLookupCache=()
20-
commit="$(git rev-parse "refs/remotes/$gitRemote/master")"
17+
declare -A usedTags=() archesLookupCache=() seenVersions=()
18+
commit="$(git rev-parse HEAD)"
19+
branch="$(git rev-parse --abbrev-ref HEAD)"
2120
common="$(
2221
cat <<-EOC
23-
GitFetch: refs/heads/master
24-
GitCommit: $commit
22+
GitFetch: refs/heads/$branch
2523
EOC
2624
)"
2725

@@ -35,17 +33,25 @@ directories="$(
3533
]
3634
| sort_by(
3735
# sort the list:
36+
# - Groovy version in descending order
3837
# - LTS JDK versions in descending order
3938
# - non-LTS JDK versions in descending order
4039
# - plain (temurin) variants above alpine
4140
# - Ubuntu versions in descending release order
4241
# (presorting the list makes tag calculation easier later because we can simply generate a list of tags each combination *could* have and let the first one to try get it, being careful not to reuse any)
4342
(
44-
ltrimstr("jdk")
43+
split("/")[0]
44+
| split("-")[1]
45+
| tonumber
46+
) as $groovy
47+
| (
48+
split("/")[1]
49+
| ltrimstr("jdk")
4550
| split("-")[0]
4651
| tonumber
4752
) as $jdk
4853
| [
54+
(-$groovy),
4955
# LTS JDK versions above non-LTS
5056
(
5157
if $jdk | IN(21, 17, 11, 8) then 0
@@ -76,7 +82,7 @@ directories="$(
7682
)"
7783
eval "directories=( $directories )"
7884

79-
firstVersion=
85+
8086
for dir in "${directories[@]}"; do
8187
# shellcheck disable=SC2001
8288
dir="$(echo "$dir" | sed -e 's/[[:space:]]*$//')"
@@ -95,17 +101,25 @@ for dir in "${directories[@]}"; do
95101
version="${version}.0"
96102
fi
97103

104+
majorVersion="${version%%.*}"
105+
98106
# double-check that each version matches the first one for this major (they should all be updated in lock-step)
99-
[ -n "$firstVersion" ] || firstVersion="$version"
100-
if [ "$version" != "$firstVersion" ]; then
101-
echo >&2 "error: $dir contains $version (compared to $firstVersion in ${directories[0]})"
107+
# declare -A firstVersions is not available in older bash, using variable indirection or assume bash 4+ (which is checked via declare -A usedTags)
108+
: "${seenVersions[$majorVersion]:=$version}"
109+
if [ "$version" != "${seenVersions[$majorVersion]}" ]; then
110+
echo >&2 "error: $dir contains $version (compared to ${seenVersions[$majorVersion]} in other images of major version $majorVersion)"
102111
exit 1
103112
fi
104113

114+
# Get the git commit for the specific directory
115+
majorDir="${dir%%/*}"
116+
commit="$(git log -1 --format='%H' -- "$majorDir")"
117+
105118
fromTag="${from##*:}"
106119
suite="${fromTag%-jdk}"
107120
suite="${suite##*-}" # "noble", "jammy", etc
108-
jdk="${dir%%-*}" # "jdk8", etc
121+
dirName="${dir##*/}"
122+
jdk="${dirName%%-*}" # "jdk8", etc
109123

110124
# identify image "variant" so we can assign tags based on variant
111125
case "$dir" in
@@ -125,9 +139,14 @@ for dir in "${directories[@]}"; do
125139
tags+=( "${versions[@]/%/-$jdk${variant:+-$variant}}" ) # "X.Y.Z-jdkNN-alpine"
126140
case "$variant" in
127141
'')
142+
tags+=( "${versions[@]/%/-$jdk-$suite}" ) # "X.Y.Z-jdkNN-noble"
143+
144+
# Only add "latest" tag for Groovy 5
145+
if [[ "$version" == 5.* ]]; then
146+
tags+=( 'latest' )
147+
fi
148+
128149
tags+=(
129-
"${versions[@]/%/-$jdk-$suite}" # "X.Y.Z-jdkNN-noble"
130-
'latest'
131150
"${versions[@]/%/-jdk}" # "X.Y.Z-jdk"
132151
"${versions[@]}" # "X.Y.Z"
133152
"${versions[@]/%/-jdk-$suite}" # "X.Y.Z-jdk-noble"
@@ -139,6 +158,9 @@ for dir in "${directories[@]}"; do
139158
"${versions[@]/%/-jdk-alpine}" # "X.Y.Z-jdk-alpine"
140159
"${versions[@]/%/-alpine}" # "X.Y.Z-alpine"
141160
)
161+
if [[ "$version" == 5.* ]]; then
162+
tags+=( 'alpine' )
163+
fi
142164
;;
143165
esac
144166

@@ -164,6 +186,7 @@ for dir in "${directories[@]}"; do
164186
Tags: $actualTags
165187
Architectures: $arches
166188
$common
189+
GitCommit: $commit
167190
Directory: $dir
168191
EOE
169192
done
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ VOLUME /home/groovy/.groovy/grapes
1919

2020
WORKDIR /home/groovy
2121

22-
ENV GROOVY_VERSION=5.0.4
22+
ENV GROOVY_VERSION=3.0.25
2323
RUN set -o errexit -o nounset \
2424
&& echo "Installing build dependencies" \
2525
&& apk add --no-cache --virtual .build-deps \

0 commit comments

Comments
 (0)