Skip to content

Commit a6ab668

Browse files
authored
Refined release workflow (#97)
The workflow will be tested soon and modifications will be made if required from the test. 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 1c0d27c commit a6ab668

File tree

3 files changed

+71
-32
lines changed

3 files changed

+71
-32
lines changed

.github/actions/artifacts_build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ inputs:
1313
required: true
1414
description: "Image Registry"
1515
snapshot-ecr-role:
16-
require: true
16+
required: true
1717
description: "IAM Role used for pushing to snapshot ecr"
1818
push_image:
1919
required: true

.github/workflows/release_build.yml

Lines changed: 69 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
#This Release Build workflow is not fully ready yet, will be tested as Beta release when it is ready.
21
name: Release Build
32
on:
43
workflow_dispatch:
54
inputs:
65
version:
7-
description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1
6+
description: The version to tag the release with, e.g., 1.2.0
87
required: true
98

109
env:
1110
AWS_DEFAULT_REGION: us-east-1
12-
ECR_REGISTRY: 637423224110.dkr.ecr.us-east-1.amazonaws.com
13-
PRIVATE_ECR_REPOSITORY: eks/observability/adot-autoinstrumentation-python
11+
AWS_PUBLIC_ECR_REGION: us-east-1
12+
AWS_PRIVATE_ECR_REGION: us-west-2
13+
RELEASE_PUBLIC_REPOSITORY: public.ecr.aws/aws-observability/adot-autoinstrumentation-python
14+
RELEASE_PRIVATE_REPOSITORY: 020628701572.dkr.ecr.us-west-2.amazonaws.com/adot-autoinstrumentation-python
15+
RELEASE_PRIVATE_REGISTRY: 020628701572.dkr.ecr.us-west-2.amazonaws.com
16+
PACKAGE_NAME: aws-opentelemetry-distro
1417

1518
permissions:
1619
id-token: write
@@ -23,62 +26,98 @@ jobs:
2326
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
2427
uses: actions/checkout@v4
2528

29+
# NOTE: do not set push_image to true for this step.
30+
# Some of the required params below are set to dummy values
31+
# as they are only used in the artifacts_build action when push_image is true,
32+
# and setting them to some legit value might cause confusion
33+
# to readers.
2634
- name: Build Wheel and Image Files
2735
uses: ./.github/actions/artifacts_build
2836
with:
2937
aws-region: ${{ env.AWS_DEFAULT_REGION }}
30-
image_uri_with_tag: ${{ env.ECR_REGISTRY }}/${{ env.PRIVATE_ECR_REPOSITORY }}:v${{ github.event.inputs.version }}
31-
image_registry: ${{ env.ECR_REGISTRY }}
32-
snapshot-ecr-role: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
38+
image_uri_with_tag: "adot-autoinstrumentation-python:test"
39+
image_registry: "dummy-registry"
40+
snapshot-ecr-role: "dummy-role"
3341
push_image: false
3442
load_image: false
3543
python_version: "3.10"
3644
package_name: aws-opentelemetry-distro
3745
os: ubuntu-latest
3846

39-
- name: Get PyPI secrets by name and ARN
47+
# TODO: Add some sort of smoke/integration testing before we go
48+
# release the artifacts. adot java for reference:
49+
# https://github.com/aws-observability/aws-otel-java-instrumentation/tree/93870a550ac30988fbdd5d3bf1e8f9f1b37916f5/smoke-tests
50+
51+
- name: Configure AWS credentials for PyPI secrets
52+
uses: aws-actions/configure-aws-credentials@v4
53+
with:
54+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_PYPI_RELEASE }}
55+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
56+
57+
- name: Get PyPI secrets
4058
uses: aws-actions/aws-secretsmanager-get-secrets@v1
4159
id: pypi_secrets
4260
with:
4361
secret-ids: |
44-
PROD_PYPI_TOKEN,arn:aws:secretsmanager:us-east-1:637423224110:secret:prod/PyPI/apiToken-W2a9ny
45-
TEST_PYPI_TOKEN,arn:aws:secretsmanager:us-east-1:637423224110:secret:test/PyPI/apiToken-z5iqc6
62+
PROD_PYPI_TOKEN,${{ secrets.PYPI_PROD_TOKEN_SECRET_ARN }}
63+
TEST_PYPI_TOKEN,${{ secrets.PYPI_TEST_TOKEN_SECRET_ARN }}
64+
parse-json-secrets: true
4665

