Skip to content

Commit 978ac26

Browse files
committed
refactor release job order
1 parent 7192017 commit 978ac26

File tree

1 file changed

+121
-109
lines changed

1 file changed

+121
-109
lines changed

.github/workflows/release-build.yml

Lines changed: 121 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ permissions:
2828
contents: write
2929

3030
jobs:
31-
build:
31+
build-sdk:
3232
environment: Release
3333
runs-on: ubuntu-latest
3434
steps:
@@ -67,6 +67,54 @@ jobs:
6767
# release the artifacts. adot java for reference:
6868
# https://github.com/aws-observability/aws-otel-java-instrumentation/tree/93870a550ac30988fbdd5d3bf1e8f9f1b37916f5/smoke-tests
6969

70+
- name: Upload SDK artifact
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: ${{ env.ARTIFACT_NAME }}
74+
path: dist/${{ env.ARTIFACT_NAME }}
75+
76+
build-layer:
77+
needs: build-sdk
78+
runs-on: ubuntu-latest
79+
outputs:
80+
aws_regions_json: ${{ steps.set-matrix.outputs.aws_regions_json }}
81+
steps:
82+
- name: Set up regions matrix
83+
id: set-matrix
84+
run: |
85+
IFS=',' read -ra REGIONS <<< "${{ github.event.inputs.aws_region }}"
86+
MATRIX="["
87+
for region in "${REGIONS[@]}"; do
88+
trimmed_region=$(echo "$region" | xargs)
89+
MATRIX+="\"$trimmed_region\","
90+
done
91+
MATRIX="${MATRIX%,}]"
92+
echo ${MATRIX}
93+
echo "aws_regions_json=${MATRIX}" >> $GITHUB_OUTPUT
94+
- name: Checkout Repo @ SHA - ${{ github.sha }}
95+
uses: actions/checkout@v4
96+
- uses: actions/setup-python@v5
97+
with:
98+
python-version: '3.x'
99+
- name: Build layers
100+
working-directory: lambda-layer/src
101+
run: |
102+
./build-lambda-layer.sh
103+
pip install tox
104+
tox
105+
- name: upload layer
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: layer.zip
109+
path: lambda-layer/src/build/aws-opentelemetry-python-layer.zip
110+
111+
publish-sdk:
112+
needs: [build-sdk, build-layer]
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Checkout Repo @ SHA - ${{ github.sha }}
116+
uses: actions/checkout@v4
117+
70118
- name: Configure AWS credentials for PyPI secrets
71119
uses: aws-actions/configure-aws-credentials@v4
72120
with:
@@ -109,20 +157,25 @@ jobs:
109157
- name: Install twine
110158
run: pip install twine
111159

