From 93226bf80f6d4e80336b2b538c9fbd42e1e4b4e3 Mon Sep 17 00:00:00 2001 From: Maxim Hayes Date: Thu, 13 Mar 2025 17:56:13 -0400 Subject: [PATCH] ci(changelog): escape changelog for notify, default entry when no changes - Escape the changelog string using `jq` before sending to the notify url. Otherwise, things like quotes might cause the payload to fail. - If there are no new changes to release, post a generic entry for tracking purposes - Informs that the version is uneventful, and clears up the special case of handling this for release. - Fixes things that use the changelog, like notify, prerelease, etc. Otherwise, it will use previous version changelog. --- buildspec/release/80notify.yml | 8 +++++--- packages/toolkit/CHANGELOG.md | 4 ++++ scripts/createRelease.ts | 18 +++++++++--------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/buildspec/release/80notify.yml b/buildspec/release/80notify.yml index 4471eb88304..062895d09d0 100644 --- a/buildspec/release/80notify.yml +++ b/buildspec/release/80notify.yml @@ -17,10 +17,12 @@ phases: - export EXTENSION_NAME=$([ "$TARGET_EXTENSION" = "amazonq" ] && echo "Amazon Q" || echo "AWS Toolkit") - export VERSION=$(node -e "console.log(require('./packages/${TARGET_EXTENSION}/package.json').version);") - export CHANGELOG=$(cat packages/${TARGET_EXTENSION}/CHANGELOG.md | perl -ne 'BEGIN{$/="\n\n"} print if $. == 2') - - MESSAGE=$(envsubst < ./buildspec/release/notify.txt) + - MESSAGE=$(envsubst < ./buildspec/release/notify.txt | jq -R -s '.') + - echo "Will post message - \n\n${MESSAGE}\n" + - echo "Full command - 'curl -v POST \"[NOTIFY_URL]\" -H \"Content-Type:application/json\" --data \"{\"Content\":${MESSAGE}}\"'" - | if [ "$STAGE" != "prod" ]; then - echo "SKIPPED (stage=${STAGE}): 'curl -v POST \"[NOTIFY_URL]\" -H \"Content-Type:application/json\" --data \"{\"Content\":\"${MESSAGE}\"}\"'" + echo "SKIPPED (stage=${STAGE}): curl -v POST ..." exit 0 fi - curl -v POST "${NOTIFY_URL}" -H "Content-Type:application/json" --data "{\"Content\":\"${MESSAGE}\"}" + curl -v POST "${NOTIFY_URL}" -H "Content-Type:application/json" --data "{\"Content\":${MESSAGE}}" diff --git a/packages/toolkit/CHANGELOG.md b/packages/toolkit/CHANGELOG.md index edd1becae49..1e9d54aa949 100644 --- a/packages/toolkit/CHANGELOG.md +++ b/packages/toolkit/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.50.0 2025-03-13 + +- Miscellaneous non-user-facing changes + ## 3.49.0 2025-03-06 - **Feature** Step Functions: Updated previewStateMachine command to open with Workflow Studio instead diff --git a/scripts/createRelease.ts b/scripts/createRelease.ts index 29b4fa82816..d6f39203fc1 100644 --- a/scripts/createRelease.ts +++ b/scripts/createRelease.ts @@ -21,10 +21,6 @@ const changesFile = path.join(changesDirectory, `${packageJson.version}.json`) nodefs.mkdirSync(nextReleaseDirectory, { recursive: true }) const changeFiles = nodefs.readdirSync(nextReleaseDirectory) -if (changeFiles.length === 0) { - console.warn('no changes to release (missing .changes/ directory)') - process.exit() -} try { nodefs.accessSync(changesFile) console.log(`error: changelog data file already exists: ${changesFile}`) @@ -45,21 +41,25 @@ for (const changeFile of changeFiles) { changelog.entries.push(file) } -changelog.entries.sort((x: { type: string }, y: { type: string }) => x.type.localeCompare(y.type)) - // Write changelog file nodefs.writeFileSync(changesFile, JSON.stringify(changelog, undefined, '\t')) const fileData = nodefs.readFileSync(path.join(cwd, 'CHANGELOG.md')) let append = `## ${packageJson.version} ${timestamp}\n\n` -for (const file of changelog.entries) { - append += `- **${file.type}** ${file.description}\n` +if (changelog.entries.length === 0) { + console.warn('no changes to release (missing .changes/ directory)') + append += '- Miscellaneous non-user-facing changes\n' +} else { + changelog.entries.sort((x: { type: string }, y: { type: string }) => x.type.localeCompare(y.type)) + for (const file of changelog.entries) { + append += `- **${file.type}** ${file.description}\n` + } } append += '\n' + fileData.toString() nodefs.writeFileSync('CHANGELOG.md', append) child_process.execSync(`git add ${changesDirectory}`) -child_process.execSync(`git rm -rf ${nextReleaseDirectory}`) +child_process.execSync(`git rm -rf --ignore-unmatch ${nextReleaseDirectory}`) child_process.execSync('git add CHANGELOG.md') console.log(changesFile)