Skip to content

Commit 04902fd

Browse files
committed
modify release lambda workflow to modify existing GH release
1 parent b17b631 commit 04902fd

File tree

1 file changed

+42
-28
lines changed

1 file changed

+42
-28
lines changed

.github/workflows/release-lambda.yml

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ permissions:
2121
contents: write
2222

2323
jobs:
24+
check-draft:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Check for release draft
28+
run: |
29+
TAG="v${{ github.event.inputs.version }}"
30+
# Check if draft release exists with this tag
31+
if ! gh release view $TAG --json isDraft -q .isDraft 2>/dev/null | grep -q true; then
32+
echo "No draft release found for tag $TAG. Did you first run the Release Build workflow?"
33+
exit 1
34+
fi
35+
echo "Found draft release for tag $TAG. Proceeding with Lambda layer release."
36+
env:
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2438
build-layer:
2539
environment: Release
2640
runs-on: ubuntu-latest
@@ -205,36 +219,36 @@ jobs:
205219
id: commit
206220
run: |
207221
echo "sha_short=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT
208-
209-
- name: Create Release Notes
210-
run: |
211-
echo "AWS OpenTelemetry Lambda Layer for JavaScript version ${{ github.event.inputs.version }}-${{ steps.commit.outputs.sha_short }}" > release_notes.md
212-
echo "" >> release_notes.md
213-
echo "Lambda Layer ARNs:" >> release_notes.md
214-
echo "" >> release_notes.md
215-
cat layer-note >> release_notes.md
216-
echo "" >> release_notes.md
217-
echo "Notes:" >> release_notes.md
218-
- name: Create GH release
222+
- name: Update GH release
219223
env:
220224
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
221225
run: |
222-
gh release create \
223-
--target "$GITHUB_REF_NAME" \
224-
--title "Release lambda-v${{ github.event.inputs.version }}-${{ steps.commit.outputs.sha_short }}" \
225-
--notes-file release_notes.md \
226-
--draft \
227-
"lambda-v${{ github.event.inputs.version }}-${{ steps.commit.outputs.sha_short }}" \
228-
layer_arns.tf layer.zip
229-
echo Removing release_notes.md ...
230-
rm -f release_notes.md
231-
- name: Upload layer.zip and SHA-256 checksum to SDK Release Notes (tagged with latest)
232-
env:
233-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
234-
run: |
235-
LATEST_SDK_VERSION=$(gh release list --repo "aws-observability/aws-otel-js-instrumentation" --json tagName,isLatest -q 'map(select(.isLatest==true)) | .[0].tagName')
226+
TAG="v${{ github.event.inputs.version }}"
236227
# Generate SHA-256 checksum for layer.zip
237228
shasum -a 256 layer.zip > layer.zip.sha256
238-
# Upload layer.zip and its checksum to the latest SDK release note
239-
gh release upload "$LATEST_SDK_VERSION" layer.zip layer.zip.sha256 --repo "aws-observability/aws-otel-js-instrumentation" --clobber
240-
echo "✅ layer.zip successfully uploaded to $LATEST_SDK_VERSION in the upstream repo!"
229+
gh release upload $TAG \
230+
layer.zip \
231+
layer.zip.sha256 \
232+
layer_arns.tf \
233+
--clobber
234+
- name: Update Release Notes
235+
run: |
236+
TAG="v${{ github.event.inputs.version }}"
237+
# Get current release notes
238+
current_notes=$(gh release view $TAG --json body -q .body)
239+
echo "## Lambda Layer" > lambda_notes.md
240+
echo "" >> lambda_notes.md
241+
echo "AWS OpenTelemetry Lambda Layer for JavaScript version ${{ github.event.inputs.version }}-${{ steps.commit.outputs.sha_short }}" > lambda_notes.md
242+
echo "" >> lambda_notes.md
243+
echo "Lambda Layer ARNs:" >> lambda_notes.md
244+
echo "" >> lambda_notes.md
245+
cat layer-note >> lambda_notes.md
246+
echo "" >> lambda_notes.md
247+
echo "Notes:" >> lambda_notes.md
248+
{
249+
echo "$current_notes"
250+
echo ""
251+
cat lambda_notes.md
252+
} > updated_notes.md
253+
# Update release notes
254+
gh release edit $TAG --notes-file updated_notes.md

0 commit comments

Comments
 (0)