Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit dffcb71

Browse files
committed
feat: add brew formula for macOS
1 parent 7fcfe98 commit dffcb71

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

.github/workflows/test.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,10 @@ jobs:
5353
uses: ./ci/image
5454
with:
5555
args: ./ci/steps/gendocs.sh
56+
brew_installs:
57+
runs-on: macos-latest
58+
steps:
59+
- uses: actions/checkout@v1
60+
- run: brew install --build-from-source ./coder.rb
61+
- run: coder --version
62+

ci/scripts/lib.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { exec } from 'https://cdn.depjs.com/exec/mod.ts'
2+
3+
export const currentDir = `${new URL(".", import.meta.url).pathname}/../`
4+
5+
export const projectRoot = async () => exec("git rev-parse --show-toplevel")
6+
7+
export const string = (a: Uint8Array): string => new TextDecoder().decode(a)
8+
9+
export const bytes = (a: string): Uint8Array => new TextEncoder().encode(a)
10+
11+
export const read = async (path: string): Promise<string> =>
12+
string(await Deno.readFile(path))
13+
14+
export const write = async (path: string, data: string): Promise<void> =>
15+
Deno.writeFile(path, bytes(data))

ci/scripts/update_brew.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env -S deno run --allow-all
2+
import { projectRoot, write } from "./lib.ts"
3+
4+
Deno.chdir(await projectRoot())
5+
6+
interface Params {
7+
sha: string
8+
version: string
9+
}
10+
11+
const template = ({ sha, version }: Params) => `class Coder < Formula
12+
desc "A command-line tool for the Coder remote development platform"
13+
homepage "https://github.com/cdr/coder-cli"
14+
url "https://github.com/cdr/coder-cli/releases/download/${version}/coder-cli-darwin-amd64-${version}.zip"
15+
sha256 "${sha}"
16+
bottle :unneeded
17+
def install
18+
bin.install "coder"
19+
end
20+
test do
21+
system "#{bin}/coder", "--version"
22+
end
23+
end
24+
`
25+
26+
if (Deno.args.length < 2) {
27+
throw Error("2 args required")
28+
}
29+
30+
const version = Deno.args[0]
31+
const sha = Deno.args[1]
32+
33+
await write("./coder.rb", template({ sha, version }))

coder.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Coder < Formula
2+
desc "A command-line tool for the Coder remote development platform"
3+
homepage "https://github.com/cdr/coder-cli"
4+
url "https://github.com/cdr/coder-cli/releases/download/v1.14.2/coder-cli-darwin-amd64-v1.14.2.zip"
5+
sha256 "69b69497a75ce19851681974aa7561af7c7061357f8616e24446e58795bf6e1f"
6+
bottle :unneeded
7+
def install
8+
bin.install "coder"
9+
end
10+
test do
11+
system "#{bin}/coder", "--version"
12+
end
13+
end

0 commit comments

Comments
 (0)