Skip to content

Commit 9e1206c

Browse files
authored
Merge pull request #1838 from o1-labs/io/release-push-tagged-version
CI: Tweak docker workflow to push additional tags for versioned releases
2 parents 2731abd + 3b44748 commit 9e1206c

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

.github/workflows/docker.yaml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
# Push frontend multi-arch manifest
136136
push-frontend-image:
137137
runs-on: ubuntu-latest
138-
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release')
138+
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
139139
needs:
140140
- build-mina-frontend-image
141141
steps:
@@ -151,13 +151,19 @@ jobs:
151151
echo "GIT_COMMIT=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
152152
echo "ADDITIONAL_TAGS=latest" >> $GITHUB_ENV
153153
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
154-
echo "GIT_COMMIT=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
155-
echo "ADDITIONAL_TAGS=" >> $GITHUB_ENV
156-
elif [[ "${{ github.ref }}" == refs/heads/release/* ]]; then
157-
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
158-
VERSION="${BRANCH_NAME#release/}"
159-
echo "GIT_COMMIT=${VERSION}" >> $GITHUB_ENV
160-
echo "ADDITIONAL_TAGS=" >> $GITHUB_ENV
154+
FULL_TAG=${GITHUB_REF#refs/tags/}
155+
MAJOR_MINOR=$(echo $FULL_TAG | sed -E 's/(v[0-9]+\.[0-9]+)\.[0-9]+/\1/')
156+
157+
echo "Will push Docker image with tag \"${FULL_TAG}\""
158+
echo "GIT_COMMIT=${FULL_TAG}" >> $GITHUB_ENV
159+
160+
if [[ "$FULL_TAG" =~ [+-] ]]; then
161+
echo "Found pre-release or build ID in version, will __NOT__ update Docker tag \"${MAJOR_MINOR}\""
162+
echo "ADDITIONAL_TAGS=" >> $GITHUB_ENV
163+
else
164+
echo "Will additionally push Docker image with tag \"${MAJOR_MINOR}\""
165+
echo "ADDITIONAL_TAGS=${MAJOR_MINOR}" >> $GITHUB_ENV
166+
fi
161167
fi
162168
163169
- name: Push frontend multi-arch manifest
@@ -173,7 +179,7 @@ jobs:
173179
# Push node multi-arch manifest (after node build completes)
174180
push-node-image:
175181
runs-on: ubuntu-latest
176-
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release')
182+
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
177183
needs:
178184
- build-mina-node-image
179185
steps:
@@ -189,13 +195,19 @@ jobs:
189195
echo "GIT_COMMIT=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
190196
echo "ADDITIONAL_TAGS=latest" >> $GITHUB_ENV
191197
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
192-
echo "GIT_COMMIT=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
193-
echo "ADDITIONAL_TAGS=" >> $GITHUB_ENV
194-
elif [[ "${{ github.ref }}" == refs/heads/release/* ]]; then
195-
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
196-
VERSION="${BRANCH_NAME#release/}"
197-
echo "GIT_COMMIT=${VERSION}" >> $GITHUB_ENV
198-
echo "ADDITIONAL_TAGS=" >> $GITHUB_ENV
198+
FULL_TAG=${GITHUB_REF#refs/tags/}
199+
MAJOR_MINOR=$(echo $FULL_TAG | sed -E 's/(v[0-9]+\.[0-9]+)\.[0-9]+/\1/')
200+
201+
echo "Will push Docker image with tag \"${FULL_TAG}\""
202+
echo "GIT_COMMIT=${FULL_TAG}" >> $GITHUB_ENV
203+
204+
if [[ "$FULL_TAG" =~ [+-] ]]; then
205+
echo "Found pre-release or build ID in version, will __NOT__ update Docker tag \"${MAJOR_MINOR}\""
206+
echo "ADDITIONAL_TAGS=" >> $GITHUB_ENV
207+
else
208+
echo "Will additionally push Docker image with tag \"${MAJOR_MINOR}\""
209+
echo "ADDITIONAL_TAGS=${MAJOR_MINOR}" >> $GITHUB_ENV
210+
fi
199211
fi
200212
201213
- name: Push node multi-arch manifest

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- **Node**: add top-level documentation for the crate `node`
1313
([#1736](https://github.com/o1-labs/mina-rust/pull/1736))
14+
- **CI**: automatically push Docker images for `vX.Y.Z` and `vX.Y` when tag `vX.Y.Z` is created
15+
([#1838](https://github.com/o1-labs/mina-rust/pull/1838))
1416

1517
### Changes
1618

website/docs/appendix/release-process.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,9 @@ After pushing the tag, verify:
354354
1. **Docker images are built and pushed**
355355

356356
```bash
357-
# Verify multi-arch images are available
357+
# Verify multi-arch images are available for both vMAJOR.MINOR.PATCH and vMAJOR.MINOR
358358
make release-docker-verify TAG=v1.5.0
359+
make release-docker-verify TAG=v1.5
359360
```
360361

361362
<!-- prettier-ignore-start -->
@@ -634,6 +635,15 @@ git push origin :refs/tags/v1.5.0
634635
# Then recreate tag
635636
```
636637

638+
:::important Verify `vMAJOR.MINOR` Docker tags
639+
640+
If tag is recreated that looks like a valid semver, it will trigger a rebuild
641+
and push of the Docker images for that tag. For example, recreating tag `v1.5.0`
642+
will initiate a Docker build that will be pushed to Dockerhub as both `v1.5.0`
643+
and `v1.5`. As long as historical tags aren't recreated this shouldn't be a
644+
problem, but if the need arises to recreate tags, it's worth verifying that
645+
related images aren't adversely affected.
646+
637647
### CI Pipeline Issues
638648

639649
- Check GitHub Actions status page

0 commit comments

Comments
 (0)