Manual Docker Build #1681
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Manual Docker Build | |
on: | |
workflow_dispatch: | |
inputs: | |
release_token: | |
description: 'Your release token' | |
required: true | |
triggered_by: | |
description: 'CD | TAG | MANUAL' | |
required: false | |
default: MANUAL | |
jobs: | |
token-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check release token | |
id: token-check | |
run: | | |
touch SUCCESS | |
if: inputs.release_token == env.release_token | |
env: | |
release_token: ${{ secrets.JINA_CORE_RELEASE_TOKEN }} | |
- name: Fail release token | |
run: | | |
[[ -f SUCCESS ]] | |
regular-release: | |
needs: token-check | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
pip_tag: [ "", "perf", "standard", "devel"] # default: "" = core | |
py_version: [ "3.7", "3.8", "3.9" , "3.10", "3.11"] # default "" = 3.7 | |
steps: | |
- uses: actions/checkout@v2.5.0 | |
with: | |
fetch-depth: 100 | |
- name: Set envs and versions | |
run: | | |
DEFAULT_PY_VERSION="3.8" | |
VCS_REF=${{ github.ref }} | |
echo "VCS_REF=$VCS_REF" >> $GITHUB_ENV | |
echo "Will build $VCS_REF" | |
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV | |
echo "BUILD_TARGET=jina" >> $GITHUB_ENV | |
if [[ "${{ matrix.pip_tag }}" == "perf" ]]; then | |
echo "JINA_PIP_INSTALL_PERF=1" >> $GITHUB_ENV | |
fi | |
if [[ "${{ matrix.pip_tag }}" == "" ]]; then | |
echo "JINA_PIP_INSTALL_CORE=1" >> $GITHUB_ENV | |
fi | |
JINA_VERSION=$(sed -n '/^__version__/p' ./jina/__init__.py | cut -d \' -f2) | |
V_JINA_VERSION=v${JINA_VERSION} | |
JINA_MINOR_VERSION=${JINA_VERSION%.*} | |
JINA_MAJOR_VERSION=${JINA_MINOR_VERSION%.*} | |
PY_TAG=${{matrix.py_version}} | |
if [ -n "${PY_TAG}" ]; then | |
PY_TAG=-py${PY_TAG//./} | |
fi | |
PIP_TAG=${{ matrix.pip_tag }} | |
if [ -n "${PIP_TAG}" ]; then | |
PIP_TAG=-${PIP_TAG} | |
fi | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
LAST_VER_TAG=$(git tag -l | sort -V | tail -n1) | |
PRE_VERSION=-dev$(git rev-list $LAST_VER_TAG..HEAD --count) | |
if [[ "${{ github.event.inputs.triggered_by }}" == "CD" ]]; then | |
if [[ "${{ matrix.py_version }}" == "$DEFAULT_PY_VERSION" ]]; then | |
echo "TAG_ALIAS=\ | |
jinaai/jina:master${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:master${PIP_TAG}, \ | |
jinaai/jina:${JINA_VERSION}${PRE_VERSION}${PIP_TAG}, \ | |
jinaai/jina:${JINA_VERSION}${PRE_VERSION}${PY_TAG}${PIP_TAG}" \ | |
>> $GITHUB_ENV | |
else | |
# on every CD | |
echo "TAG_ALIAS=\ | |
jinaai/jina:master${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:${JINA_VERSION}${PRE_VERSION}${PY_TAG}${PIP_TAG}" \ | |
>> $GITHUB_ENV | |
fi | |
elif [[ "${{ github.event.inputs.triggered_by }}" == "TAG" ]]; then | |
# on every tag release | |
if [[ "${{ matrix.py_version }}" == "$DEFAULT_PY_VERSION" ]]; then | |
echo "TAG_ALIAS=\ | |
jinaai/jina:latest${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:${JINA_VERSION}${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:${JINA_MINOR_VERSION}${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:${JINA_MAJOR_VERSION}${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:latest${PIP_TAG}, \ | |
jinaai/jina:${JINA_VERSION}${PIP_TAG}, \ | |
jinaai/jina:${JINA_MINOR_VERSION}${PIP_TAG}, \ | |
jinaai/jina:${JINA_MAJOR_VERSION}${PIP_TAG} \ | |
" >> $GITHUB_ENV | |
else | |
echo "TAG_ALIAS=\ | |
jinaai/jina:latest${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:${JINA_VERSION}${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:${JINA_MINOR_VERSION}${PY_TAG}${PIP_TAG}, \ | |
jinaai/jina:${JINA_MAJOR_VERSION}${PY_TAG}${PIP_TAG} \ | |
" >> $GITHUB_ENV | |
fi | |
elif [[ "${{ github.event.inputs.triggered_by }}" == "MANUAL" ]]; then | |
# on every manual release | |
if [[ "${{ matrix.py_version }}" == "$DEFAULT_PY_VERSION" ]]; then | |
echo "TAG_ALIAS=\ | |
jinaai/jina:${JINA_VERSION}${PIP_TAG}, \ | |
jinaai/jina:${JINA_VERSION}${PY_TAG}${PIP_TAG} \ | |
" >> $GITHUB_ENV | |
else | |
echo "TAG_ALIAS=\ | |
jinaai/jina:${JINA_VERSION}${PY_TAG}${PIP_TAG} \ | |
" >> $GITHUB_ENV | |
fi | |
else | |
echo "Bad triggered_by: ${{ github.event.inputs.triggered_by }}!" | |
exit 1 | |
fi | |
echo "JINA_VERSION=${JINA_VERSION}" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
install: true | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_DEVBOT_USER }} | |
password: ${{ secrets.DOCKERHUB_DEVBOT_TOKEN }} | |
- run: | | |
# https://github.com/docker/buildx/issues/464#issuecomment-741507760 | |
# https://github.com/kubernetes-sigs/azuredisk-csi-driver/pull/808/files | |
docker run --privileged --rm tonistiigi/binfmt --uninstall qemu-aarch64 | |
docker run --rm --privileged tonistiigi/binfmt --install all | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: Dockerfiles/debianx.Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{env.TAG_ALIAS}} | |
build-args: | | |
BUILD_DATE=${{env.BUILD_DATE}} | |
JINA_VERSION=${{env.JINA_VERSION}} | |
VCS_REF=${{env.VCS_REF}} | |
PIP_INSTALL_CORE=${{env.JINA_PIP_INSTALL_CORE}} | |
PIP_INSTALL_PERF=${{env.JINA_PIP_INSTALL_PERF}} | |
PY_VERSION=${{matrix.py_version}} | |
PIP_TAG=${{matrix.pip_tag}} | |
target: ${{env.BUILD_TARGET}} |