Skip to content
Merged
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
63 changes: 30 additions & 33 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { existsSync } = require("node:fs");
const { existsSync, readFileSync } = require("node:fs");
const { execSync } = require('node:child_process');
const log = require("npmlog");

Expand Down Expand Up @@ -131,44 +131,41 @@ if (pkgExists && SR_DISABLE_NPM === undefined) {
});
}

const hasVersionLine = (file, pattern) =>
(readFileSync(file, "utf8").match(new RegExp(pattern, "gm")) || []).length === 1;

const denoExists = existsSync("./deno.json");
if (denoExists && SR_DISABLE_DENO === undefined) {
addPlugin("semantic-release-replace-plugin", {
"replacements": [{
"files": [
"deno.json"
],
"from": `"version":.*".*"`,
"to": `"version": "\${nextRelease.version}"`,
"results": [{
"file": "deno.json",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}],
"countMatches": true
}]
});
if (!hasVersionLine("deno.json", `"version":.*".*"`)) {
log.warn(`deno.json has no single "version" line, so its version is not updated`);
} else {
addPlugin("semantic-release-replace-plugin", {
"replacements": [{
"files": [
"deno.json"
],
"from": `"version":.*".*"`,
"to": `"version": "\${nextRelease.version}"`
}]
});
}
}

const pythonExists = existsSync("./pyproject.toml");
if (pythonExists && SR_DISABLE_PYTHON === undefined) {
addPlugin("semantic-release-replace-plugin", {
"replacements": [{
"files": [
"pyproject.toml"
],
"from": `^version.*=.*".*"$`,
"to": `version = "\${nextRelease.version}"`,
"results": [{
"file": "pyproject.toml",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}],
"countMatches": true
}]
});
if (!hasVersionLine("pyproject.toml", `^version.*=.*".*"$`)) {
log.warn(`pyproject.toml has no single version line, so its version is not updated`);
} else {
addPlugin("semantic-release-replace-plugin", {
"replacements": [{
"files": [
"pyproject.toml"
],
"from": `^version.*=.*".*"$`,
"to": `version = "\${nextRelease.version}"`
}]
});
}

const uvLockExists = existsSync("./uv.lock");
if (uvLockExists) {
Expand Down
Loading