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

Push to open-balena-db as well as resin-db #12

Merged
3 commits merged into from
Mar 20, 2018
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
35 changes: 8 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
build:
docker:
- image: library/docker:1.12.6
- image: library/docker:17
working_directory: /tmp/build
environment:
DOCKER_USERNAME: travisciresin
Expand All @@ -14,31 +14,12 @@ jobs:
version: 17.07.0-ce
reusable: true
exclusive: false
- run: |
docker info
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
- run:
name: Build
- run:
name: Setup
command: |
set -ex
docker pull ${DOCKER_IMAGE}:${CIRCLE_BRANCH} || true
docker build --rm=false --pull --tag ${DOCKER_IMAGE}:${CIRCLE_SHA1} .
- deploy:
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
apk add --no-cache git
- run:
name: Build and push
command: |
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
set -ex
docker push ${DOCKER_IMAGE}:${CIRCLE_SHA1}
docker tag ${DOCKER_IMAGE}:${CIRCLE_SHA1} ${DOCKER_IMAGE}:${CIRCLE_BRANCH}
docker push ${DOCKER_IMAGE}:${CIRCLE_BRANCH}
if [ "${CIRCLE_TAG}" != "" ]; then
docker tag ${DOCKER_IMAGE}:${CIRCLE_SHA1} ${DOCKER_IMAGE}:${CIRCLE_TAG}
docker push ${DOCKER_IMAGE}:${CIRCLE_TAG}
fi

# Tag the branch
apk add --no-cache git
tag=$(git describe --tags) || true
if [ "${tag}" != "" ]; then
docker tag ${DOCKER_IMAGE}:${CIRCLE_SHA1} ${DOCKER_IMAGE}:${tag}
docker push ${DOCKER_IMAGE}:${tag}
fi
IMAGE_NAME=$DOCKER_IMAGE BRANCH_NAME=$CIRCLE_BRANCH ./automation/build.sh
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).

## v1.1.2 - 2018-03-20

* Use local build script in CI #12 [Akis Kesoglou]

## v1.1.1 - 2018-03-08

* Move to V2 of CircleCI and include git for tagging. #11 [Heds Simons]
Expand Down
31 changes: 31 additions & 0 deletions automation/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
set -e

# Input is:
# - IMAGE_NAME: the repo to push the image to, eg. resin/repository-name
# - BRANCH_NAME: eg. fix-some-bug

VERSION=$(git describe --tags)
REVISION=$(git rev-parse --short HEAD)
BRANCH=$(echo $BRANCH_NAME | sed 's/[^a-z0-9A-Z_.-]/-/g')

# Try pulling the old build first for caching purposes.
docker pull ${IMAGE_NAME}:${BRANCH} || docker pull ${IMAGE_NAME}:master || true

# Build and tag
docker build --pull --tag ${IMAGE_NAME}:${REVISION} .
docker tag ${IMAGE_NAME}:${REVISION} ${IMAGE_NAME}:${BRANCH}
docker tag ${IMAGE_NAME}:${REVISION} ${IMAGE_NAME}:${VERSION}

# Push the images
docker push ${IMAGE_NAME}:${REVISION}
docker push ${IMAGE_NAME}:${BRANCH}
docker push ${IMAGE_NAME}:${VERSION}

# Push the images to open-balena-db repo
docker tag ${IMAGE_NAME}:${REVISION} resin/open-balena-db:${REVISION}
docker tag ${IMAGE_NAME}:${REVISION} resin/open-balena-db:${BRANCH}
docker tag ${IMAGE_NAME}:${REVISION} resin/open-balena-db:${VERSION}
docker push resin/open-balena-db:${REVISION}
docker push resin/open-balena-db:${BRANCH}
docker push resin/open-balena-db:${VERSION}