forked from elastic/apm-agent-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: document active branches, prep the release process for having a…
… maintenance branch (elastic#3573) - chore: simplify and doc push-docker.sh dev script - some cleanup of CONTRIBUTING content - docs: better document the release process, prepping for a coming 4.x new major Refs: elastic#2668
- Loading branch information
Showing
3 changed files
with
83 additions
and
69 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
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
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,46 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# This script is present on workers but may not be present in a development | ||
# environment. | ||
if [ ${WORKSPACE+x} ] # We are on a CI worker | ||
then | ||
source /usr/local/bin/bash_standard_lib.sh | ||
fi | ||
# Publish (push) the given locally built Docker image. If 'v${IMAGE_TAG}' | ||
# matches the latest git tag, then the image is also published with the 'latest' | ||
# tag. | ||
# | ||
# This assumes that 'docker login REGISTRY' has already been done. | ||
# | ||
# Usage: | ||
# ./dev-utils/push-docker.sh REGISTRY IMAGE_NAME IMAGE_TAG | ||
# Example: | ||
# ./dev-utils/push-docker.sh docker.elastic.co observability/apm-agent-nodejs 3.49.1 | ||
|
||
readonly RETRIES=3 | ||
set -euo pipefail | ||
|
||
readonly DOCKER_REGISTRY_URL="$1" | ||
|
||
readonly DOCKER_IMAGE_NAME="$2" | ||
|
||
readonly DOCKER_TAG="$3" | ||
|
||
readonly DOCKER_PUSH_IMAGE="$DOCKER_REGISTRY_URL/$DOCKER_IMAGE_NAME:$DOCKER_TAG" | ||
|
||
readonly DOCKER_PUSH_IMAGE_LATEST="$DOCKER_REGISTRY_URL/$DOCKER_IMAGE_NAME:latest" | ||
|
||
echo "INFO: Pushing image $DOCKER_PUSH_IMAGE to $DOCKER_REGISTRY_URL" | ||
|
||
if [ ${WORKERS+x} ] # We are on a CI worker | ||
then | ||
retry $RETRIES docker push $DOCKER_PUSH_IMAGE || echo "Push failed after $RETRIES retries" | ||
else # We are in a local (non-CI) environment | ||
docker push $DOCKER_PUSH_IMAGE || echo "You may need to run 'docker login' first and then re-run this script" | ||
fi | ||
echo "INFO: Pushing docker image $DOCKER_PUSH_IMAGE" | ||
docker push "$DOCKER_PUSH_IMAGE" | ||
|
||
readonly LATEST_TAG=$(git tag --list --sort=version:refname "v*" | grep -v - | cut -c2- | tail -n1) | ||
# The latest (by semver version ordering) git version tag, with the 'v' removed. | ||
readonly LATEST_GIT_TAG=$(git tag --list --sort=version:refname "v*" | grep -v - | cut -c2- | tail -n1) | ||
|
||
if [ "$DOCKER_TAG" = "$LATEST_TAG" ] | ||
then | ||
echo "INFO: Current version ($DOCKER_TAG) is the latest version. Tagging and pushing $DOCKER_PUSH_IMAGE_LATEST ..." | ||
if [[ "$DOCKER_TAG" == "$LATEST_GIT_TAG" ]]; then | ||
echo "INFO: Docker tag '$DOCKER_TAG' matches latest git version tag, tagging and pushing $DOCKER_PUSH_IMAGE_LATEST" | ||
docker tag $DOCKER_PUSH_IMAGE $DOCKER_PUSH_IMAGE_LATEST | ||
|
||
if [ ${WORKERS+x} ] # We are on a CI worker | ||
then | ||
retry $RETRIES docker push $DOCKER_PUSH_IMAGE_LATEST || echo "Push failed after $RETRIES retries" | ||
else # We are in a local (non-CI) environment | ||
docker push $DOCKER_PUSH_IMAGE_LATEST || echo "You may need to run 'docker login' first and then re-run this script" | ||
fi | ||
fi | ||
docker push $DOCKER_PUSH_IMAGE_LATEST | ||
fi |