Skip to content

Commit

Permalink
Merge pull request #3645 from reactioncommerce/release-1.8.0
Browse files Browse the repository at this point in the history
Release 1.8.0
  • Loading branch information
spencern committed Feb 22, 2018
2 parents ac07d02 + a1c043e commit c5b36e4
Show file tree
Hide file tree
Showing 574 changed files with 13,485 additions and 19,838 deletions.
24 changes: 12 additions & 12 deletions .circleci/build.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#!/bin/bash

# Build and tag docker image with SHA1, branch name, git tag, and latest if necessary
set -e

# Setup variables
DOCKER_NAMESPACE=${DOCKER_NAMESPACE:-"reactioncommerce/reaction"}
SHA1=$(git rev-parse --verify "${CIRCLE_SHA1}")
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# if we're not on a deployment branch or a Docker related PR branch, skip the Docker build/test
if [[ "$CIRCLE_BRANCH" != "master" && "$CIRCLE_BRANCH" != *"docker"* ]]; then
echo "Not running a build branch. Skipping the Docker build test."
exit 0
fi

# build new image
# Build and tag docker image
# Ensure that we build the docker image and tag with the git SHA1 ref.
echo "Building the Docker image."
docker build \
--build-arg TOOL_NODE_FLAGS="--max-old-space-size=4096" \
--build-arg INSTALL_MONGO=true \
-t reactioncommerce/reaction:latest .
-t "${DOCKER_NAMESPACE}:${SHA1}" .

# Get tags and apply them to our Docker image
"${__dir}/docker-tags.sh" "${SHA1}" "${CIRCLE_BRANCH}" | sed 's/\//-/g' | xargs -t -I % \
docker tag "${DOCKER_NAMESPACE}:${SHA1}" "${DOCKER_NAMESPACE}:%"

# run the container and wait for it to boot
docker-compose -f .circleci/docker-compose.yml up -d
Expand All @@ -23,6 +26,3 @@ sleep 30
# use curl to ensure the app returns 200's
docker exec reaction bash -c "apt-get update && apt-get install -y curl && \
curl --retry 10 --retry-delay 10 -v http://localhost:3000"

# now change the image tag to the configured name
docker tag reactioncommerce/reaction:latest $DOCKER_NAMESPACE:latest
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ jobs:
command: .reaction/jsdoc/build.sh
no_output_timeout: 2m

# deploy the build (if on a deployment branch)

# deploy the docs if on master branch
- deploy:
name: Deploy to S3 if tests pass and branch is Master
command: |
Expand Down
34 changes: 14 additions & 20 deletions .circleci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,21 @@
#
# $DOCKER_NAMESPACE - the image name for production deployments [Default]: reactioncommerce/reaction

if [[ "$CIRCLE_BRANCH" != "master" ]]; then
echo "Not running a deployment branch."
exit 0
fi
set -e

# Master branch deployment (only runs when a version git tag exists - syntax: "v1.2.3")
if [[ "$CIRCLE_BRANCH" == "master" ]]; then
VERSION=$(git describe --tags | grep "^v[0-9]\+\.[0-9]\+\.[0-9]\+$")
# Setup variables
DOCKER_NAMESPACE=${DOCKER_NAMESPACE:-"reactioncommerce/reaction"}
SHA1=$(git rev-parse --verify "${CIRCLE_SHA1}")
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if [[ "$VERSION" ]]; then
set -e
# Login to docker
docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}"

DOCKER_NAMESPACE=${DOCKER_NAMESPACE:-"reactioncommerce/reaction"}
# Push image and SHA1 tag
echo "Pushing docker image with SHA1 tag ${DOCKER_NAMESPACE}:${SHA1}"
docker push "${DOCKER_NAMESPACE}:${SHA1}"

docker tag $DOCKER_NAMESPACE:latest $DOCKER_NAMESPACE:$VERSION

docker login -u $DOCKER_USER -p $DOCKER_PASS

docker push $DOCKER_NAMESPACE:$VERSION
docker push $DOCKER_NAMESPACE:latest
else
echo "On the master branch, but no version tag was found. Skipping image deployment."
fi
fi
# Push remaining tags (git tags, branch, "latest" if applicable)
echo "Pushing remaining tags"
"${__dir}/docker-tags.sh" "${SHA1}" "${CIRCLE_BRANCH}" | sed 's/\//-/g' | xargs -t -I % \
docker push "${DOCKER_NAMESPACE}:%"
50 changes: 50 additions & 0 deletions .circleci/docker-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# outputs each tag we're attaching to this docker image
set -e

SHA=$1
BRANCH=$2
SHA1=$(git rev-parse --verify "${SHA}")

# Echo to stderr
echoerr() { echo "$@" 1>&2; }

# Ensure that git SHA was provided
if [[ -x "${SHA1}" ]]; then
echoerr "Error, no git SHA provided"
exit 1;
fi

# tag with the branch
if [[ -n "${BRANCH}" ]]; then
echo "${BRANCH}"
fi

# Tag with each git tag
git show-ref --tags -d | grep "^${SHA1}" | sed -e 's,.* refs/tags/,,' -e 's/\^{}//' 2> /dev/null \
| xargs -I % \
echo "%"

# Tag with latest if certain conditions are met
if [[ "$BRANCH" == "master" ]]; then
# Check to see if we have a valid `vX.X.X` tag and assign to CURRENT_TAG
CURRENT_TAG=$( \
git show-ref --tags -d \
| grep "^${SHA1}" \
| sed -e 's,.* refs/tags/,,' -e 's/\^{}//' \
| grep "^v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" \
| sort \
)

# Find the highest tagged version number
HIGHEST_TAG=$(git --no-pager tag | grep "^v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" | sort -r | head -n 1)

# We tag :latest only if
# 1. We have a current tag
# 2. The current tag is equal to the highest tag, OR the highest tag does not exist
if [[ -n "${CURRENT_TAG}" ]]; then
if [[ "${CURRENT_TAG}" == "${HIGHEST_TAG}" ]] || [[ -z "${HIGHEST_TAG}" ]]; then
echo "latest"
fi
fi
fi
Loading

0 comments on commit c5b36e4

Please sign in to comment.