Skip to content

Commit 62ab04f

Browse files
authored
ci(changelog): escape changelog for notify, default entry when no changes (aws#6784)
- 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. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 43b0bd1 commit 62ab04f

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

buildspec/release/80notify.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ phases:
1717
- export EXTENSION_NAME=$([ "$TARGET_EXTENSION" = "amazonq" ] && echo "Amazon Q" || echo "AWS Toolkit")
1818
- export VERSION=$(node -e "console.log(require('./packages/${TARGET_EXTENSION}/package.json').version);")
1919
- export CHANGELOG=$(cat packages/${TARGET_EXTENSION}/CHANGELOG.md | perl -ne 'BEGIN{$/="\n\n"} print if $. == 2')
20-
- MESSAGE=$(envsubst < ./buildspec/release/notify.txt)
20+
- MESSAGE=$(envsubst < ./buildspec/release/notify.txt | jq -R -s '.')
21+
- echo "Will post message - \n\n${MESSAGE}\n"
22+
- echo "Full command - 'curl -v POST \"[NOTIFY_URL]\" -H \"Content-Type:application/json\" --data \"{\"Content\":${MESSAGE}}\"'"
2123
- |
2224
if [ "$STAGE" != "prod" ]; then
23-
echo "SKIPPED (stage=${STAGE}): 'curl -v POST \"[NOTIFY_URL]\" -H \"Content-Type:application/json\" --data \"{\"Content\":\"${MESSAGE}\"}\"'"
25+
echo "SKIPPED (stage=${STAGE}): curl -v POST ..."
2426
exit 0
2527
fi
26-
curl -v POST "${NOTIFY_URL}" -H "Content-Type:application/json" --data "{\"Content\":\"${MESSAGE}\"}"
28+
curl -v POST "${NOTIFY_URL}" -H "Content-Type:application/json" --data "{\"Content\":${MESSAGE}}"

packages/toolkit/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.50.0 2025-03-13
2+
3+
- Miscellaneous non-user-facing changes
4+
15
## 3.49.0 2025-03-06
26

37
- **Feature** Step Functions: Updated previewStateMachine command to open with Workflow Studio instead

scripts/createRelease.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ const changesFile = path.join(changesDirectory, `${packageJson.version}.json`)
2121
nodefs.mkdirSync(nextReleaseDirectory, { recursive: true })
2222

2323
const changeFiles = nodefs.readdirSync(nextReleaseDirectory)
24-
if (changeFiles.length === 0) {
25-
console.warn('no changes to release (missing .changes/ directory)')
26-
process.exit()
27-
}
2824
try {
2925
nodefs.accessSync(changesFile)
3026
console.log(`error: changelog data file already exists: ${changesFile}`)
@@ -45,21 +41,25 @@ for (const changeFile of changeFiles) {
4541
changelog.entries.push(file)
4642
}
4743

48-
changelog.entries.sort((x: { type: string }, y: { type: string }) => x.type.localeCompare(y.type))
49-
5044
// Write changelog file
5145
nodefs.writeFileSync(changesFile, JSON.stringify(changelog, undefined, '\t'))
5246
const fileData = nodefs.readFileSync(path.join(cwd, 'CHANGELOG.md'))
5347
let append = `## ${packageJson.version} ${timestamp}\n\n`
54-
for (const file of changelog.entries) {
55-
append += `- **${file.type}** ${file.description}\n`
48+
if (changelog.entries.length === 0) {
49+
console.warn('no changes to release (missing .changes/ directory)')
50+
append += '- Miscellaneous non-user-facing changes\n'
51+
} else {
52+
changelog.entries.sort((x: { type: string }, y: { type: string }) => x.type.localeCompare(y.type))
53+
for (const file of changelog.entries) {
54+
append += `- **${file.type}** ${file.description}\n`
55+
}
5656
}
5757

5858
append += '\n' + fileData.toString()
5959
nodefs.writeFileSync('CHANGELOG.md', append)
6060

6161
child_process.execSync(`git add ${changesDirectory}`)
62-
child_process.execSync(`git rm -rf ${nextReleaseDirectory}`)
62+
child_process.execSync(`git rm -rf --ignore-unmatch ${nextReleaseDirectory}`)
6363
child_process.execSync('git add CHANGELOG.md')
6464

6565
console.log(changesFile)

0 commit comments

Comments
 (0)