Skip to content
Snippets Groups Projects
Commit a5f03d00 authored by Yaroslav Lobankov's avatar Yaroslav Lobankov Committed by Yaroslav Lobankov
Browse files

cd: build and push Docker image on release tag

This patch adds the Docker image build routine as a part of the release
pipeline.

A word about image tags.

For example, if a release tag is 3.1.0, the resulting Docker image will
be pushed to Docker Hub with the following tags: 3.1.0, 3.1, 3.
If a release tag is 3.1.0-alpha1, the resulting Docker image will be
pushed to Docker Hub with one tag: 3.1.0-alpha1.
Same for 3.1.0-beta1 or 3.1.0-rc1 tag.

Closes #9596

NO_DOC=cd
NO_TEST=cd
NO_CHANGELOG=cd
parent 20729a46
No related branches found
No related tags found
No related merge requests found
name: packaging
name: distrib
on:
push:
......@@ -49,7 +49,7 @@ jobs:
contains(github.event.pull_request.labels.*.name, 'full-ci') ||
contains(github.event.pull_request.labels.*.name, 'static-build-ci') )
uses: ./.github/workflows/static_build_pack_test_deploy.yml
uses: ./.github/workflows/packaging_build_test_deploy.yml
with:
arch: x86_64
test-matrix: '{
......@@ -70,7 +70,7 @@ jobs:
contains(github.event.pull_request.labels.*.name, 'full-ci') ||
contains(github.event.pull_request.labels.*.name, 'static-build-ci') )
uses: ./.github/workflows/static_build_pack_test_deploy.yml
uses: ./.github/workflows/packaging_build_test_deploy.yml
with:
arch: aarch64
test-matrix: '{
......@@ -82,3 +82,14 @@ jobs:
]
}'
secrets: inherit
docker:
# Run on push of a tag except '*-entrypoint' to tarantool/tarantool.
if: github.repository == 'tarantool/tarantool' &&
startsWith(github.ref, 'refs/tags/') &&
!endsWith(github.ref, '-entrypoint')
needs: [ packaging-x86_64, packaging-aarch64 ]
uses: ./.github/workflows/docker_build_push.yml
secrets: inherit
name: docker-build-push
on:
workflow_call:
env:
DOCKERHUB_API: https://hub.docker.com/v2
jobs:
build-push:
runs-on: [ self-hosted, Linux, x86_64, regular ]
steps:
- name: Prepare checkout
uses: tarantool/actions/prepare-checkout@master
- uses: actions/checkout@v4
- uses: ./.github/actions/environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Compose image tags
run: |
REPO=tarantool/tarantool
case ${{ github.ref }} in
refs/tags/*-alpha*|refs/tags/*-beta*|refs/tags/*-rc*)
echo "TAGS=${REPO}:${{ github.ref_name }}" >> $GITHUB_ENV
;;
refs/tags/*)
MAJOR=$(echo ${{ github.ref_name }} | cut -f1 -d.)
MINOR=$(echo ${{ github.ref_name }} | cut -f2 -d.)
MAJOR_MINOR=${MAJOR}.${MINOR}
TAGS=${REPO}:${{ github.ref_name }},${REPO}:${MAJOR_MINOR}
echo "TAGS=${TAGS}" >> $GITHUB_ENV
# Add the major version tag (3, 4, 5, etc.) to the image if tag
# {major_version}.{minor_version + 1} does not exist.
# Let's say we have 3.1.0 release, and it is the latest release of
# Tarantool. According to this fact, we have the existing image on
# Docker Hub with three tags: 3.1.0, 3.1, 3.
# If 3.0.2 release is created, the corresponding image will be
# pushed to Docker Hub with tags 3.0.2, 3.0, and tag 3 will not
# be pushed since tag 3.1 exists and tag 3 should point to the
# same image which tag 3.1 points to.
MAJOR_MINOR_UP=${MAJOR}.$((MINOR + 1))
if curl \
--location \
--silent \
--show-error \
--retry 5 \
--retry-delay 5 \
--request GET \
${DOCKERHUB_API}/repositories/${REPO}/tags/${MAJOR_MINOR_UP} \
| grep -o "tag '${MAJOR_MINOR_UP}' not found"; then
echo "adding tag '${REPO}:${MAJOR}'"
echo "adding tag '${REPO}:latest'"
TAGS=${TAGS},${REPO}:${MAJOR},${REPO}:latest
echo "TAGS=${TAGS}" >> $GITHUB_ENV
fi
;;
esac
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: ./docker
file: ./docker/Dockerfile
build-args: TARANTOOL_VERSION=${{ github.ref_name }}
platforms: linux/amd64,linux/arm64
no-cache: true
push: true
tags: ${{ env.TAGS }}
- name: Send VK Teams message on failure
if: failure()
uses: ./.github/actions/report-job-status
with:
bot-token: ${{ secrets.VKTEAMS_BOT_TOKEN }}
name: static_build_pack_test_deploy
name: packaging-build-test-deploy
on:
workflow_call:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment