Skip to content

Commit 7a8dac5

Browse files
committed
refactor: migrate to esm
BREAKING-CHANGE: the minimum supported version of semantic-release is now v20.
1 parent cea6a6b commit 7a8dac5

4 files changed

Lines changed: 6519 additions & 7283 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v5
1919
with:
2020
fetch-depth: 0
2121
- uses: volta-cli/action@v4
@@ -45,7 +45,7 @@ jobs:
4545
The release notes are:
4646
${{ needs.get-next-version.outputs.new-release-notes }}
4747
EOF
48-
- uses: actions/checkout@v3
48+
- uses: actions/checkout@v5
4949
with:
5050
fetch-depth: 0
5151
- uses: volta-cli/action@v4

index.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// @ts-check
22

3-
const { env } = require("node:process");
4-
const { appendFileSync } = require("node:fs");
5-
const { EOL } = require("node:os");
6-
const { randomUUID } = require("node:crypto");
3+
import process from "node:process";
4+
import { appendFile } from "node:fs/promises";
5+
import { EOL } from "node:os";
6+
import { randomUUID } from "node:crypto";
77

8-
function exportData(name, value, { log = true, escape = false } = {}) {
8+
async function exportData(name, value, { log = true, escape = false } = {}) {
99
if (log) {
1010
console.log(`semantic-release-export-data: ${name}=${value}`);
1111
}
12-
if (env.GITHUB_OUTPUT) {
12+
if (process.env.GITHUB_OUTPUT) {
1313
let output;
1414
if (escape) {
1515
// Borrowed from https://github.com/actions/toolkit/blob/ddc5fa4ae84a892bfa8431c353db3cf628f1235d/packages/core/src/file-command.ts#L27
@@ -18,22 +18,17 @@ function exportData(name, value, { log = true, escape = false } = {}) {
1818
} else {
1919
output = `${name}=${value}${EOL}`;
2020
}
21-
appendFileSync(env.GITHUB_OUTPUT, output);
21+
await appendFile(process.env.GITHUB_OUTPUT, output);
2222
}
2323
}
2424

25-
function verifyConditions() {
26-
exportData("new-release-published", "false");
25+
export async function verifyConditions() {
26+
await exportData("new-release-published", "false");
2727
}
2828

29-
function generateNotes(_pluginConfig, { nextRelease }) {
30-
exportData("new-release-published", "true");
31-
exportData("new-release-version", nextRelease.version);
32-
exportData("new-release-git-tag", nextRelease.gitTag);
33-
exportData("new-release-notes", nextRelease.notes, { log: false, escape: true });
29+
export async function generateNotes(_pluginConfig, { nextRelease }) {
30+
await exportData("new-release-published", "true");
31+
await exportData("new-release-version", nextRelease.version);
32+
await exportData("new-release-git-tag", nextRelease.gitTag);
33+
await exportData("new-release-notes", nextRelease.notes, { log: false, escape: true });
3434
}
35-
36-
module.exports = {
37-
verifyConditions,
38-
generateNotes,
39-
};

0 commit comments

Comments
 (0)