1+ name : ecr-release.yml
2+ on :
3+ release :
4+ types : [published]
5+
6+ permissions :
7+ contents : read
8+ id-token : write # This is required for requesting the JWT
9+
10+ env :
11+ path_to_dockerfile : " Dockerfile"
12+ docker_build_dir : " ."
13+ aws_region : " us-east-1"
14+ ecr_repository_name : " durable-functions/aws-durable-execution-emulator"
15+
16+ jobs :
17+ build-and-upload-image-to-ecr :
18+ runs-on : ubuntu-latest
19+ outputs :
20+ full_image_arm64 : ${{ steps.build-publish.outputs.full_image_arm64 }}
21+ full_image_x86_64 : ${{ steps.build-publish.outputs.full_image_x86_64 }}
22+ ecr_registry_repository : ${{ steps.build-publish.outputs.ecr_registry_repository }}
23+ version : ${{ steps.version.outputs.VERSION }}
24+ strategy :
25+ matrix :
26+ include :
27+ - arch : x86_64
28+ - arch : arm64
29+ steps :
30+ - uses : actions/checkout@v6
31+ - name : Set up Python
32+ uses : actions/setup-python@v6
33+ with :
34+ python-version : " 3.13"
35+ - name : Install dependencies
36+ run : |
37+ python -m pip install --upgrade pip
38+ pip install hatch
39+ - name : Set up QEMU for multi-platform builds
40+ if : matrix.arch == 'arm64'
41+ uses : docker/setup-qemu-action@v3
42+ with :
43+ platforms : arm64
44+ - name : Build distribution
45+ run : hatch build
46+ - name : Get version from __about__.py
47+ id : version
48+ run : |
49+ VERSION=$(grep "^__version__" src/aws_durable_execution_sdk_python_testing/__about__.py | cut -d'"' -f2)
50+ echo "VERSION=$VERSION"
51+ echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
52+ - name : Configure AWS Credentials
53+ uses : aws-actions/configure-aws-credentials@v4
54+ with :
55+ role-to-assume : ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }}
56+ aws-region : ${{ env.aws_region }}
57+ - name : Login to Amazon ECR
58+ id : login-ecr-public
59+ uses : aws-actions/amazon-ecr-login@v2
60+ with :
61+ registry-type : public
62+ - name : Build, tag, and push image to Amazon ECR
63+ id : build-publish
64+ shell : bash
65+ env :
66+ ECR_REGISTRY : ${{ steps.login-ecr-public.outputs.registry }}
67+ ECR_REPOSITORY : ${{ env.ecr_repository_name }}
68+ PER_ARCH_IMAGE_TAG : " v${{ steps.version.outputs.VERSION }}-${{ matrix.arch }}"
69+ run : |
70+ if [ "${{ matrix.arch }}" = "x86_64" ]; then
71+ docker build --platform linux/amd64 --provenance false "${{ env.docker_build_dir }}" -f "${{ env.path_to_dockerfile }}" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
72+ else
73+ docker build --platform linux/arm64 --provenance false "${{ env.docker_build_dir }}" -f "${{ env.path_to_dockerfile }}" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
74+ fi
75+ docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
76+ echo "IMAGE $PER_ARCH_IMAGE_TAG is pushed to $ECR_REGISTRY/$ECR_REPOSITORY"
77+ echo "image_tag=$PER_ARCH_IMAGE_TAG"
78+ echo "full_image=$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
79+ echo "ecr_registry_repository=$ECR_REGISTRY/$ECR_REPOSITORY" >> $GITHUB_OUTPUT
80+ echo "full_image_${{ matrix.arch }}=$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG" >> $GITHUB_OUTPUT
81+ create-ecr-manifest-per-arch :
82+ runs-on : ubuntu-latest
83+ needs : [build-and-upload-image-to-ecr]
84+ steps :
85+ - name : Grab image, registry/repository name, version from previous steps
86+ id : ecr_names
87+ env :
88+ ECR_REGISTRY_REPOSITORY : ${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}
89+ FULL_IMAGE_ARM64 : ${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}
90+ FULL_IMAGE_X86_64 : ${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}
91+ VERSION : ${{ needs.build-and-upload-image-to-ecr.outputs.version }}
92+ run : |
93+ echo "full_image_arm64=$FULL_IMAGE_ARM64"
94+ echo "ecr_registry_repository=$ECR_REGISTRY_REPOSITORY"
95+ echo "full_image_x86_64=$FULL_IMAGE_X86_64"
96+ echo "version=$VERSION"
97+ - name : Configure AWS Credentials
98+ uses : aws-actions/configure-aws-credentials@v4
99+ with :
100+ role-to-assume : ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }}
101+ aws-region : ${{ env.aws_region }}
102+ - name : Login to Amazon ECR
103+ id : login-ecr-public
104+ uses : aws-actions/amazon-ecr-login@v2
105+ with :
106+ registry-type : public
107+ - name : Create ECR manifest with explicit tag
108+ id : create-ecr-manifest-explicit
109+ run : |
110+ docker manifest create "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
111+ "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
112+ "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}"
113+ - name : Annotate ECR manifest with explicit arm64 tag
114+ id : annotate-ecr-manifest-explicit-arm64
115+ run : |
116+ docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
117+ "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
118+ --arch arm64 \
119+ --os linux
120+ - name : Annotate ECR manifest with explicit amd64 tag
121+ id : annotate-ecr-manifest-explicit-amd64
122+ run : |
123+ docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
124+ "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
125+ --arch amd64 \
126+ --os linux
127+ - name : Push ECR manifest with explicit version
128+ id : push-ecr-manifest-explicit
129+ run : |
130+ docker manifest push "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}"
131+ - name : Create ECR manifest with latest tag
132+ id : create-ecr-manifest-latest
133+ run : |
134+ docker manifest create "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
135+ "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
136+ "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}"
137+ - name : Annotate ECR manifest with latest tag arm64
138+ id : annotate-ecr-manifest-latest-arm64
139+ run : |
140+ docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
141+ "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
142+ --arch arm64 \
143+ --os linux
144+ - name : Annotate ECR manifest with latest tag amd64
145+ id : annotate-ecr-manifest-latest-amd64
146+ run : |
147+ docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
148+ "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
149+ --arch amd64 \
150+ --os linux
151+ - name : Push ECR manifest with latest
152+ id : push-ecr-manifest-latest
153+ run : |
154+ docker manifest push "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}"
0 commit comments