opencode-github-release 0.4.0 → 0.4.1

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.
Files changed (3) hide show
  1. package/README.md +15 -1
  2. package/dist/index.js +30 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -44,13 +44,25 @@ Create a patch release with notes "Fixed login bug"
44
44
  Create a release
45
45
  ```
46
46
 
47
+ **Suggest a bump (without releasing):**
48
+ ```
49
+ What version should I use?
50
+ ```
51
+
52
+ **Override dirty tree check:**
53
+ ```
54
+ Create a major release with force: true
55
+ ```
56
+
47
57
  ## How it works
48
58
 
49
59
  When you request a release, the plugin fetches the latest git tag from the repository and computes the next version from it. If you specify a bump (`patch`/`minor`/`major`) or an explicit version, it creates the tag and release immediately. If you don't specify either (e.g., just "create a release"), the plugin instead runs `suggest_bump` — it analyzes commits since the latest tag using conventional commit conventions: `fix` → patch, `feat` → minor, `BREAKING CHANGE` → major — and presents the suggestion for your confirmation before proceeding.
50
60
 
51
61
  If you don't provide release notes, the plugin automatically generates them from the commit history via `gh release create --generate-notes`.
52
62
 
53
- `create_release` expects conventional commit messages (`feat:`, `fix:`, `BREAKING CHANGE:`) for accurate auto-suggestion. Commits that follow this convention are classified as:
63
+ `create_release` checks for uncommitted changes before proceeding. If the working tree is dirty, it returns a warning and asks you to commit, stash, or pass `force: true`.
64
+
65
+ It expects conventional commit messages (`feat:`, `fix:`, `BREAKING CHANGE:`) for accurate auto-suggestion. Commits that follow this convention are classified as:
54
66
 
55
67
  - `fix:` → patch bump
56
68
  - `feat:` → minor bump
@@ -69,6 +81,8 @@ Commits: 3
69
81
  Suggested bump: major -> v1.0.0
70
82
  ```
71
83
 
84
+ You can invoke `suggest_bump` directly at any time ("Suggest a bump") — it analyzes commits since the latest tag and recommends a bump without creating anything.
85
+
72
86
  ## Prerequisites
73
87
 
74
88
  - [Git](https://git-scm.com/)
package/dist/index.js CHANGED
@@ -106,11 +106,14 @@ var plugin = async ({ $ }) => {
106
106
  const latestTag = tagResult.trim();
107
107
  const newTag = version ? version.startsWith("v") ? version : `v${version}` : bumpVersion(latestTag, bump);
108
108
  const branch = (await $`git rev-parse --abbrev-ref HEAD`.text()).trim();
109
- let unpushedInfo = "";
109
+ let unpushedBefore = [];
110
110
  if (branch !== "HEAD") {
111
- const unpushed = (await $`git log origin/${branch}..HEAD --oneline 2>/dev/null || true`.text()).trim();
112
- if (unpushed) {
113
- unpushedInfo = `${unpushed.split("\n").length} unpushed commit(s) will be included in this release.`;
111
+ const before = (await $`git log origin/${branch}..HEAD --oneline 2>/dev/null || true`.text()).trim();
112
+ if (before) {
113
+ unpushedBefore = before.split("\n").map((line) => {
114
+ const hash = line.split(/\s+/)[0];
115
+ return { hash, subject: line.slice(hash.length).trim() };
116
+ });
114
117
  }
115
118
  }
116
119
  const hasPkg = (await $`test -f package.json && echo "yes" || echo "no"`.text()).trim() === "yes";
@@ -119,9 +122,9 @@ var plugin = async ({ $ }) => {
119
122
  await $`npm version ${bareVersion} --no-git-tag-version`.quiet();
120
123
  await $`git add package.json package-lock.json 2>/dev/null || true`.quiet();
121
124
  await $`git commit -m ${`chore(release): bump version to ${newTag}`}`.quiet();
122
- if (branch !== "HEAD") {
123
- await $`git push origin ${branch}`.quiet();
124
- }
125
+ }
126
+ if (branch !== "HEAD") {
127
+ await $`git push origin ${branch}`.quiet();
125
128
  }
126
129
  const message = notes || `Release ${newTag}`;
127
130
  await $`git tag -a ${newTag} -m ${message}`.quiet();
@@ -132,8 +135,26 @@ var plugin = async ({ $ }) => {
132
135
  await $`gh release create ${newTag} --title ${newTag} --generate-notes`.quiet();
133
136
  }
134
137
  let result = `Created and published ${newTag} (bumped from ${latestTag})`;
135
- if (unpushedInfo) result += `
136
- ${unpushedInfo}`;
138
+ if (branch !== "HEAD" && unpushedBefore.length > 0) {
139
+ const remaining = (await $`git log origin/${branch}..HEAD --oneline 2>/dev/null || true`.text()).trim();
140
+ const remainingCount = remaining ? remaining.split("\n").length : 0;
141
+ const pushedCount = unpushedBefore.length - remainingCount;
142
+ if (pushedCount > 0) {
143
+ const plural = pushedCount === 1 ? "" : "s";
144
+ result += `
145
+ Pushed ${pushedCount} commit${plural} to ${branch}:`;
146
+ for (let i = 0; i < pushedCount; i++) {
147
+ result += `
148
+ ${unpushedBefore[i].hash} ${unpushedBefore[i].subject}`;
149
+ }
150
+ }
151
+ if (remainingCount > 0) {
152
+ const plural = remainingCount === 1 ? "" : "s";
153
+ const verb = remainingCount === 1 ? "is" : "are";
154
+ result += `
155
+ Note: ${remainingCount} commit${plural} in this release ${verb} not yet pushed to origin/${branch}.`;
156
+ }
157
+ }
137
158
  return { title: newTag, output: result };
138
159
  }
139
160
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-github-release",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "OpenCode plugin to create git tags and publish GitHub releases with semantic versioning.",
5
5
  "repository": {
6
6
  "type": "git",