Skip to content

Commit 2e616d2

Browse files
chore(release): enhance semantic-release configuration to update pubspec.yaml version
1 parent 40e650d commit 2e616d2

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

release.config.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,32 @@ module.exports = {
44
"@semantic-release/commit-analyzer", // Detects the release type (major, minor, patch)
55
"@semantic-release/release-notes-generator", // Generates release notes
66
"@semantic-release/changelog", // Updates CHANGELOG.md
7+
[
8+
{
9+
// Hook to update pubspec.yaml
10+
prepare: (pluginConfig, context) => {
11+
const version = context.nextRelease.version;
12+
const filePath = "pubspec.yaml";
13+
14+
let pubspec = fs.readFileSync(filePath, "utf8");
15+
pubspec = pubspec.replace(/^version: .*/m, `version: ${version}`);
16+
fs.writeFileSync(filePath, pubspec);
17+
18+
context.logger.log(
19+
`✅ pubspec.yaml actualizado a version: ${version}`
20+
);
21+
},
22+
},
23+
],
24+
[
25+
"@semantic-release/git", // Commits CHANGELOG and bumps version if needed
26+
{
27+
assets: ["CHANGELOG.md", "pubspec.yaml"],
28+
message:
29+
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
30+
},
31+
],
732
"@semantic-release/github", // Publishes to GitHub Releases
8-
"@semantic-release/git", // Commits CHANGELOG and bumps version if needed
933
],
1034
changelogFile: "CHANGELOG.md",
1135
preset: "conventionalcommits",

0 commit comments

Comments
 (0)