opencode-github-release 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +24 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { tool } from "@opencode-ai/plugin";
|
|
3
3
|
function bumpVersion(current, bump) {
|
|
4
|
+
const prefix = current.startsWith("v") ? "v" : "";
|
|
4
5
|
const cleaned = current.replace(/^v/, "");
|
|
5
6
|
const match = cleaned.match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
6
7
|
if (!match) throw new Error(`Cannot parse semver from "${current}"`);
|
|
@@ -19,7 +20,7 @@ function bumpVersion(current, bump) {
|
|
|
19
20
|
if (bump === "patch") {
|
|
20
21
|
patch++;
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return `${prefix}${major}.${minor}.${patch}`;
|
|
23
24
|
}
|
|
24
25
|
function classifyCommit(subject) {
|
|
25
26
|
const breaking = /^BREAKING CHANGE:/im.test(subject) || /^\w+(\([^)]*\))?!:/m.test(subject);
|
|
@@ -104,7 +105,28 @@ var plugin = async ({ $ }) => {
|
|
|
104
105
|
await $`git fetch --tags --force 2>/dev/null || true`.quiet();
|
|
105
106
|
const tagResult = await $`git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"`.text();
|
|
106
107
|
const latestTag = tagResult.trim();
|
|
107
|
-
const
|
|
108
|
+
const repoUsesV = latestTag.startsWith("v");
|
|
109
|
+
const hasExistingTags = parseInt((await $`git tag -l 2>/dev/null | wc -l`.text()).trim(), 10) > 0;
|
|
110
|
+
let newTag;
|
|
111
|
+
if (version) {
|
|
112
|
+
const versionHasV = version.startsWith("v");
|
|
113
|
+
if (hasExistingTags && versionHasV !== repoUsesV) {
|
|
114
|
+
const suggestion = versionHasV ? version.replace(/^v/, "") : `v${version}`;
|
|
115
|
+
return {
|
|
116
|
+
title: "Version prefix mismatch",
|
|
117
|
+
output: [
|
|
118
|
+
`Existing releases use ${repoUsesV ? 'the "v" prefix' : 'no "v" prefix'} (e.g. "${latestTag}"),`,
|
|
119
|
+
`but you provided "${version}" which ${versionHasV ? "has" : "does not have"} a "v" prefix.`,
|
|
120
|
+
"",
|
|
121
|
+
`Would you like to use "${suggestion}" instead?`,
|
|
122
|
+
"If so, call create_release again with the corrected version."
|
|
123
|
+
].join("\n")
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
newTag = version;
|
|
127
|
+
} else {
|
|
128
|
+
newTag = bumpVersion(latestTag, bump);
|
|
129
|
+
}
|
|
108
130
|
const branch = (await $`git rev-parse --abbrev-ref HEAD`.text()).trim();
|
|
109
131
|
let unpushedBefore = [];
|
|
110
132
|
if (branch !== "HEAD") {
|