Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maint: Docker tagging updates #791

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ jobs:
command: |
set -x

export TAG="$(test "${CIRCLE_BRANCH}" == "main" && echo "" || echo "branch-")${BUILD_ID}"
export ECR_HOST=702835727665.dkr.ecr.us-east-1.amazonaws.com
export KO_DOCKER_REPO=${ECR_HOST}

Expand Down Expand Up @@ -245,9 +244,6 @@ workflows:
requires:
- build_binaries
- build_docker
filters:
branches:
only: main
- publish_github:
context: Honeycomb Secrets for Public Repos
requires:
Expand Down
34 changes: 31 additions & 3 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
#!/usr/bin/env bash
set -o nounset
set -o pipefail
set -o xtrace

TAGS="latest"
TAGS=""
# Check if CIRCLE_BRANCH is set and not empty
if [[ -n "${CIRCLE_BRANCH}" ]]; then
export TAGS="${CIRCLE_BUILD_NUM},branch-${CIRCLE_BRANCH}"
fi

# We only want to tag main with latest on ECR
if [[ "${CIRCLE_BRANCH}" == "main" ]]; then
TAGS+=",latest"
fi

# Local builds just get "dev" for version
VERSION="dev"

# If we are doing a dev build on circle, we will version it as the circleci buildnumber
if [[ -n "${CIRCLE_BUILD_NUM}" ]]; then
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved
VERSION="${CIRCLE_BUILD_NUM}"
fi

# if we're running off a git tag, it is a release which we tag with the versions as well as latest
# caution: this means if we ever release an update to a previous version, it will be marked latest
# it is probably best if people just use the major or minor version tags

if [[ -n ${CIRCLE_TAG:-} ]]; then
# trim 'v' prefix if present
VERSION=${CIRCLE_TAG#"v"}
# append version to image tags
TAGS+=",$VERSION"

# Extract major, major.minor, and major.minor.patch versions
MAJOR_VERSION=${VERSION%%.*}
MINOR_VERSION=${VERSION%.*}

# Append versions to image tags
# So 2.1.1 would be tagged with "2","2.1","2.1.1"
TAGS="$MAJOR_VERSION,$MINOR_VERSION,$VERSION,latest"
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved
fi

unset GOOS
Expand Down