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 2e8d708

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

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

ci/steps/build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ cp ../gon.json $tmpdir/gon.json
2020
pushd "$tmpdir"
2121
case "$GOOS" in
2222
"windows")
23-
artifact="coder-cli-$GOOS-$GOARCH.zip"
23+
artifact="coder-cli-$GOOS-$GOARCH-$tag.zip"
2424
mv coder coder.exe
2525
zip "$artifact" coder.exe
2626
;;
2727
"linux")
28-
artifact="coder-cli-$GOOS-$GOARCH.tar.gz"
28+
artifact="coder-cli-$GOOS-$GOARCH-$tag.tar.gz"
2929
tar -czf "$artifact" coder
3030
;;
3131
"darwin")
3232
if [[ ${CI-} ]]; then
33-
artifact="coder-cli-$GOOS-$GOARCH.zip"
33+
artifact="coder-cli-$GOOS-$GOARCH-$tag.zip"
3434
gon -log-level debug ./gon.json
3535
mv coder.zip $artifact
3636
else
37-
artifact="coder-cli-$GOOS-$GOARCH.tar.gz"
37+
artifact="coder-cli-$GOOS-$GOARCH-$tag.tar.gz"
3838
tar -czf "$artifact" coder
3939
echo "--- warning: not in ci, skipping signed release of darwin"
4040
fi

ci/steps/lib.ts

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

ci/steps/update_brew.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env -S deno run --allow-all
2+
import { root, write } from "./lib.ts"
3+
4+
await root()
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 platorm"
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+
17+
bottle :unneeded
18+
19+
def install
20+
bin.install "coder"
21+
end
22+
23+
test do
24+
system "#{bin}/coder", "--version"
25+
end
26+
end
27+
`
28+
29+
if (Deno.args.length < 2) {
30+
throw Error("2 args required")
31+
}
32+
33+
const version = Deno.args[0]
34+
const sha = Deno.args[1]
35+
36+
await write("./coder.rb", template({ sha, version }))

coder.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Coder < Formula
2+
desc "a command line tool for the Coder remote development platorm"
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+
7+
bottle :unneeded
8+
9+
def install
10+
bin.install "coder"
11+
end
12+
13+
test do
14+
system "#{bin}/coder", "--version"
15+
end
16+
end

0 commit comments

Comments
 (0)