Skip to content

Commit 32f0426

Browse files
committed
Fix formatting of generated release notes
The "Arduino IDE" GitHub Actions workflow generates a changelog from the commits since the last tag. This changelog is published in multiple ways: - Printed to workflow run logs - Uploaded to Arduino's download server (mostly useful for the nightly builds) - Initial version of release notes For the last, the changelog text must be passed from the dedicated changelog generation workflow step to the release step. This is done via workflow job output. At the time the system was set up, outputs for workflow `run` steps were set using the `set-output` workflow command. That "workflow command" system was later determined by GitHub to have potential security vulnerabilities, so it was replaced with a `GITHUB_OUTPUT` environment file. The "Arduino IDE" workflow was migrated to the new "environment file" approach. It was later discovered that there was an undocumented breaking change in the method for handling multi-line strings in workflow step outputs between the old "workflow command" system and the new "environment file". This resulted in the initial release notes having an incorrect format. For example, what would previously have been formatted like this: - Updated translation files (#1606) [23c7f5f] - Use 0.29.0 CLI in IDE2 (#1683) [f1144ef] Was now formatted like this: - Updated translation files (#1606) [23c7f5f]%0A - Use 0.29.0 CLI in IDE2 (#1683) [f1144ef]%0A The solution is to remove the commands that did the escaping of the changelog text in a manner that is no longer supported and replace them with a "here document"-style format. A random number is used as the "delimiter" (limit string) per the security recommendations in the official GitHub documentation. Note that even though the multiline strings handling documentation was placed under the environment variable section, it also applies to setting outputs.
1 parent 200c002 commit 32f0426

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: .github/workflows/build.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,14 @@ jobs:
180180
fi
181181
fi
182182
echo -e "$BODY"
183-
OUTPUT_SAFE_BODY="${BODY//'%'/'%25'}"
184-
OUTPUT_SAFE_BODY="${OUTPUT_SAFE_BODY//$'\n'/'%0A'}"
185-
OUTPUT_SAFE_BODY="${OUTPUT_SAFE_BODY//$'\r'/'%0D'}"
186-
echo "BODY=$OUTPUT_SAFE_BODY" >> $GITHUB_OUTPUT
183+
184+
# Set workflow step output
185+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
186+
DELIMITER="$RANDOM"
187+
echo "BODY<<$DELIMITER" >> $GITHUB_OUTPUT
188+
echo "$BODY" >> $GITHUB_OUTPUT
189+
echo "$DELIMITER" >> $GITHUB_OUTPUT
190+
187191
echo "$BODY" > CHANGELOG.txt
188192
189193
- name: Upload Changelog [GitHub Actions]

0 commit comments

Comments
 (0)