Skip to content

docker

docker #47

Workflow file for this run

# Copyright 2021 Agnostiq Inc.
#
# This file is part of Covalent.
#
# Licensed under the Apache License 2.0 (the "License"). A copy of the
# License may be obtained with this software package or at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Use of this file is prohibited except in compliance with the License.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: docker
on:
workflow_dispatch:
inputs:
version:
description: "AWS Plugins version number, e.g. 0.32.3"
type: string
covalent_version:
required: false
description: "Covalent pip package, e.g. covalent>=0.202.0,<1 or covalent==0.202.0"
type: string
default: "covalent>=0.202.0,<1"
prerelease:
description: "true: Create a prerelease. false: Create a stable release"
required: true
type: boolean
default: true
workflow_call:
inputs:
prerelease:
description: "true: Create a prerelease. false: Create a stable release"
required: true
type: boolean
default: true
covalent_version:
required: false
description: "Covalent pip package, e.g. covalent>=0.202.0,<1 or covalent==0.202.0"
type: string
default: "covalent>=0.202.0,<1"
jobs:
docker:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
env:
version: ${{ inputs.version }}
covalent_version: ${{ inputs.covalent_version }}
steps:
- name: Check out release tag
uses: actions/checkout@v2
if: >
env.version
with:
persist-credentials: false
fetch-depth: 0
ref: "v${{ env.version }}"
- name: Checkout default branch (develop)
uses: actions/checkout@v2
if: >
!env.version
with:
persist-credentials: false
fetch-depth: 0
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: "linux/amd64"
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/setup-python@v4
with:
python-version: "3.8.13"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.ECR_PUBLIC_UPLOAD_ROLE }}
aws-region: us-east-1
- name: Login to Public registry
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
- name: Generate Tag
run: |
TAG="$(cat ./VERSION)"
echo "TAG: $TAG"
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Generate Tag v2
run: |
pip install "${{ env.covalent_version }}"
package_info=$(pip show covalent)
package_version=$(echo "$package_info" | grep -E '^Version: ' | cut -d' ' -f2)
major_version=$(echo "$package_version" | sed -E 's/^([0-9]+)\..*$/\1/')
minor_version=$(echo "$package_version" | sed -E 's/^[0-9]+\.([0-9]+)\..*$/\1/')
patch_version=$(echo "$package_version" | sed -E 's/^[0-9]+.[0-9]+\.([0-9]+).*$/\1/')
echo "Major version: $major_version"
echo "Minor version: $minor_version"
echo "Patch version: $patch_version"
COV_VER_TAG="$major_version.$minor_version.$patch_version"
echo "COV_VER_TAG: $COV_VER_TAG"
echo "COV_VER_TAG=$COV_VER_TAG" >> $GITHUB_ENV
- name: Build and push pre-release image version
if: >
inputs.prerelease
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
files: Dockerfile
platforms: "linux/amd64"
push: true
build-args: |
COVALENT_BASE_IMAGE=python:3.8-slim-bullseye
COVALENT_PACKAGE_VERSION=${{ env.covalent_version }}
tags: |
public.ecr.aws/covalent/covalent-executor-base:latest
public.ecr.aws/covalent/covalent-executor-base:${{ env.TAG }}
public.ecr.aws/covalent/covalent-executor-base:${{ env.COV_VER_TAG }}
- name: Build and push stable version
if: >
!inputs.prerelease
&& github.event_name == 'workflow_dispatch'
&& env.version
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
files: Dockerfile
platforms: "linux/amd64"
push: true
build-args: |
COVALENT_BASE_IMAGE=python:3.8-slim-buster
COVALENT_PACKAGE_VERSION=${{ env.covalent_version }}
tags: |
public.ecr.aws/covalent/covalent-executor-base:stable
public.ecr.aws/covalent/covalent-executor-base:${{ env.TAG }}
public.ecr.aws/covalent/covalent-executor-base:${{ env.COV_VER_TAG }}