Skip to content

Commit f83ec14

Browse files
committed
Only tag docker-images with latest if they actually have the highest version, Fixes: #550
1 parent f7ec27d commit f83ec14

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ jobs:
6969
with:
7070
name: artifacts
7171
path: build/release
72+
- name: Check latest
73+
id: check_latest
74+
if: startsWith(github.ref, 'refs/tags/')
75+
run: |
76+
CURRENT_TAG=${GITHUB_REF#refs/tags/}
77+
78+
git fetch --all --tags --quiet
79+
ALL_TAGS=$(git tag -l | grep -E '^v[0-9]+\.[0-9]+' | sort -V)
80+
LATEST_TAG=$(echo "${ALL_TAGS}" | tail -n 1)
81+
82+
if [ "${CURRENT_TAG}" = "${LATEST_TAG}" ]; then
83+
echo "is_latest=true" >> $GITHUB_OUTPUT
84+
echo "Current tag ${CURRENT_TAG} is the latest version"
85+
else
86+
echo "is_latest=false" >> $GITHUB_OUTPUT
87+
echo "Current tag ${CURRENT_TAG} is not the latest (latest is ${LATEST_TAG})"
88+
fi
7289
- name: Login to GitHub Container Registry
7390
uses: docker/login-action@v3
7491
with:
@@ -86,7 +103,7 @@ jobs:
86103
# For releases: latest, full version and major version (ex. latest, v3.3 and v3)
87104
tags: |
88105
type=raw,value={{branch}}
89-
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
106+
type=raw,value=latest,enable=${{ steps.check_latest.outputs.is_latest == 'true' }}
90107
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
91108
type=match,pattern=v\d+,group=0,enable=${{ startsWith(github.ref, 'refs/tags/') }}
92109
flavor: |

0 commit comments

Comments
 (0)