Skip to content

Commit 7a7c901

Browse files
committed
Make "latest" refer to latest release branch
1 parent 584f0fb commit 7a7c901

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

.github/workflows/test_and_deploy.yml

+44-21
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,33 @@ env:
2626
STABLE_ARM_TARBALL_NAME: rondb-22.10.3-linux-glibc2.28-arm64_v8.tar.gz
2727

2828
jobs:
29+
check-git:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
is_highest_release: ${{ steps.is_highest_release.outputs.is_highest }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Check if current branch is the highest release branch
39+
if: github.repository == 'logicalclocks/rondb-docker'
40+
id: is_highest_release
41+
run: |
42+
ALL_RELEASES=$(git branch -r | grep 'origin/release-' | sed 's|origin/||')
43+
HIGHEST_RELEASE=$(echo "$ALL_RELEASES" | sort -V | tail -n 1)
44+
echo "Highest release branch is $HIGHEST_RELEASE"
45+
46+
if [ "${GITHUB_REF_NAME}" = "$HIGHEST_RELEASE" ]; then
47+
echo "Current branch is the highest release branch."
48+
echo "is_highest=true" >> $GITHUB_ENV
49+
else
50+
echo "is_highest=false" >> $GITHUB_ENV
51+
fi
52+
2953
integration-test-and-package:
3054
runs-on: ubuntu-latest
55+
needs: [check-git]
3156
steps:
3257
- uses: actions/checkout@v4
3358

@@ -103,34 +128,33 @@ jobs:
103128
--build-arg RONDB_TARBALL_LOCAL_REMOTE=remote \
104129
--build-arg RONDB_X86_TARBALL_URI=$BASE_DEPLOY_URL/$STABLE_X86_TARBALL_NAME
105130
106-
# In the main branch, we work with "<version>-SNAPSHOT", which might as well be called "latest"
107-
- name: Push X86 *latest* images to Dockerhub
108-
if: github.repository == 'logicalclocks/rondb-docker' && github.ref_name == 'main'
131+
- name: Push X86 images to Dockerhub
132+
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
109133
run: |
110134
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
111135
docker tag rondb-standalone:$RONDB_VERSION_LTS-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
112136
docker tag rondb-standalone:$RONDB_VERSION_STABLE-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
137+
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
138+
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
139+
140+
# Our "latest" branch points to the latest *release* branch.
141+
- name: Push X86 *latest* images to Dockerhub
142+
if: github.repository == 'logicalclocks/rondb-docker' && needs.check-git.outputs.is_highest_release == 'true'
143+
run: |
144+
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
113145
docker tag rondb-standalone:$RONDB_VERSION_LTS-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-latest
114146
docker tag rondb-standalone:$RONDB_VERSION_STABLE-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-latest
115147
docker tag rondb-standalone:$RONDB_VERSION_STABLE-$VERSION hopsworks/$X86_IMAGE_NAME:latest
116-
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
117-
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
118148
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-latest
119149
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-latest
120150
docker push hopsworks/$X86_IMAGE_NAME:latest
121151
122-
- name: Push X86 *release* images to Dockerhub
123-
if: github.repository == 'logicalclocks/rondb-docker' && startsWith(github.ref_name, 'release-')
124-
run: |
125-
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
126-
docker tag rondb-standalone:$RONDB_VERSION_LTS-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
127-
docker tag rondb-standalone:$RONDB_VERSION_STABLE-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
128-
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
129-
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
130-
131152
build-and-push-ARM64:
132153
runs-on: ubuntu-latest
133154
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
155+
needs: [check-git]
156+
env:
157+
is_highest_release: ${{ needs.check-git.outputs.is_highest_release == 'true' }}
134158
steps:
135159
- uses: actions/checkout@v4
136160

@@ -153,7 +177,7 @@ jobs:
153177
run: |
154178
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
155179
TAGS="hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION"
156-
if [[ "${{ github.ref_name == 'main' }}" == "true" ]]; then
180+
if [[ "$is_highest_release" == "true" ]]; then
157181
TAGS+=" --tag hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_LTS-latest"
158182
fi
159183
docker buildx build . \
@@ -170,7 +194,7 @@ jobs:
170194
run: |
171195
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
172196
TAGS="--tag hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION"
173-
if [[ "${{ github.ref_name == 'main' }}" == "true" ]]; then
197+
if [[ "$is_highest_release" == "true" ]]; then
174198
TAGS+=" --tag hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_STABLE-latest"
175199
TAGS+=" --tag hopsworks/$ARM_IMAGE_NAME:latest"
176200
fi
@@ -187,7 +211,9 @@ jobs:
187211
build-and-push-cross-platform-image:
188212
runs-on: ubuntu-latest
189213
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
190-
needs: [integration-test-and-package, build-and-push-ARM64]
214+
needs: [check-git, integration-test-and-package, build-and-push-ARM64]
215+
env:
216+
is_highest_release: ${{ needs.check-git.outputs.is_highest_release == 'true' }}
191217
steps:
192218
- uses: actions/checkout@v4
193219

@@ -204,17 +230,14 @@ jobs:
204230
run: |
205231
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
206232
207-
# Using $VERSION will create weird `-SNAPSHOT` tags, when in main, but we need
208-
# those Dockerhub images in order to run the main branch.
209-
210233
docker buildx imagetools create -t hopsworks/rondb-standalone:$RONDB_VERSION_LTS-$VERSION \
211234
hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION \
212235
hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
213236
docker buildx imagetools create -t hopsworks/rondb-standalone:$RONDB_VERSION_STABLE-$VERSION \
214237
hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION \
215238
hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
216239
217-
if [[ "${{ github.ref_name == 'main' }}" == "true" ]]; then
240+
if [[ "$is_highest_release" == "true" ]]; then
218241
docker buildx imagetools create -t hopsworks/rondb-standalone:$RONDB_VERSION_LTS-latest \
219242
hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-latest \
220243
hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_LTS-latest

0 commit comments

Comments
 (0)