Files
plainleaf/cmd/update_version.ts
T
Zef Hemel 2f037d2a19 Fixes #1438
Another attempt, apparently Github actions don't allow running git describe.
2025-08-20 10:43:53 +02:00

28 lines
789 B
TypeScript

import { version } from "../version.ts";
export async function updateVersionFile() {
const command = new Deno.Command("git", {
args: ["describe", "--tags", "--long"],
stdout: "piped",
stderr: "piped",
});
const { stdout } = await command.output();
let commitVersion = new TextDecoder().decode(stdout).trim();
if (!commitVersion) {
// Probably in CI, let's pull from Github environment variables instead
commitVersion = `${version}-${Deno.env.get("GITHUB_SHA")}`;
}
const versionFilePath = "./public_version.ts";
const versionContent = `
export const publicVersion = "${commitVersion}";
`;
await Deno.writeTextFile(versionFilePath, versionContent);
console.log(
`Updated public_version.ts with version information: ${commitVersion}`,
);
}