GeezerVison is showing github.com — ci: stuff · thorstone137/opencode@0c022ef
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/publish.yml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 58 | 58 | ./script/publish.ts | 59 | 59 | env: | 60 | 60 | OPENCODE_BUMP: ${{ inputs.bump }} | | 61 | + OPENCODE_TAG: latest | 61 | 62 | GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }} | 62 | 63 | AUR_KEY: ${{ secrets.AUR_KEY }} | 63 | 64 | NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/snapshot.yml -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 30 | 30 | run: | | 31 | 31 | ./packages/opencode/script/publish.ts | 32 | 32 | env: | 33 | | - OPENCODE_SNAPSHOT: true | 34 | | - OPENCODE_TAG: ${{ github.ref_name }} | 35 | 33 | GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }} | 36 | 34 | NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} |
Collapse file Copy file name to clipboardExpand all lines: bun.lock +10Lines changed: 10 additions & 0 deletions Collapse file Copy file name to clipboardExpand all lines: package.json +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 48 | 48 | "turbo": "2.5.6" | 49 | 49 | }, | 50 | 50 | "dependencies": { | 51 | | - "@opencode-ai/sdk": "workspace:*" | | 51 | + "@opencode-ai/sdk": "workspace:*", | | 52 | + "@opencode-ai/script": "workspace:*" | 52 | 53 | }, | 53 | 54 | "repository": { | 54 | 55 | "type": "git", | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/package.json +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 28 | 28 | "@types/yargs": "17.0.33", | 29 | 29 | "typescript": "catalog:", | 30 | 30 | "vscode-languageserver-types": "3.17.5", | 31 | | - "zod-to-json-schema": "3.24.5" | | 31 | + "zod-to-json-schema": "3.24.5", | | 32 | + "@opencode-ai/script": "workspace:*" | 32 | 33 | }, | 33 | 34 | "dependencies": { | 34 | 35 | "@clack/prompts": "1.0.0-alpha.1", | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/script/build.ts +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,7 @@ process.chdir(dir) | 5 | 5 | import { $ } from "bun" | 6 | 6 |
| 7 | 7 | import pkg from "../package.json" | | 8 | +import { Script } from "@opencode-ai/script" | 8 | 9 |
| 9 | 10 | const GOARCH: Record<string, string> = { | 10 | 11 | arm64: "arm64", | @@ -25,12 +26,11 @@ const targets = [ | 25 | 26 | await $`rm -rf dist` | 26 | 27 |
| 27 | 28 | const binaries: Record<string, string> = {} | 28 | | -const version = process.env["OPENCODE_VERSION"] ?? "dev" | 29 | 29 | for (const [os, arch] of targets) { | 30 | 30 | console.log(`building ${os}-${arch}`) | 31 | 31 | const name = `${pkg.name}-${os}-${arch}` | 32 | 32 | await $`mkdir -p dist/${name}/bin` | 33 | | - await $`CGO_ENABLED=0 GOOS=${os} GOARCH=${GOARCH[arch]} go build -ldflags="-s -w -X main.Version=${version}" -o ../opencode/dist/${name}/bin/tui ../tui/cmd/opencode/main.go` | | 33 | + await $`CGO_ENABLED=0 GOOS=${os} GOARCH=${GOARCH[arch]} go build -ldflags="-s -w -X main.Version=${Script.version}" -o ../opencode/dist/${name}/bin/tui ../tui/cmd/opencode/main.go` | 34 | 34 | .cwd("../tui") | 35 | 35 | .quiet() | 36 | 36 |
| @@ -43,12 +43,12 @@ for (const [os, arch] of targets) { | 43 | 43 | compile: { | 44 | 44 | target: `bun-${os}-${arch}` as any, | 45 | 45 | outfile: `dist/${name}/bin/opencode`, | 46 | | - execArgv: [`--user-agent=opencode/${version}`, `--env-file=""`, `--`], | | 46 | + execArgv: [`--user-agent=opencode/${Script.version}`, `--env-file=""`, `--`], | 47 | 47 | windows: {}, | 48 | 48 | }, | 49 | 49 | entrypoints: ["./src/index.ts"], | 50 | 50 | define: { | 51 | | - OPENCODE_VERSION: `'${version}'`, | | 51 | + OPENCODE_VERSION: `'${Script.version}'`, | 52 | 52 | OPENCODE_TUI_PATH: `'../../../dist/${name}/bin/tui'`, | 53 | 53 | }, | 54 | 54 | }) | @@ -57,15 +57,15 @@ for (const [os, arch] of targets) { | 57 | 57 | JSON.stringify( | 58 | 58 | { | 59 | 59 | name, | 60 | | - version, | | 60 | + version: Script.version, | 61 | 61 | os: [os === "windows" ? "win32" : os], | 62 | 62 | cpu: [arch], | 63 | 63 | }, | 64 | 64 | null, | 65 | 65 | 2, | 66 | 66 | ), | 67 | 67 | ) | 68 | | - binaries[name] = version | | 68 | + binaries[name] = Script.version | 69 | 69 | } | 70 | 70 |
| 71 | 71 | export { binaries } |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/script/publish.ts +19-29Lines changed: 19 additions & 29 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | #!/usr/bin/env bun | 2 | | -const dir = new URL("..", import.meta.url).pathname | 3 | | -process.chdir(dir) | 4 | 2 | import { $ } from "bun" | 5 | | - | 6 | 3 | import pkg from "../package.json" | | 4 | +import { Script } from "@opencode-ai/script" | 7 | 5 |
| 8 | | -const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true" | 9 | | -let version = process.env["OPENCODE_VERSION"] | 10 | | -const tag = process.env["OPENCODE_TAG"] ?? (snapshot ? "snapshot" : "latest") | 11 | | -if (!version && snapshot) { | 12 | | - version = `0.0.0-${tag}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` | 13 | | - process.env["OPENCODE_VERSION"] = version | 14 | | -} | 15 | | -if (!version) throw new Error("OPENCODE_VERSION is required") | 16 | | - | 17 | | -console.log(`publishing ${version}`) | | 6 | +const dir = new URL("..", import.meta.url).pathname | | 7 | +process.chdir(dir) | 18 | 8 |
| 19 | 9 | const { binaries } = await import("./build.ts") | 20 | 10 | { | @@ -38,19 +28,19 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write( | 38 | 28 | preinstall: "node ./preinstall.mjs", | 39 | 29 | postinstall: "node ./postinstall.mjs", | 40 | 30 | }, | 41 | | - version, | | 31 | + version: Script.version, | 42 | 32 | optionalDependencies: binaries, | 43 | 33 | }, | 44 | 34 | null, | 45 | 35 | 2, | 46 | 36 | ), | 47 | 37 | ) | 48 | 38 | for (const [name] of Object.entries(binaries)) { | 49 | | - await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${tag}` | | 39 | + await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${Script.tag}` | 50 | 40 | } | 51 | | -await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${tag}` | | 41 | +await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${Script.tag}` | 52 | 42 |
| 53 | | -if (!snapshot) { | | 43 | +if (!Script.preview) { | 54 | 44 | for (const key of Object.keys(binaries)) { | 55 | 45 | await $`cd dist/${key}/bin && zip -r ../../${key}.zip *` | 56 | 46 | } | @@ -67,7 +57,7 @@ if (!snapshot) { | 67 | 57 | "# Maintainer: adam", | 68 | 58 | "", | 69 | 59 | "pkgname='opencode-bin'", | 70 | | - `pkgver=${version.split("-")[0]}`, | | 60 | + `pkgver=${Script.version.split("-")[0]}`, | 71 | 61 | "options=('!debug' '!strip')", | 72 | 62 | "pkgrel=1", | 73 | 63 | "pkgdesc='The AI coding agent built for the terminal.'", | @@ -78,10 +68,10 @@ if (!snapshot) { | 78 | 68 | "conflicts=('opencode')", | 79 | 69 | "depends=('fzf' 'ripgrep')", | 80 | 70 | "", | 81 | | - `source_aarch64=("\${pkgname}_\${pkgver}_aarch64.zip::https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-arm64.zip")`, | | 71 | + `source_aarch64=("\${pkgname}_\${pkgver}_aarch64.zip::https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-arm64.zip")`, | 82 | 72 | `sha256sums_aarch64=('${arm64Sha}')`, | 83 | 73 | "", | 84 | | - `source_x86_64=("\${pkgname}_\${pkgver}_x86_64.zip::https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-x64.zip")`, | | 74 | + `source_x86_64=("\${pkgname}_\${pkgver}_x86_64.zip::https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-x64.zip")`, | 85 | 75 | `sha256sums_x86_64=('${x64Sha}')`, | 86 | 76 | "", | 87 | 77 | "package() {", | @@ -96,7 +86,7 @@ if (!snapshot) { | 96 | 86 | "# Maintainer: adam", | 97 | 87 | "", | 98 | 88 | "pkgname='opencode'", | 99 | | - `pkgver=${version.split("-")[0]}`, | | 89 | + `pkgver=${Script.version.split("-")[0]}`, | 100 | 90 | "options=('!debug' '!strip')", | 101 | 91 | "pkgrel=1", | 102 | 92 | "pkgdesc='The AI coding agent built for the terminal.'", | @@ -108,7 +98,7 @@ if (!snapshot) { | 108 | 98 | "depends=('fzf' 'ripgrep')", | 109 | 99 | "makedepends=('git' 'bun-bin' 'go')", | 110 | 100 | "", | 111 | | - `source=("opencode-\${pkgver}.tar.gz::https://github.com/sst/opencode/archive/v${version}.tar.gz")`, | | 101 | + `source=("opencode-\${pkgver}.tar.gz::https://github.com/sst/opencode/archive/v${Script.version}.tar.gz")`, | 112 | 102 | `sha256sums=('SKIP')`, | 113 | 103 | "", | 114 | 104 | "build() {", | @@ -139,7 +129,7 @@ if (!snapshot) { | 139 | 129 | await Bun.file(`./dist/aur-${pkg}/PKGBUILD`).write(pkgbuild) | 140 | 130 | await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO` | 141 | 131 | await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO` | 142 | | - await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${version}"` | | 132 | + await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${Script.version}"` | 143 | 133 | await $`cd ./dist/aur-${pkg} && git push` | 144 | 134 | break | 145 | 135 | } catch (e) { | @@ -157,19 +147,19 @@ if (!snapshot) { | 157 | 147 | "class Opencode < Formula", | 158 | 148 | ` desc "The AI coding agent built for the terminal."`, | 159 | 149 | ` homepage "https://github.com/sst/opencode"`, | 160 | | - ` version "${version.split("-")[0]}"`, | | 150 | + ` version "${Script.version.split("-")[0]}"`, | 161 | 151 | "", | 162 | 152 | " on_macos do", | 163 | 153 | " if Hardware::CPU.intel?", | 164 | | - ` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-darwin-x64.zip"`, | | 154 | + ` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-darwin-x64.zip"`, | 165 | 155 | ` sha256 "${macX64Sha}"`, | 166 | 156 | "", | 167 | 157 | " def install", | 168 | 158 | ' bin.install "opencode"', | 169 | 159 | " end", | 170 | 160 | " end", | 171 | 161 | " if Hardware::CPU.arm?", | 172 | | - ` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-darwin-arm64.zip"`, | | 162 | + ` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-darwin-arm64.zip"`, | 173 | 163 | ` sha256 "${macArm64Sha}"`, | 174 | 164 | "", | 175 | 165 | " def install", | @@ -180,14 +170,14 @@ if (!snapshot) { | 180 | 170 | "", | 181 | 171 | " on_linux do", | 182 | 172 | " if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?", | 183 | | - ` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-x64.zip"`, | | 173 | + ` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-x64.zip"`, | 184 | 174 | ` sha256 "${x64Sha}"`, | 185 | 175 | " def install", | 186 | 176 | ' bin.install "opencode"', | 187 | 177 | " end", | 188 | 178 | " end", | 189 | 179 | " if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?", | 190 | | - ` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-arm64.zip"`, | | 180 | + ` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-arm64.zip"`, | 191 | 181 | ` sha256 "${arm64Sha}"`, | 192 | 182 | " def install", | 193 | 183 | ' bin.install "opencode"', | @@ -203,6 +193,6 @@ if (!snapshot) { | 203 | 193 | await $`git clone https://${process.env["GITHUB_TOKEN"]}@github.com/sst/homebrew-tap.git ./dist/homebrew-tap` | 204 | 194 | await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula) | 205 | 195 | await $`cd ./dist/homebrew-tap && git add opencode.rb` | 206 | | - await $`cd ./dist/homebrew-tap && git commit -m "Update to v${version}"` | | 196 | + await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"` | 207 | 197 | await $`cd ./dist/homebrew-tap && git push` | 208 | 198 | } |
Collapse file Copy file name to clipboard +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "$schema": "https://json.schemastore.org/package", | | 3 | + "name": "@opencode-ai/script", | | 4 | + "devDependencies": { | | 5 | + "@types/bun": "catalog:" | | 6 | + }, | | 7 | + "exports": { | | 8 | + ".": "./src/index.ts" | | 9 | + } | | 10 | +} |
Collapse file Copy file name to clipboard +35Lines changed: 35 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { $ } from "bun" | | 2 | + | | 3 | +if (process.versions.bun !== "1.3.0") { | | 4 | + | | 5 | +} | | 6 | + | | 7 | +const TAG = process.env["OPENCODE_TAG"] ?? (await $`git branch --show-current`.text().then((x) => x.trim())) | | 8 | +const IS_PREVIEW = TAG !== "latest" | | 9 | +const VERSION = await (async () => { | | 10 | + if (IS_PREVIEW) return `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` | | 11 | + const version = await fetch("https://registry.npmjs.org/opencode-ai/latest") | | 12 | + .then((res) => { | | 13 | + if (!res.ok) throw new Error(res.statusText) | | 14 | + return res.json() | | 15 | + }) | | 16 | + .then((data: any) => data.version) | | 17 | + const [major, minor, patch] = version.split(".").map((x: string) => Number(x) || 0) | | 18 | + const t = process.env["OPENCODE_BUMP"]?.toLowerCase() | | 19 | + if (t === "major") return `${major + 1}.0.0` | | 20 | + if (t === "minor") return `${major}.${minor + 1}.0` | | 21 | + return `${major}.${minor}.${patch + 1}` | | 22 | +})() | | 23 | + | | 24 | +export const Script = { | | 25 | + get tag() { | | 26 | + return TAG | | 27 | + }, | | 28 | + get version() { | | 29 | + return VERSION | | 30 | + }, | | 31 | + get preview() { | | 32 | + return IS_PREVIEW | | 33 | + }, | | 34 | +} | | 35 | +console.log(`opencode script`, JSON.stringify(Script, null, 2)) |
Collapse file Copy file name to clipboard +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "$schema": "https://json.schemastore.org/tsconfig", | | 3 | + "extends": "@tsconfig/bun/tsconfig.json", | | 4 | + "compilerOptions": { | | 5 | + "lib": ["ESNext", "DOM", "DOM.Iterable"], | | 6 | + "noUncheckedIndexedAccess": false | | 7 | + } | | 8 | +} |
|