From 122864d4066c4269a38ba14ec1a5b1181f51f40c Mon Sep 17 00:00:00 2001 From: Alejandro Esquivel Date: Wed, 26 Apr 2023 12:52:24 -0700 Subject: [PATCH] Updated docker workflow to allow covalent verison configuration (#41) * Updated docker workflow to allow covalent verison configuration * removed check to determine type of call * syntax fix * Updated workflow to extract covalent version and tag image * fix for workflow * debugging * debugging * debugging * updated changelog * added additional tags * updated env vars --- .github/workflows/docker.yml | 64 ++++++++++++++++++++++++++++-------- CHANGELOG.md | 4 +++ 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0e674db..9e2a69e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,9 +23,14 @@ name: docker on: workflow_dispatch: inputs: - stable_version: - description: "Version number, e.g. 0.32.3" + 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 @@ -38,6 +43,11 @@ on: 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: @@ -45,22 +55,24 @@ jobs: permissions: id-token: write contents: read + env: + prerelease: ${{ inputs.prerelease }} + version: ${{ inputs.stable_verion }} + covalent_version: ${{ inputs.covalent_version }} steps: - name: Check out release tag uses: actions/checkout@v2 if: > - github.event_name == 'workflow_dispatch' - && inputs.stable_version + env.version with: persist-credentials: false fetch-depth: 0 - ref: "v${{ inputs.stable_version }}" + ref: "v${{ env.version }}" - name: Checkout default branch (develop) uses: actions/checkout@v2 if: > - inputs.prerelease - && github.event_name == 'workflow_call' + !env.version with: persist-credentials: false fetch-depth: 0 @@ -73,6 +85,10 @@ jobs: - 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: @@ -89,9 +105,29 @@ jobs: 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 + env.prerelease uses: docker/build-push-action@v2 with: builder: ${{ steps.buildx.outputs.name }} @@ -101,17 +137,17 @@ jobs: push: true build-args: | COVALENT_BASE_IMAGE=python:3.8-slim-bullseye - COVALENT_PACKAGE_VERSION=covalent>=0.202.0,<1 - PRE_RELEASE=true + 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 + !env.prerelease && github.event_name == 'workflow_dispatch' - && inputs.stable_version + && env.version uses: docker/build-push-action@v2 with: builder: ${{ steps.buildx.outputs.name }} @@ -121,6 +157,8 @@ jobs: push: true build-args: | COVALENT_BASE_IMAGE=python:3.8-slim-buster - COVALENT_PACKAGE_VERSION=covalent>=0.202.0,<1 + 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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index bb1d015..f76e590 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [UNRELEASED] +### Changed + +- Added configurable covalent version in `docker` workflow to build base executor image + ## [0.15.1] - 2023-02-10 ### Fixed