Skip to content

Commit 088ad72

Browse files
committed
Only push :latest docker tag on final releases
When we publish alpha/beta releases (e.g. "v1.0.0a1") we should push the image tagged with the version to Docker Hub, but we should *not* update the `:latest` tag. That one should always point to a stable release for now.
1 parent 26c251d commit 088ad72

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

.circleci/config.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,45 @@ jobs:
7575
name: Load Built Docker Image
7676
command: docker load --input /tmp/workspace/docker-image
7777
- run:
78-
name: Re-tag Image
78+
name: Docker Login
79+
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
80+
# TODO: Drop these SHA-tagged builds in favor of just release numbers.
81+
# We maintain them for now for compatibility w/ a previous release style.
82+
- run:
83+
name: Publish Commit-SHA-Tagged Image
84+
command: docker push envirodgi/web-monitoring-diff:${CIRCLE_SHA1}
85+
- run:
86+
name: Publish Version-Tagged Image
7987
command: |
80-
if [ -n "${CIRCLE_TAG}" ]; then
81-
docker image tag envirodgi/web-monitoring-diff:${CIRCLE_SHA1} envirodgi/web-monitoring-diff:${CIRCLE_TAG:1}
82-
docker image tag envirodgi/web-monitoring-diff:${CIRCLE_SHA1} envirodgi/web-monitoring-diff:latest
88+
# Sanity-check that we are dealing with an actual release tag.
89+
if [ -z "${CIRCLE_TAG}" ]; then
90+
echo 'There is no git tag to use!'
91+
else
92+
# Re-tag the Docker image with the current version number, which
93+
# is based on the current git tag ($CIRCLE_TAG).
94+
docker image tag \
95+
envirodgi/web-monitoring-diff:${CIRCLE_SHA1} \
96+
envirodgi/web-monitoring-diff:${CIRCLE_TAG:1}
97+
docker push envirodgi/web-monitoring-diff:${CIRCLE_TAG:1}
8398
fi
8499
- run:
85-
name: Publish to Docker Hub
100+
name: Publish :latest Tag If Final Release
86101
command: |
87-
docker login -u $DOCKER_USER -p $DOCKER_PASS
88-
docker push envirodgi/web-monitoring-diff:${CIRCLE_SHA1}
89-
if [ -n "${CIRCLE_TAG}" ]; then
90-
docker push envirodgi/web-monitoring-diff:${CIRCLE_TAG:1}
91-
docker push envirodgi/web-monitoring-diff:latest
102+
# Skip tags with additional info after "v0.0.0", e.g. "v1.0.0a1"
103+
FINAL_VERSION="$(echo "${CIRCLE_TAG}" | grep -E '^v\d+(\.\d+)+$')"
104+
if [ -z "${FINAL_VERSION}" ]; then
105+
echo 'The current tag does not represent a final release!'
106+
echo 'Not publishing a ":latest" tag.'
107+
else
108+
docker image tag \
109+
envirodgi/web-monitoring-diff:${CIRCLE_SHA1} \
110+
envirodgi/web-monitoring-diff:latest
111+
docker push envirodgi/web-monitoring-diff:latest
92112
fi
93113
114+
# TODO: Publish to PyPI from CircleCI for version tags, similar to Docker.
115+
# publish_pypi:
116+
94117
workflows:
95118
build:
96119
jobs:

0 commit comments

Comments
 (0)