This repository has been archived by the owner on Dec 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from hashicorp/claire-tag-update
RELENG-86 fixing to only push the latest tag if its not a prerelease
- Loading branch information
Showing
3 changed files
with
81 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
REGISTRY_NAME?=docker.io/hashicorp | ||
VERSION=1.7.0 | ||
IMAGE_TAG_ENT=$(REGISTRY_NAME)/vault-enterprise:$(VERSION)_ent | ||
IMAGE_TAG_OSS=$(REGISTRY_NAME)/vault:$(VERSION) | ||
export REGISTRY_NAME?=docker.io/hashicorp | ||
export VERSION=1.7.0 | ||
|
||
.PHONY: build ent-image oss-image | ||
|
||
build: ent-image oss-image | ||
|
||
ent-image: export PROJECT_NAME=vault-enterprise | ||
ent-image: export TAG_SUFFIX=_ent | ||
ent-image: | ||
docker build --build-arg VAULT_VERSION=$(VERSION)+ent --no-cache -t $(IMAGE_TAG_ENT) . | ||
docker tag $(IMAGE_TAG_ENT) $(REGISTRY_NAME)/vault-enterprise:latest | ||
docker build --label version=$(VERSION) --build-arg VAULT_VERSION=$(VERSION)+ent --no-cache -t $(REGISTRY_NAME)/$(PROJECT_NAME):$(VERSION)$(TAG_SUFFIX) . | ||
@../scripts/tag-images.sh | ||
|
||
oss-image: export PROJECT_NAME=vault | ||
oss-image: | ||
docker build --build-arg VAULT_VERSION=$(VERSION) --no-cache -t $(IMAGE_TAG_OSS) . | ||
docker tag $(IMAGE_TAG_OSS) $(REGISTRY_NAME)/vault:latest | ||
docker build --label version=$(VERSION) --build-arg VAULT_VERSION=$(VERSION) --no-cache -t $(REGISTRY_NAME)/$(PROJECT_NAME):$(VERSION) . | ||
@../scripts/tag-images.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
# * VERSION - Image version to tag i.e 1.7.0 or 1.7.0- | ||
# * REGISTRY_NAME - Docker Registry Name i.e docker.io/hashicorp | ||
# * PROJECT_NAME - Project name i.e vault or vault-enterprise | ||
|
||
# Introspects the docker label of an container to see what version 'latest' is | ||
function get_latest_docker_version() { | ||
# Arguments: | ||
# $1 - Docker Org | ||
# $2 - Docker Image Name | ||
# | ||
# | ||
# Returns: | ||
# 0 - success (version in the 'latest' container echoed) | ||
# 1 - 'latest' tag does not exist or label could not be found | ||
|
||
docker pull "$1"/"$2":latest | ||
local docker_latest=$(docker inspect --format="{{ index .Config.Labels.version }}" "$1"/"$2":latest) | ||
if [ -z "$docker_latest" ]; then | ||
return 1 | ||
else | ||
echo "$docker_latest" | ||
return 0 | ||
fi | ||
} | ||
|
||
# Calculates the higher of two versions | ||
function higher_version() { | ||
# Arguments: | ||
# $1 - first version to compare | ||
# $2 - second version to compare | ||
# | ||
# Returns: | ||
# higher version of two arguments | ||
|
||
higher_version=$(echo -e "$1\n$2" | sort -rV | head -n 1) | ||
echo "$higher_version" | ||
} | ||
|
||
# If this is not a pre-release, we determine if any of the 'latest' images need to be updated | ||
function main() { | ||
|
||
: "${VERSION?"Need to set VERSION"}" | ||
|
||
: "${REGISTRY_NAME?"Need to set REGISTRY_NAME"}" | ||
|
||
: "${PROJECT_NAME?"Need to set PROJECT_NAME"}" | ||
|
||
DOCKER_TAG="$VERSION$TAG_SUFFIX" | ||
|
||
if [[ "${VERSION}" =~ [0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Tagging a new latest docker image" | ||
docker tag "$REGISTRY_NAME"/"$PROJECT_NAME":"$DOCKER_TAG" "$REGISTRY_NAME"/"$PROJECT_NAME":latest || return 1 | ||
fi | ||
# If it is a prerelease, we don't tag latest so we do nothing here | ||
|
||
return 0 | ||
} | ||
main "$@" | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
REGISTRY_NAME?=docker.io/hashicorp | ||
VERSION=1.7.0 | ||
IMAGE_TAG_ENT=$(REGISTRY_NAME)/vault-enterprise:$(VERSION)-ubi-ent | ||
IMAGE_TAG_OSS=$(REGISTRY_NAME)/vault:$(VERSION)-ubi | ||
export REGISTRY_NAME?=docker.io/hashicorp | ||
export VERSION=1.7.0 | ||
|
||
.PHONY: build ent-image oss-image | ||
|
||
build: ent-image oss-image | ||
|
||
ent-image: export PROJECT_NAME=vault-enterprise | ||
ent-image: export TAG_SUFFIX=-ubi-ent | ||
ent-image: | ||
docker build --build-arg VAULT_VERSION=$(VERSION)+ent --no-cache -t $(IMAGE_TAG_ENT) . | ||
docker build --label version=$(VERSION) --build-arg VAULT_VERSION=$(VERSION)+ent --no-cache -t $(REGISTRY_NAME)/$(PROJECT_NAME):$(VERSION)$(TAG_SUFFIX) . | ||
docker tag $(IMAGE_TAG_ENT) $(REGISTRY_NAME)/vault-enterprise:latest | ||
@../scripts/tag-images.sh | ||
|
||
oss-image: export PROJECT_NAME=vault | ||
oss-image: export TAG_SUFFIX=-ubi | ||
oss-image: | ||
docker build --build-arg VAULT_VERSION=$(VERSION) --no-cache -t $(IMAGE_TAG_OSS) . | ||
docker build --label version=$(VERSION) --build-arg VAULT_VERSION=$(VERSION) --no-cache -t $(REGISTRY_NAME)/$(PROJECT_NAME):$(VERSION)$(TAG_SUFFIX) . | ||
docker tag $(IMAGE_TAG_OSS) $(REGISTRY_NAME)/vault:latest | ||
@../scripts/tag-images.sh |