|
| 1 | +// deno-lint-ignore-file no-deprecated-deno-api |
| 2 | +import { resolve } from "@std/path"; |
| 3 | +import { assert } from "@std/assert"; |
| 4 | + |
| 5 | +import * as semver from "https://deno.land/x/[email protected]/mod.ts"; |
| 6 | + |
| 7 | +type Options = Parameters<typeof Deno.run>[0]; |
| 8 | +async function run(label: string, options: Options) { |
| 9 | + const p = await Deno.run(options).status(); |
| 10 | + assert(p.code === 0, label); |
| 11 | +} |
| 12 | + |
| 13 | +const version = semver.valid(Deno.args[0]); |
| 14 | +assert(version, "Invalid version!"); |
| 15 | + |
| 16 | +const file = resolve("./deno.json"); |
| 17 | +const Config = JSON.parse(await Deno.readTextFile(file)); |
| 18 | + |
| 19 | +await run("build npm package", { |
| 20 | + cmd: ["deno", "task", "build", version], |
| 21 | +}); |
| 22 | + |
| 23 | +Config.version = version; |
| 24 | +const contents = JSON.stringify(Config, null, 2); |
| 25 | +await Deno.writeTextFile(file, contents); |
| 26 | + |
| 27 | +// prevent CI error |
| 28 | +await run("deno fmt", { |
| 29 | + cmd: ["deno", "fmt", file], |
| 30 | +}); |
| 31 | + |
| 32 | +await run("publish npm package", { |
| 33 | + cmd: ["npm", "publish"], |
| 34 | + cwd: resolve("npm"), |
| 35 | +}); |
| 36 | + |
| 37 | +await run("publish jsr package", { |
| 38 | + cmd: ["deno", "publish", "--allow-dirty"], |
| 39 | +}); |
| 40 | + |
| 41 | +await run("git add", { |
| 42 | + cmd: ["git", "add", file], |
| 43 | +}); |
| 44 | + |
| 45 | +await run("git commit", { |
| 46 | + cmd: ["git", "commit", "-m", version], |
| 47 | +}); |
| 48 | + |
| 49 | +await run("git tag", { |
| 50 | + cmd: ["git", "tag", version], |
| 51 | +}); |
| 52 | + |
| 53 | +await run("git push", { |
| 54 | + cmd: ["git", "push", "--tags"], |
| 55 | +}); |
0 commit comments