160+
- name: Download SDK artifact
161+
uses: actions/download-artifact@v4
162+
with:
163+
name: ${{ env.ARTIFACT_NAME }}
164+
112165
- name: Publish to TestPyPI
113166
env:
114167
TWINE_USERNAME: '__token__'
115168
TWINE_PASSWORD: ${{ env.TEST_PYPI_TOKEN_API_TOKEN }}
116169
run: |
117-
twine upload --repository testpypi --skip-existing --verbose dist/${{ env.ARTIFACT_NAME }}
170+
twine upload --repository testpypi --skip-existing --verbose ${{ env.ARTIFACT_NAME }}
118171
119172
# Publish to prod PyPI
120173
- name: Publish to PyPI
121174
env:
122175
TWINE_USERNAME: '__token__'
123176
TWINE_PASSWORD: ${{ env.PROD_PYPI_TOKEN_API_TOKEN }}
124177
run: |
125-
twine upload --skip-existing --verbose dist/${{ env.ARTIFACT_NAME }}
178+
twine upload --skip-existing --verbose ${{ env.ARTIFACT_NAME }}
126179
127180
# Publish to public ECR
128181
- name: Build and push public ECR image
@@ -145,80 +198,10 @@ jobs:
145198
platforms: linux/amd64,linux/arm64
146199
tags: |
147200
${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ github.event.inputs.version }}
148-
149-
- name: Get SHA256 checksum of wheel file
150-
id: get_sha256
151-
run: |
152-
shasum -a 256 dist/${{ env.ARTIFACT_NAME }} | sed "s|dist/||" > ${{ env.ARTIFACT_NAME }}.sha256
153-
154-
# Publish to GitHub releases
155-
- name: Create GH release
156-
id: create_release
157-
env:
158-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
159-
run: |
160-
# Extract versions from pyproject.toml
161-
SDK_VERSION=$(grep "opentelemetry-sdk ==" aws-opentelemetry-distro/pyproject.toml | sed 's/.*== \([^,]*\).*/\1/' | tr -d '"')
162-
INSTRUMENTATION_VERSION=$(grep "opentelemetry-instrumentation ==" aws-opentelemetry-distro/pyproject.toml | sed 's/.*== \([^,]*\).*/\1/' | tr -d '"')
163-
164-
# Create release notes
165-
cat > release_notes.md << EOF
166-
This release contains updates of the following upstream components:
167-
168-
OpenTelemetry Python - $SDK_VERSION
169-
OpenTelemetry Python Contrib - $INSTRUMENTATION_VERSION
170-
171-
This release also publishes to public ECR and PyPi.
172-
* See ADOT Python auto-instrumentation Docker image v${{ github.event.inputs.version }} in our public ECR repository:
173-
https://gallery.ecr.aws/aws-observability/adot-autoinstrumentation-python
174-
* See version ${{ github.event.inputs.version }} in our PyPi repository:
175-
https://pypi.org/project/aws-opentelemetry-distro/
176-
EOF
177-
178-
gh release create --target "$GITHUB_REF_NAME" \
179-
--title "Release v${{ github.event.inputs.version }}" \
180-
--notes-file release_notes.md \
181-
--draft \
182-
"v${{ github.event.inputs.version }}" \
183-
dist/${{ env.ARTIFACT_NAME }} \
184-
${{ env.ARTIFACT_NAME }}.sha256
185-
build-layer:
186-
runs-on: ubuntu-latest
187-
needs: build
188-
outputs:
189-
aws_regions_json: ${{ steps.set-matrix.outputs.aws_regions_json }}
190-
steps:
191-
- name: Set up regions matrix
192-
id: set-matrix
193-
run: |
194-
IFS=',' read -ra REGIONS <<< "${{ github.event.inputs.aws_region }}"
195-
MATRIX="["
196-
for region in "${REGIONS[@]}"; do
197-
trimmed_region=$(echo "$region" | xargs)
198-
MATRIX+="\"$trimmed_region\","
199-
done
200-
MATRIX="${MATRIX%,}]"
201-
echo ${MATRIX}
202-
echo "aws_regions_json=${MATRIX}" >> $GITHUB_OUTPUT
203-
- name: Checkout Repo @ SHA - ${{ github.sha }}
204-
uses: actions/checkout@v4
205-
- uses: actions/setup-python@v5
206-
with:
207-
python-version: '3.x'
208-
- name: Build layers
209-
working-directory: lambda-layer/src
210-
run: |
211-
./build-lambda-layer.sh
212-
pip install tox
213-
tox
214-
- name: upload layer
215-
uses: actions/upload-artifact@v4
216-
with:
217-
name: layer.zip
218-
path: lambda-layer/src/build/aws-opentelemetry-python-layer.zip
201+
219202
publish-layer-prod:
220203
runs-on: ubuntu-latest
221-
needs: build-layer
204+
needs: [build-layer, publish-sdk]
222205
strategy:
223206
matrix:
224207
aws_region: ${{ fromJson(needs.build-layer.outputs.aws_regions_json) }}
@@ -299,9 +282,12 @@ jobs:
299282
if: always()
300283
run: |
301284
aws s3 rb --force s3://${{ env.BUCKET_NAME }}
285+
302286
generate-lambda-release-note:
303287
runs-on: ubuntu-latest
304288
needs: publish-layer-prod
289+
outputs:
290+
layer-note: ${{ steps.layer-note.outputs.layer-note }}
305291
steps:
306292
- name: Checkout Repo @ SHA - ${{ github.sha }}
307293
uses: actions/checkout@v4
@@ -320,6 +306,7 @@ jobs:
320306
cat $file
321307
done
322308
- name: generate layer-note
309+
id: layer-note
323310
working-directory: ${{ env.LAYER_NAME }}
324311
run: |
325312
echo "| Region | Layer ARN |" >> ../layer-note
@@ -329,7 +316,13 @@ jobs:
329316
read arn < $file
330317
echo "| " $file " | " $arn " |" >> ../layer-note
331318
done
332-
cat ../layer-note
319+
cd ..
320+
{
321+
echo "layer-note<<EOF"
322+
cat layer-note
323+
echo "EOF"
324+
} >> $GITHUB_OUTPUT
325+
cat layer-note
333326
- name: generate tf layer
334327
working-directory: ${{ env.LAYER_NAME }}
335328
run: |
@@ -355,47 +348,66 @@ jobs:
355348
done
356349
echo "}" >> ../layer_cdk
357350
cat ../layer_cdk
358-
- name: download layer.zip
351+
352+
publish-github:
353+
needs: generate-lambda-release-note
354+
runs-on: ubuntu-latest
355+
steps:
356+
- name: Checkout Repo @ SHA - ${{ github.sha }}
357+
uses: actions/checkout@v4
358+
359+
- name: Download SDK artifact
360+
uses: actions/download-artifact@v4
361+
with:
362+
name: ${{ env.ARTIFACT_NAME }}
363+
364+
- name: Download layer.zip artifact
359365
uses: actions/download-artifact@v4
360366
with:
361367
name: layer.zip
368+
362369
- name: Rename layer file
363370
run: |
364371
cp aws-opentelemetry-python-layer.zip layer.zip
365-
- name: Get commit hash
366-
id: commit
367-
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
368-
- name: Update GH release
372+
373+
# Publish to GitHub releases
374+
- name: Create GH release
375+
id: create_release
369376
env:
370377
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
371378
run: |
372-
TAG="v${{ github.event.inputs.version }}"
373-
# Generate SHA-256 checksum for layer.zip
379+
# Extract versions from pyproject.toml
380+
SDK_VERSION=$(grep "opentelemetry-sdk ==" aws-opentelemetry-distro/pyproject.toml | sed 's/.*== \([^,]*\).*/\1/' | tr -d '"')
381+
INSTRUMENTATION_VERSION=$(grep "opentelemetry-instrumentation ==" aws-opentelemetry-distro/pyproject.toml | sed 's/.*== \([^,]*\).*/\1/' | tr -d '"')
382+
383+
# Create release notes
384+
cat > release_notes.md << EOF
385+
This release contains updates of the following upstream components:
386+
387+
OpenTelemetry Python - $SDK_VERSION
388+
OpenTelemetry Python Contrib - $INSTRUMENTATION_VERSION
389+
390+
This release also publishes to public ECR and PyPi.
391+
* See ADOT Python auto-instrumentation Docker image v${{ github.event.inputs.version }} in our public ECR repository:
392+
https://gallery.ecr.aws/aws-observability/adot-autoinstrumentation-python
393+
* See version ${{ github.event.inputs.version }} in our PyPi repository:
394+
https://pypi.org/project/aws-opentelemetry-distro/
395+
396+
This release also includes the AWS OpenTelemetry Lambda Layer for Python version ${{ github.event.inputs.version }}-$(echo $GITHUB_SHA | cut -c1-7).
397+
398+
Lambda Layer ARNs:
399+
${{ needs.generate-lambda-release-note.outputs.layer-note }}
400+
EOF
401+
402+
shasum -a 256 ${{ env.ARTIFACT_NAME }} > ${{ env.ARTIFACT_NAME }}.sha256
374403
shasum -a 256 layer.zip > layer.zip.sha256
375-
gh release upload $TAG \
376-
layer.zip \
377-
layer.zip.sha256 \
378-
layer_arns.tf \
379-
--clobber
380-
- name: Update Release Notes
381-
env:
382-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
383-
run: |
384-
TAG="v${{ github.event.inputs.version }}"
385-
# Get current release notes
386-
current_notes=$(gh release view $TAG --json body -q .body)
387-
echo "This release also includes the AWS OpenTelemetry Lambda Layer for Python version ${{ github.event.inputs.version }}-${{ steps.commit.outputs.sha_short }}." >> lambda_notes.md
388-
echo "" >> lambda_notes.md
389-
echo "Lambda Layer ARNs:" >> lambda_notes.md
390-
echo "" >> lambda_notes.md
391-
cat layer-note >> lambda_notes.md
392-
echo "" >> lambda_notes.md
393-
echo "Notes:" >> lambda_notes.md
394-
{
395-
echo "$current_notes"
396-
echo ""
397-
cat lambda_notes.md
398-
} > updated_notes.md
399-
# Update release notes
400-
gh release edit $TAG --notes-file updated_notes.md
401404
405+
gh release create --target "$GITHUB_REF_NAME" \
406+
--title "Release v${{ github.event.inputs.version }}" \
407+
--notes-file release_notes.md \
408+
--draft \
409+
"v${{ github.event.inputs.version }}" \
410+
${{ env.ARTIFACT_NAME }} \
411+
${{ env.ARTIFACT_NAME }}.sha256 \
412+
layer.zip \
413+
layer.zip.sha256

0 commit comments

Comments
 (0)