1+ name : ecr-release.yml
2+ on :
3+ on :
4+ push :
5+ branches : [ "feat/publish-emulator-image" ]
6+ release :
7+ types : [published]
8+
9+ permissions :
10+ contents : read
11+ id-token : write # This is required for requesting the JWT
12+
13+ env :
14+ path_to_dockerfile : " bin/DockerFile"
15+ docker_build_dir : " bin"
16+ aws_region : " us-east-1"
17+ ecr_repository_name : " o4w4w0v6/aws-durable-execution-emulator"
18+
19+ jobs :
20+ build-and-upload-image-to-ecr :
21+ runs-on : ubuntu-latest
22+ outputs :
23+ full_image_arm64 : ${{ steps.build-publish.outputs.full_image_arm64 }}
24+ full_image_x86_64 : ${{ steps.build-publish.outputs.full_image_x86_64 }}
25+ ecr_registry_repository : ${{ steps.build-publish.outputs.ecr_registry_repository }}
26+ strategy :
27+ matrix :
28+ include :
29+ - arch : x86_64
30+ - arch : arm64
31+ steps :
32+ - name : Grab version from generate-version job
33+ id : version
34+ env :
35+ VERSION : $${{ github.event.release.name }}
36+ run : |
37+ echo "$VERSION"
38+ - uses : actions/checkout@v6
39+ - name : Set up Python
40+ uses : actions/setup-python@v6
41+ with :
42+ python-version : " 3.13"
43+
44+ - name : Install dependencies
45+ run : |
46+ python -m pip install --upgrade pip
47+ pip install hatch
48+ - name : Set up QEMU for multi-platform builds
49+ if : matrix.arch == 'arm64'
50+ uses : docker/setup-qemu-action@v3
51+ with :
52+ platforms : arm64
53+ - name : Configure AWS Credentials
54+ uses : aws-actions/configure-aws-credentials@v4
55+ with :
56+ role-to-assume : ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }}
57+ aws-region : ${{ env.aws_region }}
58+ - name : Login to Amazon ECR
59+ id : login-ecr-public
60+ uses : aws-actions/amazon-ecr-login@v2
61+ with :
62+ registry-type : public
63+ - name : Build, tag, and push image to Amazon ECR
64+ id : build-publish
65+ shell : bash
66+ env :
67+ ECR_REGISTRY : ${{ steps.login-ecr-public.outputs.registry }}
68+ ECR_REPOSITORY : ${{ env.ecr_repository_name }}
69+ IMAGE_TAG : " ${{ env.image_tag }}${{ needs.generate-version.outputs.version }}"
70+ PER_ARCH_IMAGE_TAG : " ${{ matrix.arch }}${{ needs.generate-version.outputs.version }}"
71+ run : |
72+ if [ "${{ matrix.arch }}" = "x86_64" ]; then
73+ 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"
74+ else
75+ 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"
76+ fi
77+ docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
78+ echo "IMAGE $PER_ARCH_IMAGE_TAG is pushed to $ECR_REGISTRY/$ECR_REPOSITORY"
79+ echo "image_tag=$PER_ARCH_IMAGE_TAG"
80+ echo "full_image=$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
81+ echo "ecr_registry_repository=$ECR_REGISTRY/$ECR_REPOSITORY" >> $GITHUB_OUTPUT
82+ echo "full_image_${{ matrix.arch }}=$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG" >> $GITHUB_OUTPUT
83+ create-ecr-manifest-per-arch :
84+ runs-on : ubuntu-latest
85+ needs : [build-and-upload-image-to-ecr]
86+ steps :
87+ - name : Grab image and registry/repository name from previous steps
88+ id : ecr_names
89+ env :
90+ ECR_REGISTRY_REPOSITORY : ${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}
91+ FULL_IMAGE_ARM64 : ${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}
92+ FULL_IMAGE_X86_64 : ${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}
93+ run : |
94+ echo "full_image_arm64=$FULL_IMAGE_ARM64"
95+ echo "ecr_registry_repository=$ECR_REGISTRY_REPOSITORY"
96+ echo "full_image_x86_64=$FULL_IMAGE_X86_64"
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 }}:$${{ github.event.release.name }}" \
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 }}:$${{ github.event.release.name }}" \
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 }}:$${{ github.event.release.name }}" \
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 }}:$${{ github.event.release.name }}"
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