From 435adf0744152d1a63133a88b8ec5c56feb12c5f Mon Sep 17 00:00:00 2001 From: Akis Kesoglou Date: Tue, 13 Mar 2018 12:28:38 +0200 Subject: [PATCH 1/3] Use local build script in CI - Extracts commands into a separate script - Updates CI to Docker 17.X - Normalises pushed images to: - revision: eg. 22dd724 - branch: maintenance - semver: eg v1.5.2-5-g22dd724 Change-Type: patch --- .circleci/config.yml | 36 +++++++++--------------------------- automation/build.sh | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 27 deletions(-) create mode 100755 automation/build.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index b5234b8..26dde92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -14,31 +14,13 @@ 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 info + 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 diff --git a/automation/build.sh b/automation/build.sh new file mode 100755 index 0000000..255c45b --- /dev/null +++ b/automation/build.sh @@ -0,0 +1,23 @@ +#!/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} From db3d04eeda168f7c35b16c1443d88ea50b0b8414 Mon Sep 17 00:00:00 2001 From: Akis Kesoglou Date: Tue, 13 Mar 2018 17:52:46 +0200 Subject: [PATCH 2/3] Push images to open-balena-db as well --- .circleci/config.yml | 1 - automation/build.sh | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 26dde92..f0b57a0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,6 @@ jobs: - run: name: Setup command: | - docker info docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" apk add --no-cache git - run: diff --git a/automation/build.sh b/automation/build.sh index 255c45b..97f0ce5 100755 --- a/automation/build.sh +++ b/automation/build.sh @@ -21,3 +21,11 @@ docker tag ${IMAGE_NAME}:${REVISION} ${IMAGE_NAME}:${VERSION} 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} From 5e06b3304a1e4b845b7483ef9af9f51a147cf27e Mon Sep 17 00:00:00 2001 From: "resin-io-versionbot[bot]" Date: Tue, 20 Mar 2018 11:15:37 +0000 Subject: [PATCH 3/3] v1.1.2 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 262af38..1c07933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]