Skip to content

Commit e75b9bd

Browse files
authored
Back patch PyPI, ECR image and Lambda layer signature to 0.14.x (#592)
*Description of changes:* The CR includes 3 changes: * back patch signing public ECR image(aws-observability/aws-otel-java-instrumentation#1288) * back patch signing PyPI attestation error (#585) * fix signing lambda layer issue that the unsigned s3 file is not overwrite to be the signed. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 1f494f6 commit e75b9bd

1 file changed

Lines changed: 73 additions & 11 deletions

File tree

.github/workflows/release-build.yml

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,19 @@ jobs:
162162
path: dist-pypi
163163

164164
# The step below publishes to testpypi in order to catch any issues
165-
# - name: Publish to TestPyPI
166-
# uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
167-
# with:
168-
# repository-url: https://test.pypi.org/legacy/
169-
# skip-existing: true
170-
# verbose: true
171-
# packages-dir: dist-pypi
165+
- name: Publish to TestPyPI
166+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
167+
with:
168+
attestations: false
169+
repository-url: https://test.pypi.org/legacy/
170+
skip-existing: true
171+
verbose: true
172+
packages-dir: dist-pypi
172173

173174
# Publish to prod PyPI
174175
- name: Publish to PyPI
175176
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
176177
with:
177-
attestations: false
178178
skip-existing: true
179179
verbose: true
180180
packages-dir: dist-pypi
@@ -249,20 +249,32 @@ jobs:
249249
aws s3 cp aws-opentelemetry-python-layer.zip s3://${{ env.BUCKET_NAME }}
250250
251251
# Sign the layer
252+
echo "Checking for signing profile..."
252253
PROFILE=$(aws signer list-signing-profiles --query "profiles[?profileName=='ADOTLambdaLayerSigningProfile'].arn" --output text 2>/dev/null)
253-
[ -z "$PROFILE" ] && exit 0
254+
[ -z "$PROFILE" ] && echo "No signing profile found, skipping" && exit 0
254255
256+
echo "Starting signing job..."
255257
JOB_ID=$(aws signer start-signing-job \
256258
--source "s3={bucketName=${{ env.BUCKET_NAME }},key=aws-opentelemetry-python-layer.zip,version=null}" \
257259
--destination "s3={bucketName=${{ env.BUCKET_NAME }},prefix=signed-}" \
258260
--profile-name ADOTLambdaLayerSigningProfile \
259261
--query 'jobId' --output text 2>/dev/null) || exit 0
260-
[ -z "$JOB_ID" ] && exit 0
262+
[ -z "$JOB_ID" ] && echo "No job ID returned" && exit 0
263+
echo "Job ID: $JOB_ID"
261264
265+
echo "Waiting for signing job to complete..."
262266
aws signer wait successful-signing-job --job-id "$JOB_ID" || exit 0
267+
echo "Signing completed"
263268
269+
echo "Moving signed layer..."
264270
SIGNED=$(aws signer describe-signing-job --job-id "$JOB_ID" --query 'signedObject.s3.key' --output text 2>/dev/null)
265-
[ -n "$SIGNED" ] && aws s3 mv "s3://${{ env.BUCKET_NAME }}/$SIGNED" "s3://${{ env.BUCKET_NAME }}/aws-opentelemetry-python-layer.zip"
271+
echo "SIGNED value: '$SIGNED'"
272+
if [ -n "$SIGNED" ]; then
273+
aws s3 mv "s3://${{ env.BUCKET_NAME }}/$SIGNED" "s3://${{ env.BUCKET_NAME }}/aws-opentelemetry-python-layer.zip --clobber"
274+
echo "Signed layer moved successfully"
275+
else
276+
echo "No SIGNED value returned, skipping move"
277+
fi
266278
267279
- name: Publish Layer Version
268280
run: |
@@ -474,3 +486,53 @@ jobs:
474486
${{ env.WHEEL_ARTIFACT_NAME }}.sha256 \
475487
layer.zip \
476488
layer.zip.sha256
489+
490+
sign-public-ecr-image:
491+
runs-on: ubuntu-latest
492+
needs: publish-sdk
493+
steps:
494+
- name: Configure AWS Credentials for public ECR
495+
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #v5.0.0
496+
with:
497+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_ECR_RELEASE }}
498+
aws-region: ${{ env.AWS_PUBLIC_ECR_REGION }}
499+
500+
# Install notation CLI with AWS Signer plugin
501+
- name: Install notation CLI with AWS Signer plugin
502+
run: |
503+
curl -Lo aws-signer-notation-cli_amd64.deb https://d2hvyiie56hcat.cloudfront.net/linux/amd64/installer/deb/latest/aws-signer-notation-cli_amd64.deb
504+
sudo dpkg -i aws-signer-notation-cli_amd64.deb
505+
notation version
506+
notation plugin ls
507+
508+
# Query ECR signing profile ARN
509+
- name: Query ECR Signing Profile ARN
510+
id: ecr-signing-profile
511+
run: |
512+
PROFILE_ARN=$(aws signer list-signing-profiles --region ${{ env.AWS_PUBLIC_ECR_REGION }} --query "profiles[?profileName=='ADOTECRSigningProfile'].arn" --output text 2>/dev/null)
513+
if [ -n "$PROFILE_ARN" ]; then
514+
echo "profile_arn=$PROFILE_ARN" >> $GITHUB_OUTPUT
515+
echo "Found ECR signing profile: $PROFILE_ARN"
516+
else
517+
echo "ECR signing profile 'ADOTECRSigningProfile' not found"
518+
exit 0
519+
fi
520+
521+
# Login to Public ECR
522+
- name: Log in to AWS public ECR
523+
if: steps.ecr-signing-profile.outputs.profile_arn != ''
524+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 #v3.5.0
525+
with:
526+
registry: public.ecr.aws
527+
528+
# Sign Public ECR Image
529+
- name: Sign Public ECR Image
530+
if: steps.ecr-signing-profile.outputs.profile_arn != ''
531+
run: |
532+
# Sign the released public ECR image
533+
notation sign ${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ github.event.inputs.version }} \
534+
--plugin com.amazonaws.signer.notation.plugin \
535+
--id ${{ steps.ecr-signing-profile.outputs.profile_arn }}
536+
echo "Successfully signed public ECR image"
537+
echo "Image: ${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ github.event.inputs.version }}"
538+
echo "Profile ARN: ${{ steps.ecr-signing-profile.outputs.profile_arn }}"

0 commit comments

Comments
 (0)