opencode-github-release 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nahom Amestsantim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # opencode-github-release
2
+
3
+ An [OpenCode](https://opencode.ai) plugin that creates git tags and publishes GitHub releases with semantic versioning.
4
+
5
+ [![npm](https://badgen.net/npm/v/opencode-github-release)](https://www.npmjs.com/package/opencode-github-release)
6
+ [![GitHub](https://badgen.net/github/stars/amestsantim/opencode-github-release)](https://github.com/amestsantim/opencode-github-release)
7
+ [![License: MIT](https://badgen.net/github/license/amestsantim/opencode-github-release)](https://opensource.org/licenses/MIT)
8
+
9
+ ## Installation
10
+
11
+ Add to your `opencode.json`:
12
+
13
+ ```json
14
+ {
15
+ "plugin": ["opencode-github-release"]
16
+ }
17
+ ```
18
+
19
+ Restart OpenCode. The plugin loads automatically.
20
+
21
+ ## Usage
22
+
23
+ Ask OpenCode to create a release. The plugin provides a `create_release` tool with these modes:
24
+
25
+ **Auto-bump from latest tag:**
26
+ ```
27
+ Create a patch release
28
+ Create a minor release
29
+ Create a major release
30
+ ```
31
+
32
+ **Explicit version:**
33
+ ```
34
+ Release version 2.0.0
35
+ ```
36
+
37
+ **With release notes:**
38
+ ```
39
+ Create a patch release with notes "Fixed login bug"
40
+ ```
41
+
42
+ ## Prerequisites
43
+
44
+ - [Git](https://git-scm.com/)
45
+ - [GitHub CLI](https://cli.github.com/) (`gh`) authenticated to your account
46
+ - The current directory must be a git repository with a remote named `origin`
47
+
48
+ ## Development
49
+
50
+ ```bash
51
+ npm install
52
+ npm run typecheck
53
+ npm run build
54
+ npm pack --dry-run
55
+ ```
56
+
57
+ ## License
58
+
59
+ MIT
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '@opencode-ai/plugin';
2
+
3
+ declare const plugin: Plugin;
4
+
5
+ export { plugin as default };
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ // src/index.ts
2
+ import { tool } from "@opencode-ai/plugin";
3
+ function bumpVersion(current, bump) {
4
+ const cleaned = current.replace(/^v/, "");
5
+ const match = cleaned.match(/^(\d+)\.(\d+)\.(\d+)/);
6
+ if (!match) throw new Error(`Cannot parse semver from "${current}"`);
7
+ let major = parseInt(match[1], 10);
8
+ let minor = parseInt(match[2], 10);
9
+ let patch = parseInt(match[3], 10);
10
+ if (bump === "major") {
11
+ major++;
12
+ minor = 0;
13
+ patch = 0;
14
+ }
15
+ if (bump === "minor") {
16
+ minor++;
17
+ patch = 0;
18
+ }
19
+ if (bump === "patch") {
20
+ patch++;
21
+ }
22
+ return `v${major}.${minor}.${patch}`;
23
+ }
24
+ var plugin = async ({ $ }) => {
25
+ return {
26
+ tool: {
27
+ create_release: tool({
28
+ description: 'Create a git tag and publish a GitHub release with semantic versioning. Provide either `bump` to auto-compute the next version from the latest tag, or an explicit `version` string (e.g. "2.0.0" or "v2.0.0").',
29
+ args: {
30
+ bump: tool.schema.enum(["patch", "minor", "major"]).optional(),
31
+ version: tool.schema.string().optional(),
32
+ notes: tool.schema.string().optional()
33
+ },
34
+ async execute(args, _context) {
35
+ const { bump, version, notes } = args;
36
+ if (!bump && !version) {
37
+ throw new Error("Provide either `bump` (patch/minor/major) or an explicit `version` string");
38
+ }
39
+ await $`git fetch --tags --force 2>/dev/null || true`;
40
+ const result = await $`git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"`;
41
+ const latestTag = result.stdout.toString().trim();
42
+ const newTag = version ? version.startsWith("v") ? version : `v${version}` : bumpVersion(latestTag, bump);
43
+ const message = notes || `Release ${newTag}`;
44
+ await $`git tag -a ${newTag} -m ${message}`;
45
+ await $`git push origin ${newTag}`;
46
+ if (notes) {
47
+ await $`gh release create ${newTag} --title ${newTag} --notes ${notes}`;
48
+ } else {
49
+ await $`gh release create ${newTag} --title ${newTag} --generate-notes`;
50
+ }
51
+ return `\u2713 Created and published ${newTag} (bumped from ${latestTag})`;
52
+ }
53
+ })
54
+ }
55
+ };
56
+ };
57
+ var index_default = plugin;
58
+ export {
59
+ index_default as default
60
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "opencode-github-release",
3
+ "version": "0.1.0",
4
+ "description": "OpenCode plugin to create git tags and publish GitHub releases with semantic versioning.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format esm --dts --clean",
21
+ "dev": "tsup src/index.ts --format esm --dts --watch",
22
+ "typecheck": "tsc --noEmit",
23
+ "check": "npm run typecheck && npm run build && npm pack --dry-run",
24
+ "prepublishOnly": "npm run check"
25
+ },
26
+ "keywords": [
27
+ "opencode",
28
+ "opencode-plugin",
29
+ "release",
30
+ "github"
31
+ ],
32
+ "license": "MIT",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "dependencies": {
37
+ "@opencode-ai/plugin": "^1.14.41"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^25.0.10",
41
+ "tsup": "^8.5.1",
42
+ "typescript": "^5.9.3"
43
+ }
44
+ }