|
| 1 | +name: Upload Testing SDK Emulator Image |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + id-token: write |
| 10 | + |
| 11 | +env: |
| 12 | + package_path: packages/aws-durable-execution-sdk-python-testing |
| 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 | + platform: linux/amd64 |
| 29 | + - arch: arm64 |
| 30 | + platform: linux/arm64 |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 34 | + with: |
| 35 | + ref: ${{ github.event.release.tag_name }} |
| 36 | + |
| 37 | + - name: Set up Python |
| 38 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 39 | + with: |
| 40 | + python-version: "3.13" |
| 41 | + |
| 42 | + - name: Install Hatch |
| 43 | + run: python -m pip install --upgrade hatch==1.16.5 |
| 44 | + |
| 45 | + - name: Set up QEMU for multi-platform builds |
| 46 | + if: matrix.arch == 'arm64' |
| 47 | + uses: docker/setup-qemu-action@v3 |
| 48 | + with: |
| 49 | + platforms: arm64 |
| 50 | + |
| 51 | + - name: Build distribution |
| 52 | + working-directory: ${{ env.package_path }} |
| 53 | + run: hatch build |
| 54 | + |
| 55 | + - name: Get version from __about__.py |
| 56 | + id: version |
| 57 | + run: | |
| 58 | + VERSION=$(grep "^__version__" "${{ env.package_path }}/src/aws_durable_execution_sdk_python_testing/__about__.py" | cut -d'"' -f2) |
| 59 | + echo "VERSION=$VERSION" |
| 60 | + echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT" |
| 61 | +
|
| 62 | + - name: Configure AWS Credentials |
| 63 | + uses: aws-actions/configure-aws-credentials@v4 |
| 64 | + with: |
| 65 | + role-to-assume: ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }} |
| 66 | + aws-region: ${{ env.aws_region }} |
| 67 | + |
| 68 | + - name: Login to Amazon ECR |
| 69 | + id: login-ecr-public |
| 70 | + uses: aws-actions/amazon-ecr-login@v2 |
| 71 | + with: |
| 72 | + registry-type: public |
| 73 | + |
| 74 | + - name: Build, tag, and push image to Amazon ECR |
| 75 | + id: build-publish |
| 76 | + shell: bash |
| 77 | + env: |
| 78 | + ECR_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} |
| 79 | + ECR_REPOSITORY: ${{ env.ecr_repository_name }} |
| 80 | + PER_ARCH_IMAGE_TAG: v${{ steps.version.outputs.VERSION }}-${{ matrix.arch }} |
| 81 | + run: | |
| 82 | + docker build --platform "${{ matrix.platform }}" --provenance false "${{ env.package_path }}" -f "${{ env.package_path }}/Dockerfile" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG" |
| 83 | + docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG" |
| 84 | + echo "ecr_registry_repository=$ECR_REGISTRY/$ECR_REPOSITORY" >> "$GITHUB_OUTPUT" |
| 85 | + echo "full_image_${{ matrix.arch }}=$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG" >> "$GITHUB_OUTPUT" |
| 86 | +
|
| 87 | + create-ecr-manifest-per-arch: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: [build-and-upload-image-to-ecr] |
| 90 | + steps: |
| 91 | + - name: Configure AWS Credentials |
| 92 | + uses: aws-actions/configure-aws-credentials@v4 |
| 93 | + with: |
| 94 | + role-to-assume: ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }} |
| 95 | + aws-region: ${{ env.aws_region }} |
| 96 | + |
| 97 | + - name: Login to Amazon ECR |
| 98 | + uses: aws-actions/amazon-ecr-login@v2 |
| 99 | + with: |
| 100 | + registry-type: public |
| 101 | + |
| 102 | + - name: Create and push explicit version manifest |
| 103 | + run: | |
| 104 | + docker manifest create "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \ |
| 105 | + "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \ |
| 106 | + "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" |
| 107 | + docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \ |
| 108 | + "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \ |
| 109 | + --arch arm64 \ |
| 110 | + --os linux |
| 111 | + docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \ |
| 112 | + "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \ |
| 113 | + --arch amd64 \ |
| 114 | + --os linux |
| 115 | + docker manifest push "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" |
| 116 | +
|
| 117 | + - name: Create and push latest manifest |
| 118 | + run: | |
| 119 | + docker manifest create "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \ |
| 120 | + "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \ |
| 121 | + "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" |
| 122 | + docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \ |
| 123 | + "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \ |
| 124 | + --arch arm64 \ |
| 125 | + --os linux |
| 126 | + docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \ |
| 127 | + "${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \ |
| 128 | + --arch amd64 \ |
| 129 | + --os linux |
| 130 | + docker manifest push "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" |
0 commit comments