diff --git a/action/build.ts b/action/build.ts new file mode 100644 index 000000000..28104905a --- /dev/null +++ b/action/build.ts @@ -0,0 +1,2 @@ +import { run } from "./run.ts"; +await run("build-komodo"); \ No newline at end of file diff --git a/action/deno.json b/action/deno.json new file mode 100644 index 000000000..5d7670259 --- /dev/null +++ b/action/deno.json @@ -0,0 +1,5 @@ +{ + "imports": { + "@std/toml": "jsr:@std/toml" + } +} diff --git a/action/deploy.ts b/action/deploy.ts new file mode 100755 index 000000000..28143a495 --- /dev/null +++ b/action/deploy.ts @@ -0,0 +1,2 @@ +import { run } from "./run.ts"; +await run("deploy-komodo"); diff --git a/action/run.ts b/action/run.ts new file mode 100644 index 000000000..fdb33521a --- /dev/null +++ b/action/run.ts @@ -0,0 +1,52 @@ +import * as TOML from "@std/toml"; + +export const run = async (action: string) => { + const branch = await new Deno.Command("bash", { + args: ["-c", "git rev-parse --abbrev-ref HEAD"], + }) + .output() + .then((r) => new TextDecoder("utf-8").decode(r.stdout).trim()); + + const cargo_toml_str = await Deno.readTextFile("Cargo.toml"); + const prev_version = ( + TOML.parse(cargo_toml_str) as { + workspace: { package: { version: string } }; + } + ).workspace.package.version; + + const [version, tag, count] = prev_version.split("-"); + const next_count = Number(count) + 1; + + const next_version = `${version}-${tag}-${next_count}`; + + await Deno.writeTextFile( + "Cargo.toml", + cargo_toml_str.replace( + `version = "${prev_version}"`, + `version = "${next_version}"` + ) + ); + + // Cargo check first here to make sure lock file is updated before commit. + const cmd = ` +cargo check +echo "" + +git add --all +git commit --all --message "deploy ${version}-${tag}-${next_count}" + +echo "" +git push +echo "" + +km run -y action ${action} "KOMODO_BRANCH=${branch}&KOMODO_VERSION=${version}&KOMODO_TAG=${tag}-${next_count}" +` + .split("\n") + .map((line) => line.trim()) + .filter((line) => line.length > 0 && !line.startsWith("//")) + .join(" && "); + + new Deno.Command("bash", { + args: ["-c", cmd], + }).spawn(); +}; diff --git a/deploy/deno.json b/deploy/deno.json deleted file mode 100644 index 0967ef424..000000000 --- a/deploy/deno.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/deploy/komodo.ts b/deploy/komodo.ts deleted file mode 100755 index eff1514fe..000000000 --- a/deploy/komodo.ts +++ /dev/null @@ -1,50 +0,0 @@ -import * as TOML from "jsr:@std/toml"; - -const branch = await new Deno.Command("bash", { - args: ["-c", "git rev-parse --abbrev-ref HEAD"], -}) - .output() - .then((r) => new TextDecoder("utf-8").decode(r.stdout).trim()); - -const cargo_toml_str = await Deno.readTextFile("Cargo.toml"); -const prev_version = ( - TOML.parse(cargo_toml_str) as { - workspace: { package: { version: string } }; - } -).workspace.package.version; - -const [version, tag, count] = prev_version.split("-"); -const next_count = Number(count) + 1; - -const next_version = `${version}-${tag}-${next_count}`; - -await Deno.writeTextFile( - "Cargo.toml", - cargo_toml_str.replace( - `version = "${prev_version}"`, - `version = "${next_version}"` - ) -); - -// Cargo check first here to make sure lock file is updated before commit. -const cmd = ` -cargo check -echo "" - -git add --all -git commit --all --message "deploy ${version}-${tag}-${next_count}" - -echo "" -git push -echo "" - -km run -y action deploy-komodo "KOMODO_BRANCH=${branch}&KOMODO_VERSION=${version}&KOMODO_TAG=${tag}-${next_count}" -` - .split("\n") - .map((line) => line.trim()) - .filter((line) => line.length > 0 && !line.startsWith("//")) - .join(" && "); - -new Deno.Command("bash", { - args: ["-c", cmd], -}).spawn(); diff --git a/runfile.toml b/runfile.toml index d762435c9..234d731af 100644 --- a/runfile.toml +++ b/runfile.toml @@ -61,4 +61,8 @@ cmd = "cargo doc --no-deps -p komodo_client && http-server -p 8050 target/doc" [deploy-komodo] alias = "dk" -cmd = "deno run --allow-all deploy/komodo.ts" \ No newline at end of file +cmd = "deno run --allow-all action/deploy.ts" + +[build-komodo] +alias = "bk" +cmd = "deno run --allow-all action/build.ts" \ No newline at end of file