47-
- name: Export distro version
48-
id: distro_version
49-
shell: bash
50-
run: |
51-
pkg_version=$(grep '__version__' ./aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py | awk -F '"' '{print $2}')
52-
echo "ADOT_PYTHON_VERSION=$pkg_version" >> $GITHUB_OUTPUT
66+
- name: Configure AWS credentials for private ECR
67+
uses: aws-actions/configure-aws-credentials@v4
68+
with:
69+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_ECR_RELEASE }}
70+
aws-region: ${{ env.AWS_PRIVATE_ECR_REGION }}
71+
72+
- name: Log in to AWS private ECR
73+
uses: docker/login-action@v3
74+
with:
75+
registry: ${{ env.RELEASE_PRIVATE_REGISTRY }}
76+
77+
- name: Configure AWS credentials for public ECR
78+
uses: aws-actions/configure-aws-credentials@v4
79+
with:
80+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_ECR_RELEASE }}
81+
aws-region: ${{ env.AWS_PUBLIC_ECR_REGION }}
82+
83+
- name: Log in to AWS public ECR
84+
uses: docker/login-action@v3
85+
with:
86+
registry: public.ecr.aws
5387

5488
# The step below publishes to testpypi in order to catch any issues
5589
# with the package configuration that would cause a failure to upload to pypi.
90+
- name: Install twine
91+
run: pip install twine
92+
5693
- name: Publish to TestPyPI
5794
env:
5895
TWINE_USERNAME: '__token__'
59-
TWINE_PASSWORD: ${{ steps.pypi_secrets.outputs.TEST_PYPI_TOKEN }}
96+
TWINE_PASSWORD: ${{ env.TEST_PYPI_TOKEN_API_TOKEN }}
6097
run: |
61-
pip install --upgrade twine
62-
twine upload --repository testpypi --skip-existing --verbose dist/aws_opentelemetry_distro-${{ steps.distro_version.outputs.ADOT_PYTHON_VERSION }}-py3-none-any.whl
98+
twine upload --repository testpypi --skip-existing --verbose dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
6399
64-
- name: Push release image
100+
# The following step publish to ECR
101+
- name: Build and push images
65102
uses: docker/build-push-action@v5
66103
with:
67104
push: true
68105
context: .
69106
file: ./Dockerfile
70107
platforms: linux/amd64,linux/arm64
71-
tags: ${{ env.ECR_REGISTRY }}/${{ env.PRIVATE_ECR_REPOSITORY }}:v${{ github.event.inputs.version }}
108+
tags: |
109+
${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ github.event.inputs.version }}
110+
${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ github.event.inputs.version }}
72111
73-
#TODO: Uncomment "Publish to PyPI" after test release_build workflow.
74-
# - name: Publish to PyPI
75-
# env:
76-
# TWINE_USERNAME: '__token__'
77-
# TWINE_PASSWORD: ${{ steps.pypi_secrets.outputs.PROD_PYPI_TOKEN }}
78-
# run: |
79-
# twine upload --skip-existing --verbose dist/aws_opentelemetry_distro-${{ steps.distro_version.outputs.ADOT_PYTHON_VERSION }}-py3-none-any.whl
112+
# Publish to prod PyPI
113+
- name: Publish to PyPI
114+
env:
115+
TWINE_USERNAME: '__token__'
116+
TWINE_PASSWORD: ${{ env.PROD_PYPI_TOKEN_API_TOKEN }}
117+
run: |
118+
twine upload --skip-existing --verbose dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
80119
81-
- name: Create release
120+
- name: Create GH release
82121
id: create_release
83122
env:
84123
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
@@ -87,4 +126,4 @@ jobs:
87126
--title "Release v${{ github.event.inputs.version }}" \
88127
--draft \
89128
"v${{ github.event.inputs.version }}" \
90-
dist/aws_opentelemetry_distro-${{ steps.distro_version.outputs.ADOT_PYTHON_VERSION }}-py3-none-any.whl
129+
dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
__version__ = "0.0.1"
4+
__version__ = "0.0.0.dev"

0 commit comments

Comments
 (0)