Skip to content

Commit d355fde

Browse files
chore(ci): add new script to bump Lambda layer version (#6001)
* Adding new script to bump layer version * Adding new script to bump layer version * Making changes to work with GNU sed
1 parent 196529b commit d355fde

File tree

3 files changed

+62
-21
lines changed

3 files changed

+62
-21
lines changed

.github/workflows/publish_v3_layer.yml

+19-21
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ on:
3333
latest_published_version:
3434
description: "Latest PyPi published version to rebuild latest docs for, e.g. 3.0.0, 3.0.0a1 (pre-release)"
3535
required: true
36+
layer_documentation_version:
37+
description: "Version to be updated in our documentation. e.g. if the current layer number is 3, this value must be 4."
38+
required: true
3639
source_code_artifact_name:
3740
description: "Artifact name to restore sealed source code"
3841
type: string
@@ -52,6 +55,10 @@ on:
5255
type: string
5356
description: "Latest PyPi published version to rebuild latest docs for, e.g. 3.0.0, 3.0.0a1 (pre-release)"
5457
required: true
58+
layer_documentation_version:
59+
type: string
60+
description: "Version to be updated in our documentation. e.g. if the current layer number is 3, this value must be 4."
61+
required: true
5562
pre_release:
5663
description: "Publishes documentation using a pre-release tag (3.0.0a1)."
5764
default: false
@@ -257,29 +264,20 @@ jobs:
257264
integrity_hash: ${{ inputs.source_code_integrity_hash }}
258265
artifact_name: ${{ inputs.source_code_artifact_name }}
259266

260-
# UNCOMMENT THIS
261-
# - name: Download CDK layer artifacts
262-
# uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
263-
# with:
264-
# path: cdk-layer-stack
265-
# pattern: cdk-layer-stack-* # merge all Layer artifacts created per region earlier (reusable_deploy_v2_layer_stack.yml; step "Save Layer ARN artifact")
266-
# merge-multiple: true
267-
# - name: Replace layer versions in documentation
268-
# run: |
269-
# ls -la cdk-layer-stack/
270-
# ./layer_v3/scripts/update_layer_arn.sh cdk-layer-stack
267+
- name: Replace layer versions in documentation
268+
run: ./layer_v3/scripts/update_layer_arn_v3.sh ${{ inputs.layer_documentation_version }}
271269
# NOTE: It felt unnecessary creating yet another PR to update changelog w/ latest tag
272270
# since this is the only step in the release where we update docs from a temp branch
273-
# - name: Update changelog with latest tag
274-
# run: make changelog
275-
# - name: Create PR
276-
# id: create-pr
277-
# uses: ./.github/actions/create-pr
278-
# with:
279-
# files: "docs/index.md examples CHANGELOG.md"
280-
# temp_branch_prefix: "ci-layer-docs"
281-
# pull_request_title: "chore(ci): layer docs update"
282-
# github_token: ${{ secrets.GITHUB_TOKEN }}
271+
- name: Update changelog with latest tag
272+
run: make changelog
273+
- name: Create PR
274+
id: create-pr
275+
uses: ./.github/actions/create-pr
276+
with:
277+
files: "docs/index.md docs/includes/_layer_homepage_arm64.md docs/includes/_layer_homepage_x86.md examples CHANGELOG.md"
278+
temp_branch_prefix: "ci-layer-docs"
279+
pull_request_title: "chore(ci): layer docs update"
280+
github_token: ${{ secrets.GITHUB_TOKEN }}
283281

284282
prepare_docs_alias:
285283
runs-on: ubuntu-latest

.github/workflows/release-v3.yml

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ on:
3939
description: "Version to be released in PyPi, Docs, and Lambda Layer, e.g. v3.0.0, v3.0.0a0 (pre-release)"
4040
default: v3.0.0
4141
required: true
42+
layer_documentation_version:
43+
description: "Lambda layer version to be updated in our documentation. e.g. if the current layer number is 3, this value must be 4."
44+
type: string
45+
required: true
4246
skip_pypi:
4347
description: "Skip publishing to PyPi as it can't publish more than once. Useful for semi-failed releases"
4448
default: false
@@ -342,6 +346,7 @@ jobs:
342346
uses: ./.github/workflows/publish_v3_layer.yml
343347
with:
344348
latest_published_version: ${{ needs.seal.outputs.RELEASE_VERSION }}
349+
layer_documentation_version: ${{ inputs.layer_documentation_version }}
345350
pre_release: ${{ inputs.pre_release }}
346351
source_code_artifact_name: ${{ needs.seal.outputs.artifact_name }}
347352
source_code_integrity_hash: ${{ needs.seal.outputs.integrity_hash }}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# This script is run during the publish_v3_layer.yml CI job,
4+
# and it is responsible for replacing the layer ARN in our documentation.
5+
# Our pipeline must generate the same layer number for all commercial regions + gov cloud
6+
# If this doesn't happens, we have an error and we must fix it in the deployment.
7+
#
8+
# see .github/workflows/reusable_deploy_v3_layer_stack.yml
9+
10+
11+
# Get the new version number from the first command-line argument
12+
new_version=$1
13+
if [ -z "$new_version" ]; then
14+
echo "Usage: $0 <new_version>"
15+
exit 1
16+
fi
17+
18+
# Find all files with specified extensions in ./docs and ./examples directories
19+
# -type f: only find files (not directories)
20+
# \( ... \): group conditions
21+
# -o: logical OR
22+
# -print0: use null character as separator (handles filenames with spaces)
23+
find ./docs ./examples -type f \( -name "*.md" -o -name "*.py" -o -name "*.yaml" -o -name "*.txt" -o -name "*.tf" -o -name "*.yml" \) -print0 | while IFS= read -r -d '' file; do
24+
echo "Processing file: $file"
25+
26+
# Use sed to replace the version number in the Lambda layer ARN
27+
# -i: edit files in-place without creating a backup
28+
# -E: use extended regular expressions
29+
# The regex matches the layer name and replaces only the version number at the end
30+
sed -i -E "s/(AWSLambdaPowertoolsPythonV3-python[0-9]+-((arm64)|(x86_64)):)[0-9]+/\1$new_version/g" "$file"
31+
if [ $? -eq 0 ]; then
32+
echo "Updated $file successfully"
33+
grep "arn:aws:lambda:" "$file"
34+
else
35+
echo "Error processing $file"
36+
fi
37+
done
38+
echo "Layer version update attempt completed."

0 commit comments

Comments
 (0)