generated from AgnostiqHQ/covalent-executor-template
-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (145 loc) · 5.34 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# 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:
repository_dispatch:
types: ["prerelease", "stable"]
workflow_dispatch:
inputs:
version:
description: "AWS Braket plugin version number, e.g. 0.32.3 - For docker image version"
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:
prerelease: ${{ inputs.prerelease }}
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
ref: further-fixes-for-release
- 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 AWS 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 docker image
if: >
env.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-braket-executor:latest
public.ecr.aws/covalent/covalent-braket-executor:${{ env.TAG }}
public.ecr.aws/covalent/covalent-braket-executor:${{ env.COV_VER_TAG }}
- name: Build and push stable release
if: >
!env.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-braket-executor:stable
public.ecr.aws/covalent/covalent-braket-executor:${{ env.TAG }}
public.ecr.aws/covalent/covalent-braket-executor:${{ env.COV_VER_TAG }}