Generate version from git describe at build time (#1374)
* Generate version from git describe at build time * Add 2.0-beta prefix * Use Deno.Command instead of Deno.run
This commit is contained in:
@@ -15,3 +15,4 @@ silverbullet
|
||||
deploy.json
|
||||
*.generated
|
||||
tmp_playground
|
||||
/version.ts
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { denoPlugins } from "@luca/esbuild-deno-loader";
|
||||
import * as esbuild from "esbuild";
|
||||
|
||||
import { updateVersionFile } from "./update_version.ts";
|
||||
|
||||
await updateVersionFile();
|
||||
await Deno.mkdir("dist", { recursive: true });
|
||||
await esbuild.build({
|
||||
entryPoints: {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { compileManifests } from "./cmd/compile.ts";
|
||||
import { builtinPlugNames } from "./plugs/builtin_plugs.ts";
|
||||
import { parseArgs } from "@std/cli/parse-args";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { updateVersionFile } from "./update_version.ts";
|
||||
|
||||
await updateVersionFile();
|
||||
|
||||
if (import.meta.main) {
|
||||
const args = parseArgs(Deno.args, {
|
||||
|
||||
@@ -8,6 +8,9 @@ import { parseArgs } from "@std/cli/parse-args";
|
||||
import { patchDenoLibJS } from "./cmd/compile.ts";
|
||||
import { denoPlugins } from "@luca/esbuild-deno-loader";
|
||||
import * as esbuild from "esbuild";
|
||||
import { updateVersionFile } from "./update_version.ts";
|
||||
|
||||
await updateVersionFile();
|
||||
|
||||
export async function bundleAll(
|
||||
watch: boolean,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
export async function updateVersionFile() {
|
||||
const command = new Deno.Command("git", {
|
||||
args: ["describe", "--tags", "--long", "--dirty"],
|
||||
stdout: "piped",
|
||||
stderr: "piped",
|
||||
});
|
||||
|
||||
const { stdout } = await command.output();
|
||||
const commitVersion = new TextDecoder().decode(stdout).trim();
|
||||
|
||||
const versionFilePath = "./version.ts";
|
||||
const versionContent = `export const version = "2.0-beta (${commitVersion})";\n`;
|
||||
|
||||
await Deno.writeTextFile(versionFilePath, versionContent);
|
||||
console.log(`Updated version.ts with version information: ${commitVersion}`);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export const version = "2.0-beta";
|
||||
Reference in New Issue
Block a user