From 843e80992e15bd5c47f64b448aa18994f37dd2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Cort=C3=B3n=20Cobas?= <104267232+carloscortonc@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:38:38 +0200 Subject: [PATCH 1/5] feat: update output delimiter & include `notes` if present --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4b3db4e..7b4ce2c 100644 --- a/index.js +++ b/index.js @@ -2,11 +2,15 @@ const { env } = require("node:process"); const { appendFileSync } = require("node:fs"); +const { EOL } = require("node:os"); +const { randomUUID } = require("node:crypto"); function exportData(name, value) { console.log(`semantic-release-export-data: ${name}=${value}`); if (env.GITHUB_OUTPUT) { - const output = `${name}=${value}\n`; + // Borrowed from https://github.com/actions/toolkit/blob/ddc5fa4ae84a892bfa8431c353db3cf628f1235d/packages/core/src/file-command.ts#L27 + const delimiter = "output_delimiter_".concat(randomUUID()); + const output = "".concat(name, "<<", delimiter, EOL, value, EOL, delimiter, EOL); appendFileSync(env.GITHUB_OUTPUT, output); } } @@ -19,6 +23,8 @@ function generateNotes(_pluginConfig, { nextRelease }) { exportData("new-release-published", "true"); exportData("new-release-version", nextRelease.version); exportData("new-release-git-tag", nextRelease.gitTag); + // Export notes if present + nextRelease.notes && exportData("new-release-release-notes", nextRelease.notes); } module.exports = { From 8793f4e168d86d400d322470cc42334a570b8771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Cort=C3=B3n=20Cobas?= <104267232+carloscortonc@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:51:25 +0200 Subject: [PATCH 2/5] chore: simplify output variable name --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7b4ce2c..626603e 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,7 @@ function generateNotes(_pluginConfig, { nextRelease }) { exportData("new-release-version", nextRelease.version); exportData("new-release-git-tag", nextRelease.gitTag); // Export notes if present - nextRelease.notes && exportData("new-release-release-notes", nextRelease.notes); + nextRelease.notes && exportData("new-release-notes", nextRelease.notes); } module.exports = { From caca4b22ac1a1055fff6ddba8e59b3bad471895e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Cort=C3=B3n=20Cobas?= <104267232+carloscortonc@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:55:32 +0200 Subject: [PATCH 3/5] docs: update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2dffaa0..dfe8b09 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Currently, the plugin exports the following GitHub Actions's outputs: | `new-release-published` | Whether a new release was published. The return value is in the form of a string. (`true` or `false`) | | `new-release-version` | If a new release was published, the version of the new release. (e.g. `1.3.0`) | | `new-release-git-tag` | If a new version was published, the git tag of the new release. (e.g. `v1.3.0`) | +| `new-release-notes` | If a new version was published, the generated notes (if present) | ### GitHub Actions Example From 2f3cc34d3816a93f56579e02c195f3b32b009dc5 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Sun, 5 Oct 2025 11:06:15 -0300 Subject: [PATCH 4/5] Avoid logging release notes and avoid escaping unnecessarily --- index.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 626603e..562f710 100644 --- a/index.js +++ b/index.js @@ -5,12 +5,19 @@ const { appendFileSync } = require("node:fs"); const { EOL } = require("node:os"); const { randomUUID } = require("node:crypto"); -function exportData(name, value) { - console.log(`semantic-release-export-data: ${name}=${value}`); +function exportData(name, value, { log = true, escape = false } = {}) { + if (log) { + console.log(`semantic-release-export-data: ${name}=${value}`); + } if (env.GITHUB_OUTPUT) { - // Borrowed from https://github.com/actions/toolkit/blob/ddc5fa4ae84a892bfa8431c353db3cf628f1235d/packages/core/src/file-command.ts#L27 - const delimiter = "output_delimiter_".concat(randomUUID()); - const output = "".concat(name, "<<", delimiter, EOL, value, EOL, delimiter, EOL); + let output; + if (escape) { + // Borrowed from https://github.com/actions/toolkit/blob/ddc5fa4ae84a892bfa8431c353db3cf628f1235d/packages/core/src/file-command.ts#L27 + const delimiter = "output_delimiter_".concat(randomUUID()); + output = `${name}<<${delimiter}${EOL}${value}${EOL}${delimiter}${EOL}`; + } else { + output = `${name}=${value}${EOL}`; + } appendFileSync(env.GITHUB_OUTPUT, output); } } @@ -23,8 +30,7 @@ function generateNotes(_pluginConfig, { nextRelease }) { exportData("new-release-published", "true"); exportData("new-release-version", nextRelease.version); exportData("new-release-git-tag", nextRelease.gitTag); - // Export notes if present - nextRelease.notes && exportData("new-release-notes", nextRelease.notes); + exportData("new-release-notes", nextRelease.notes, { log: false, escape: true }); } module.exports = { From 0f4dbf589e2dd2456256c7af702f01b8cf190541 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Sun, 5 Oct 2025 11:21:26 -0300 Subject: [PATCH 5/5] Print release notes in ci.yaml --- .github/workflows/ci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6388398..3217bd0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,6 +30,7 @@ jobs: new-release-published: ${{ steps.get-next-version.outputs.new-release-published }} new-release-version: ${{ steps.get-next-version.outputs.new-release-version }} new-release-git-tag: ${{ steps.get-next-version.outputs.new-release-git-tag }} + new-release-notes: ${{ steps.get-next-version.outputs.new-release-notes }} release: runs-on: ubuntu-latest @@ -39,6 +40,11 @@ jobs: steps: - run: echo "The new release version is ${{ needs.get-next-version.outputs.new-release-version }} with tag ${{ needs.get-next-version.outputs.new-release-git-tag }}" + - run: | + cat << 'EOF' + The release notes are: + ${{ needs.get-next-version.outputs.new-release-notes }} + EOF - uses: actions/checkout@v3 with: fetch-depth: 0