Skip to content

Commit 8028978

Browse files
sdangoldreamorosi
andauthored
improv(ci): Automate the layer version tracking during the Make Release workflow (#4355)
Co-authored-by: Andrea Amorosi <dreamorosi@gmail.com>
1 parent f19cfc6 commit 8028978

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

.github/scripts/update_layer_arn.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
# see .github/workflows/publish_layer.yml
99

1010

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>"
11+
# Get the new layer arn from the first command-line argument
12+
new_layer_arn=$1
13+
if [ -z "$new_layer_arn" ]; then
14+
echo "Usage: $0 <new_layer_arn>"
1515
exit 1
1616
fi
17+
new_version=$(echo $new_layer_arn | sed 's/.*://')
1718

1819
# Find all files with specified extensions in ./docs and ./examples directories
1920
# -type f: only find files (not directories)

.github/workflows/make-release.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ name: Make Release
1717
# 4. Merge the PR created by the `publish_layer` workflow to update the documentation
1818
# 5. Update draft release notes with the latest changes and publish the release on GitHub
1919

20-
on:
21-
workflow_dispatch:
22-
inputs:
23-
layer_documentation_version:
24-
description: "Lambda layer version to be updated in our documentation. e.g. if the current layer number is 3, this value must be 4."
25-
type: string
26-
required: true
20+
on: workflow_dispatch
2721

2822
permissions:
2923
contents: read
@@ -105,5 +99,4 @@ jobs:
10599
pull-requests: write
106100
uses: ./.github/workflows/publish_layer.yml
107101
with:
108-
latest_published_version: ${{ needs.publish-npm.outputs.RELEASE_VERSION }}
109-
layer_documentation_version: ${{ inputs.layer_documentation_version }}
102+
latest_published_version: ${{ needs.publish-npm.outputs.RELEASE_VERSION }}

.github/workflows/publish_layer.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ on:
1111
description: "Latest npm published version to rebuild corresponding layer for, e.g. 1.0.2"
1212
default: "1.0.2"
1313
required: true
14-
layer_documentation_version:
15-
description: "Version to be updated in our documentation. e.g. if the current layer number is 3, this value must be 4."
16-
required: true
1714

1815
workflow_call:
1916
inputs:
@@ -26,10 +23,6 @@ on:
2623
default: false
2724
type: boolean
2825
required: false
29-
layer_documentation_version:
30-
description: "Version to be updated in our documentation. e.g. if the current layer number is 3, this value must be 4."
31-
required: true
32-
type: string
3326

3427
jobs:
3528
# Build layer by running cdk synth in layer-publisher directory and uploading cdk.out for deployment
@@ -105,7 +98,7 @@ jobs:
10598
ref: ${{ github.sha }}
10699
- name: Replace layer versions in documentation
107100
run: |
108-
./.github/scripts/update_layer_arn.sh ${{ inputs.layer_documentation_version }}
101+
./.github/scripts/update_layer_arn.sh ${{ needs.deploy-prod.outputs.layer-arn }}
109102
- name: Stage changes
110103
run: git add .
111104
- name: Create PR

.github/workflows/reusable_deploy_layer_stack.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
description: "Latest version that is published"
1616
required: true
1717
type: string
18+
outputs:
19+
layer-arn:
20+
description: "The latest deployed Layer ARN"
21+
value: ${{ jobs.deploy-cdk-stack.outputs.layer-arn }}
1822
secrets:
1923
target-account-role:
2024
required: true
@@ -65,6 +69,8 @@ jobs:
6569
"il-central-1",
6670
"mx-central-1"
6771
]
72+
outputs:
73+
layer-arn: ${{ steps.store-latest-layer-arn.outputs.layer-arn }}
6874
steps:
6975
- name: checkout
7076
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -89,11 +95,16 @@ jobs:
8995
- name: Deploy Layer
9096
run: npm run cdk -w layers -- deploy --app cdk.out --context region=${{ matrix.region }} 'LayerPublisherStack' --require-approval never --verbose --outputs-file cdk-outputs.json
9197
- name: Store latest Layer ARN
98+
id: store-latest-layer-arn
9299
if: ${{ inputs.stage == 'PROD' }}
93100
run: |
94101
mkdir cdk-layer-stack
95102
jq -r -c '.LayerPublisherStack.LatestLayerArn' layers/cdk-outputs.json > cdk-layer-stack/${{ matrix.region }}-layer-version.txt
96-
cat cdk-layer-stack/${{ matrix.region }}-layer-version.txt
103+
if [ "${{ matrix.region }}" = "us-east-1" ]; then
104+
echo "layer-arn=$(cat cdk-layer-stack/${{ matrix.region }}-layer-version.txt)" | tee -a "$GITHUB_OUTPUT"
105+
else
106+
cat cdk-layer-stack/${{ matrix.region }}-layer-version.txt
107+
fi
97108
- name: Save Layer ARN artifact
98109
if: ${{ inputs.stage == 'PROD' }}
99110
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

0 commit comments

Comments
 (0)