2020-01-16 00:18:55 +03:00
|
|
|
version: 2.1
|
|
|
|
|
|
|
|
workflows:
|
|
|
|
build-and-deploy:
|
|
|
|
jobs:
|
|
|
|
- build
|
2022-02-25 01:13:20 +03:00
|
|
|
- push:
|
2020-01-16 00:18:55 +03:00
|
|
|
filters:
|
|
|
|
tags:
|
2022-02-25 01:13:20 +03:00
|
|
|
only: /^v.*/
|
2020-01-16 00:18:55 +03:00
|
|
|
branches:
|
|
|
|
ignore: /.*/
|
2017-10-12 23:47:26 +03:00
|
|
|
jobs:
|
|
|
|
build:
|
2017-10-13 19:52:39 +03:00
|
|
|
working_directory: /go/src/go.mozilla.org/sops
|
2017-10-12 23:47:26 +03:00
|
|
|
docker:
|
2019-11-18 21:06:58 +03:00
|
|
|
- image: circleci/golang:1.13
|
2020-01-16 00:18:55 +03:00
|
|
|
resource_class: large
|
2017-10-12 23:47:26 +03:00
|
|
|
steps:
|
|
|
|
- checkout
|
2022-03-25 14:56:22 +03:00
|
|
|
- setup_remote_docker:
|
|
|
|
version: 20.10.11
|
2017-10-13 19:52:39 +03:00
|
|
|
- run:
|
|
|
|
name: Build containers
|
|
|
|
command: |
|
|
|
|
docker build -t mozilla/sops .
|
|
|
|
docker tag mozilla/sops "mozilla/sops:$CIRCLE_SHA1"
|
2021-07-22 07:50:54 +03:00
|
|
|
- run:
|
|
|
|
name: Build containers (alpine)
|
|
|
|
command: |
|
|
|
|
# Just to ensure the container can be built.
|
|
|
|
docker build -f Dockerfile.alpine -t mozilla/sops:alpine .
|
2020-01-16 00:18:55 +03:00
|
|
|
|
|
|
|
push:
|
2022-03-25 14:56:22 +03:00
|
|
|
machine:
|
|
|
|
image: ubuntu-2004:202111-02
|
2020-01-16 00:18:55 +03:00
|
|
|
resource_class: large
|
|
|
|
steps:
|
|
|
|
- checkout
|
2022-02-25 01:13:20 +03:00
|
|
|
- run:
|
2020-01-16 00:18:55 +03:00
|
|
|
name: semver check
|
|
|
|
command: |
|
2020-01-18 16:31:15 +03:00
|
|
|
MAJOR=$(echo ${CIRCLE_TAG#v} | cut -d"." -f1)
|
|
|
|
MINOR=$(echo ${CIRCLE_TAG#v} | cut -d"." -f2)
|
|
|
|
PATCH=$(echo ${CIRCLE_TAG#v} | cut -d"." -f3)
|
2020-01-16 00:18:55 +03:00
|
|
|
echo "export MAJOR=${MAJOR}" >> $BASH_ENV
|
|
|
|
echo "export MINOR=${MINOR}" >> $BASH_ENV
|
|
|
|
echo "export PATCH=${PATCH}" >> $BASH_ENV
|
2020-01-18 16:31:15 +03:00
|
|
|
|
|
|
|
if [ -z $MAJOR ];then
|
|
|
|
cat \<< EOF
|
|
|
|
Failure Info:
|
|
|
|
|
|
|
|
This job uses the semver from the git TAG as the public version to publish.
|
|
|
|
|
2022-02-25 01:13:20 +03:00
|
|
|
- This should only run on workflows triggered by a tag.
|
|
|
|
- The tag name should be a semver like 'v1.2.3'
|
2020-01-18 16:31:15 +03:00
|
|
|
- The version should follow conventions documented at https://github.com/fsaintjacques/semver-tool
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-10-12 23:47:26 +03:00
|
|
|
- run:
|
2020-01-16 00:18:55 +03:00
|
|
|
name: Build containers
|
2017-10-12 23:47:26 +03:00
|
|
|
command: |
|
2020-01-16 00:18:55 +03:00
|
|
|
docker build -t mozilla/sops .
|
2020-01-30 21:39:54 +03:00
|
|
|
docker build -f Dockerfile.alpine -t mozilla/sops:alpine .
|
2020-01-16 00:18:55 +03:00
|
|
|
- run:
|
|
|
|
name: Tag & Push containers
|
|
|
|
command: |
|
|
|
|
#latest
|
2020-01-18 16:39:27 +03:00
|
|
|
bin/ci/deploy_dockerhub.sh "latest"
|
2020-01-30 21:39:54 +03:00
|
|
|
bin/ci/deploy_dockerhub.sh "alpine"
|
2020-01-16 00:18:55 +03:00
|
|
|
|
|
|
|
# by sha
|
|
|
|
echo "Tag and push mozilla/sops:$CIRCLE_SHA1"
|
|
|
|
docker tag mozilla/sops "mozilla/sops:$CIRCLE_SHA1"
|
2020-01-18 16:39:27 +03:00
|
|
|
bin/ci/deploy_dockerhub.sh "$CIRCLE_SHA1"
|
2020-01-16 00:18:55 +03:00
|
|
|
|
2020-01-30 21:39:54 +03:00
|
|
|
# no sha for alpine
|
|
|
|
|
2020-01-16 00:18:55 +03:00
|
|
|
# by semver
|
|
|
|
# v1.2.3
|
2020-01-18 16:31:15 +03:00
|
|
|
if [ ! -z $PATCH ];then
|
|
|
|
echo "Tag and Push mozilla/sops:v$MAJOR.$MINOR.$PATCH"
|
|
|
|
docker tag mozilla/sops "mozilla/sops:v$MAJOR.$MINOR.$PATCH"
|
2020-01-18 16:39:27 +03:00
|
|
|
bin/ci/deploy_dockerhub.sh "v$MAJOR.$MINOR.$PATCH"
|
2020-01-30 21:39:54 +03:00
|
|
|
|
|
|
|
echo "Tag and Push mozilla/sops:v$MAJOR.$MINOR.$PATCH-alpine"
|
|
|
|
docker tag mozilla/sops:alpine "mozilla/sops:v$MAJOR.$MINOR.$PATCH-alpine"
|
|
|
|
bin/ci/deploy_dockerhub.sh "v$MAJOR.$MINOR.$PATCH-alpine"
|
2020-01-18 16:31:15 +03:00
|
|
|
fi
|
2020-01-16 00:18:55 +03:00
|
|
|
# v1.2
|
2020-01-18 16:31:15 +03:00
|
|
|
if [ ! -z $MINOR ];then
|
|
|
|
echo "Tag and Push mozilla/sops:v$MAJOR.$MINOR"
|
|
|
|
docker tag mozilla/sops "mozilla/sops:v$MAJOR.$MINOR"
|
2020-01-18 16:39:27 +03:00
|
|
|
bin/ci/deploy_dockerhub.sh "v$MAJOR.$MINOR"
|
2020-01-30 21:39:54 +03:00
|
|
|
|
|
|
|
echo "Tag and Push mozilla/sops:v$MAJOR.$MINOR-alpine"
|
|
|
|
docker tag mozilla/sops:alpine "mozilla/sops:v$MAJOR.$MINOR-alpine"
|
|
|
|
bin/ci/deploy_dockerhub.sh "v$MAJOR.$MINOR-alpine"
|
2020-01-18 16:31:15 +03:00
|
|
|
fi
|
2020-01-16 00:18:55 +03:00
|
|
|
# v1
|
|
|
|
echo "Tag and Push mozilla/sops:v$MAJOR"
|
|
|
|
docker tag mozilla/sops "mozilla/sops:v$MAJOR"
|
2020-01-18 16:39:27 +03:00
|
|
|
bin/ci/deploy_dockerhub.sh "v$MAJOR"
|
2020-01-16 00:18:55 +03:00
|
|
|
|
2020-01-30 21:39:54 +03:00
|
|
|
echo "Tag and Push mozilla/sops:v$MAJOR-alpine"
|
|
|
|
docker tag mozilla/sops:alpine "mozilla/sops:v$MAJOR-alpine"
|
|
|
|
bin/ci/deploy_dockerhub.sh "v$MAJOR-alpine"
|