Commit 032742e1 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Add docker_images release step

parent 556cef49
......@@ -4,6 +4,9 @@ config.toml
out
builds/
executors/docker/bindata.go
dockerfiles/alpine/gitlab-ci-multi-runner-linux-amd64
dockerfiles/build/gitlab-runner-helper
dockerfiles/ubuntu/gitlab-ci-multi-runner_amd64.deb
.idea/
tests/ubuntu/.vagrant
artifacts
......@@ -80,11 +80,24 @@ packages:
- out/rpm/
expire_in: 7d
docker_images:
stage: release
image: docker:1.12
script:
- source ci/touch_make_dependencies
- make release_docker_images
only:
- master@gitlab-org/gitlab-ci-multi-runner
- /\Av[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+\Z/@gitlab-org/gitlab-ci-multi-runner
- /\Av[0-9]+\.[0-9]+\.[0-9]+\Z/@gitlab-org/gitlab-ci-multi-runner
tags:
- release
.release: &release
stage: release
script:
- source ci/touch_make_dependencies
- source ci/release "$CI_BUILD_NAME"
- make release
tags:
- release
......
......@@ -5,6 +5,13 @@ VERSION := $(shell ci/version)
REVISION := $(shell git rev-parse --short HEAD || echo unknown)
BRANCH := $(shell git show-ref | grep "$(REVISION)" | grep -v HEAD | awk '{print $$2}' | sed 's|refs/remotes/origin/||' | sed 's|refs/heads/||' | sort | head -n 1)
BUILT := $(shell date +%Y-%m-%dT%H:%M:%S%:z)
LATEST_STABLE_TAG := $(shell git -c versionsort.prereleaseSuffix="-rc" -c versionsort.prereleaseSuffix="-RC" tag -l "v*.*.*" --sort=-v:refname | awk '!/rc/' | head -n 1)
export IS_LATEST :=
ifeq ($(shell git describe --exact-match --match $(LATEST_STABLE_TAG) >/dev/null 2>&1; echo $$?), 0)
export IS_LATEST := true
endif
PACKAGE_CLOUD ?= ayufan/gitlab-ci-multi-runner
PACKAGE_CLOUD_URL ?= https://packagecloud.io/
BUILD_PLATFORMS ?= -os '!netbsd' -os '!openbsd'
......@@ -28,7 +35,6 @@ GO_LDFLAGS ?= -X $(COMMON_PACKAGE_NAMESPACE).NAME=$(PACKAGE_NAME) -X $(COMMON_PA
-X $(COMMON_PACKAGE_NAMESPACE).REVISION=$(REVISION) -X $(COMMON_PACKAGE_NAMESPACE).BUILT=$(BUILT) \
-X $(COMMON_PACKAGE_NAMESPACE).BRANCH=$(BRANCH)
GO_FILES ?= $(shell find . -name '*.go')
export GO15VENDOREXPERIMENT := 1
export CGO_ENABLED := 0
all: deps verify build
......@@ -64,7 +70,7 @@ version: FORCE
@echo Build platforms: $(BUILD_PLATFORMS)
@echo DEB platforms: $(DEB_PLATFORMS)
@echo RPM platforms: $(RPM_PLATFORMS)
bash -c 'echo TEST: ${GO15VENDOREXPERIMENT}'
@echo IS_LATEST: $(IS_LATEST)
verify: fmt vet lint complexity test
......@@ -339,6 +345,12 @@ s3-upload:
--target-paths "$(S3_UPLOAD_PATH)/" \
$(shell cd out/; find . -type f)
release:
@ci/release "$$CI_BUILD_NAME"
release_docker_images:
@ci/release_docker_images
check-tags-in-changelog:
# Looking for tags in CHANGELOG
@git status | grep "On branch master" 2>&1 >/dev/null || echo "Check should be done on master branch only. Skipping."
......
#!/bin/bash
set -eo pipefail
make s3-upload "S3_UPLOAD_PATH=$CI_BUILD_REF_NAME"
case "$1" in
......@@ -10,7 +14,9 @@ case "$1" in
RPM_PLATFORMS="el/7 fedora/23"
;;
stable)
make s3-upload "S3_UPLOAD_PATH=latest"
if [[ -n "${IS_LATEST}" ]]; then
make s3-upload "S3_UPLOAD_PATH=latest"
fi
apt-get install -yqqq ruby ruby-dev
make packagecloud
......
#!/bin/bash
set -eo pipefail
IS_LATEST=${IS_LATEST:-}
ref_tag=${CI_BUILD_REF_NAME:-master}
if [[ "${ref_tag}" = "master" ]]; then
ref_tag=bleeding
fi
build() {
echo -e "\033[1mBuilding image: \033[32m${1}\033[0m"
docker build -t "${1}" "${2}"
}
tag() {
echo -e "\033[1mTagging image: \033[32m${2}\033[0m"
docker tag "${1}" "${2}"
}
tag_latest() {
if [[ -z "${IS_LATEST}" ]]; then
return
fi
tag "${@}"
}
push() {
docker push "${1}"
}
push_latest() {
if [[ -z "${IS_LATEST}" ]]; then
return
fi
push "${@}"
}
login() {
docker login --username "${1}" --password "${2}" "${3}"
}
logout() {
docker logout "${1}"
}
cp out/deb/gitlab-ci-multi-runner_amd64.deb dockerfiles/ubuntu/
cp out/binaries/gitlab-ci-multi-runner-linux-amd64 dockerfiles/alpine
build "gitlab/gitlab-runner:ubuntu-${ref_tag}" dockerfiles/ubuntu
build "gitlab/gitlab-runner:alpine-${ref_tag}" dockerfiles/alpine
tag "gitlab/gitlab-runner:ubuntu-${ref_tag}" "gitlab/gitlab-runner:${ref_tag}"
tag_latest "gitlab/gitlab-runner:ubuntu-${ref_tag}" gitlab/gitlab-runner:ubuntu
tag_latest "gitlab/gitlab-runner:ubuntu-${ref_tag}" gitlab/gitlab-runner:latest
tag_latest "gitlab/gitlab-runner:alpine-${ref_tag}" gitlab/gitlab-runner:alpine
if [[ -n "${CI_REGISTRY}" ]] && [[ -n "${CI_REGISTRY_IMAGE}" ]]; then
tag "gitlab/gitlab-runner:ubuntu-${ref_tag}" "${CI_REGISTRY_IMAGE}:ubuntu-${ref_tag}"
tag "gitlab/gitlab-runner:alpine-${ref_tag}" "${CI_REGISTRY_IMAGE}:alpine-${ref_tag}"
tag "gitlab/gitlab-runner:${ref_tag}" "${CI_REGISTRY_IMAGE}:${ref_tag}"
tag_latest gitlab/gitlab-runner:ubuntu "${CI_REGISTRY_IMAGE}:ubuntu"
tag_latest gitlab/gitlab-runner:latest "${CI_REGISTRY_IMAGE}:latest"
tag_latest gitlab/gitlab-runner:alpine "${CI_REGISTRY_IMAGE}:alpine"
if [[ -n "${CI_BUILD_TOKEN}" ]]; then
login gitlab-ci-token "${CI_BUILD_TOKEN}" "${CI_REGISTRY}"
push "${CI_REGISTRY_IMAGE}:ubuntu-${ref_tag}"
push "${CI_REGISTRY_IMAGE}:alpine-${ref_tag}"
push "${CI_REGISTRY_IMAGE}:${ref_tag}"
push_latest "${CI_REGISTRY_IMAGE}:ubuntu"
push_latest "${CI_REGISTRY_IMAGE}:latest"
push_latest "${CI_REGISTRY_IMAGE}:alpine"
logout "${CI_REGISTRY}"
fi
fi
if [[ -n "${DOCKER_HUB_USER}" ]] && [[ -n "${DOCKER_HUB_PASSWORD}" ]]; then
login "${DOCKER_HUB_USER}" "${DOCKER_HUB_PASSWORD}"
push "gitlab/gitlab-runner:ubuntu-${ref_tag}"
push "gitlab/gitlab-runner:alpine-${ref_tag}"
push "gitlab/gitlab-runner:${ref_tag}"
push_latest gitlab/gitlab-runner:ubuntu
push_latest gitlab/gitlab-runner:latest
push_latest gitlab/gitlab-runner:alpine
logout
fi
#!/bin/bash
set -eo pipefail
version=$(cat VERSION || echo dev | sed -e 's/^v//g')
exact_tag=$(git describe --exact-match 2>/dev/null | sed -e 's/^v//g' || echo "")
last_tag=$(git describe --tags --abbrev=0)
last_tag=$(git describe --tags --abbrev=0 --match 'v[0-9].[0-9].[0-9]')
commits=$(git log --oneline ${last_tag}..HEAD | wc -l)
revision=$(git rev-parse --short HEAD || echo unknown)
if [ $(echo ${exact_tag} | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$") ]; then
if [[ $(echo ${exact_tag} | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$") ]]; then
echo $exact_tag
exit 0
fi
if [ $(echo ${exact_tag} | grep -E "^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$") ]; then
if [[ $(echo ${exact_tag} | grep -E "^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$") ]]; then
echo $exact_tag
exit 0
fi
......
......@@ -10,15 +10,15 @@ RUN apk add --update \
openssl \
wget
RUN wget -O /usr/bin/gitlab-ci-multi-runner https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-ci-multi-runner-linux-amd64 && \
chmod +x /usr/bin/gitlab-ci-multi-runner && \
COPY gitlab-ci-multi-runner-linux-amd64 /usr/bin/gitlab-ci-multi-runner
RUN chmod +x /usr/bin/gitlab-ci-multi-runner && \
ln -s /usr/bin/gitlab-ci-multi-runner /usr/bin/gitlab-runner && \
wget -q https://github.com/docker/machine/releases/download/v0.7.0/docker-machine-Linux-x86_64 -O /usr/bin/docker-machine && \
chmod +x /usr/bin/docker-machine && \
mkdir -p /etc/gitlab-runner/certs && \
chmod -R 700 /etc/gitlab-runner
ADD entrypoint /
COPY entrypoint /
RUN chmod +x /entrypoint
VOLUME ["/etc/gitlab-runner", "/home/gitlab-runner"]
......
......@@ -9,18 +9,20 @@ RUN apt-get update -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN echo "deb https://packages.gitlab.com/runner/gitlab-ci-multi-runner/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/runner_gitlab-ci-multi-runner.list && \
wget -q -O - https://packages.gitlab.com/gpg.key | apt-key add - && \
apt-get update -y && \
apt-get install -y gitlab-ci-multi-runner && \
COPY gitlab-ci-multi-runner_amd64.deb /tmp/
RUN dpkg -i /tmp/gitlab-ci-multi-runner_amd64.deb; \
apt-get update && \
apt-get -f install -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm /tmp/gitlab-ci-multi-runner_amd64.deb && \
gitlab-runner --version && \
wget -q https://github.com/docker/machine/releases/download/v0.7.0/docker-machine-Linux-x86_64 -O /usr/bin/docker-machine && \
chmod +x /usr/bin/docker-machine && \
apt-get clean && \
mkdir -p /etc/gitlab-runner/certs && \
chmod -R 700 /etc/gitlab-runner && \
rm -rf /var/lib/apt/lists/*
chmod -R 700 /etc/gitlab-runner
ADD entrypoint /
COPY entrypoint /
RUN chmod +x /entrypoint
VOLUME ["/etc/gitlab-runner", "/home/gitlab-runner"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment