Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 15 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@

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}`);
function exportData(name, value, { log = true, escape = false } = {}) {
if (log) {
console.log(`semantic-release-export-data: ${name}=${value}`);
}
if (env.GITHUB_OUTPUT) {
const output = `${name}=${value}\n`;
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);
}
}
Expand All @@ -19,6 +30,7 @@ function generateNotes(_pluginConfig, { nextRelease }) {
exportData("new-release-published", "true");
exportData("new-release-version", nextRelease.version);
exportData("new-release-git-tag", nextRelease.gitTag);
exportData("new-release-notes", nextRelease.notes, { log: false, escape: true });
}

module.exports = {
Expand Down