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 18a38a0

Browse files
committed
fixup! chore: use Deno from all ci scripts
1 parent 7bc54de commit 18a38a0

File tree

3 files changed

+61
-48
lines changed

3 files changed

+61
-48
lines changed

ci/steps/build.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

ci/steps/build.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env -S deno run --allow-all
2+
import { exec, execInherit, cdProjectRoot, cdCurrent } from "./lib.ts"
3+
4+
const main = async () => {
5+
await cdProjectRoot()
6+
Deno.chdir("./ci/steps")
7+
8+
const goos = Deno.env.get("GOOS")
9+
const goarch = Deno.env.get("GOARCH") ?? ""
10+
11+
const tag = await exec("git describe --tags")
12+
console.info(`--- building coder-cli for ${goos}-${goarch}`)
13+
14+
const dir = await Deno.makeTempDir()
15+
16+
await execInherit(
17+
`go build -ldflags "-X cdr.dev/coder-cli/internal/version.Version=${tag}" -o "${dir}/coder" ../../cmd/coder`
18+
)
19+
20+
await Deno.copyFile("../gon.json", `${dir}/gon.json`)
21+
Deno.chdir(dir)
22+
switch (goos) {
23+
case "darwin":
24+
await packageMacOS(goos, goarch, tag)
25+
break
26+
case "windows":
27+
await packageWindows(goos, goarch, tag)
28+
break
29+
case "linux":
30+
await packageLinux(goos, goarch, tag)
31+
break
32+
default:
33+
throw Error(`unknown GOOS env var: ${goos}`)
34+
}
35+
cdCurrent()
36+
Deno.remove(dir, { recursive: true })
37+
}
38+
39+
const packageWindows = async (goos: string, goarch: string, tag: string) => {
40+
const artifact = `coder-cli-${goos}-${goarch}-${tag}.zip`
41+
await Deno.rename("coder", "coder.exe")
42+
await execInherit(`zip ${artifact} coder.exe`)
43+
}
44+
45+
const packageLinux = async (goos: string, goarch: string, tag: string) => {
46+
const artifact = `coder-cli-${goos}-${goarch}-${tag}.tar.gz`
47+
await execInherit(`tar -czf ${artifact} coder`)
48+
}
49+
50+
const packageMacOS = async (goos: string, goarch: string, tag: string) => {
51+
// cp ../gon.json $tmpdir/gon.json
52+
const artifact = `coder-cli-${goos}-${goarch}-${tag}.zip`
53+
await execInherit("gon -log-level debug ./gon.json")
54+
await Deno.rename("coder.zip", artifact)
55+
}
56+
57+
await main()

ci/steps/lib.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
export const root = async () =>
1+
export const cdProjectRoot = async () =>
22
Deno.chdir(await exec("git rev-parse --show-toplevel"))
33

4+
export const cdCurrent = () =>
5+
Deno.chdir(`${new URL(".", import.meta.url).pathname}/../`)
6+
47
export const string = (a: Uint8Array): string => new TextDecoder().decode(a)
58

69
export const bytes = (a: string): Uint8Array => new TextEncoder().encode(a)

0 commit comments

Comments
 (0)