From 2f037d2a198a25dc356fd95f1f56b29f0f4c5841 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 20 Aug 2025 10:43:53 +0200 Subject: [PATCH] Fixes #1438 Another attempt, apparently Github actions don't allow running git describe. --- .github/workflows/edge.yml | 1 - build_web.ts | 3 +-- cmd/update_version.ts | 9 ++++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/edge.yml b/.github/workflows/edge.yml index d728b912..11d78395 100644 --- a/.github/workflows/edge.yml +++ b/.github/workflows/edge.yml @@ -17,7 +17,6 @@ jobs: - name: Compile for all platforms run: | deno task build - deno task bundle deno task server:zip:linux-x86_64 deno task server:zip:linux-aarch64 deno task server:zip:darwin-x86_64 diff --git a/build_web.ts b/build_web.ts index e58e663e..fc35f07a 100644 --- a/build_web.ts +++ b/build_web.ts @@ -10,8 +10,6 @@ import { denoPlugins } from "@luca/esbuild-deno-loader"; import * as esbuild from "esbuild"; import { updateVersionFile } from "./cmd/update_version.ts"; -await updateVersionFile(); - export async function bundleAll( watch: boolean, ): Promise { @@ -149,6 +147,7 @@ if (import.meta.main) { watch: false, }, }); + await updateVersionFile(); await bundleAll(args.watch); if (!args.watch) { esbuild.stop(); diff --git a/cmd/update_version.ts b/cmd/update_version.ts index 001e8d08..b2e2cdac 100644 --- a/cmd/update_version.ts +++ b/cmd/update_version.ts @@ -1,3 +1,5 @@ +import { version } from "../version.ts"; + export async function updateVersionFile() { const command = new Deno.Command("git", { args: ["describe", "--tags", "--long"], @@ -6,7 +8,12 @@ export async function updateVersionFile() { }); const { stdout } = await command.output(); - const commitVersion = new TextDecoder().decode(stdout).trim(); + 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 = `