Add version tag system, for matching if the deployment is the newest one

or not.
This commit is contained in:
吳元皓 2025-06-08 21:36:37 +08:00
parent 61de16e285
commit dd39bc3910
5 changed files with 25 additions and 4 deletions

View File

@ -14,7 +14,7 @@
# Copy source files
COPY . .
RUN bun run generateVersionTag
# Build the application
RUN bun run build

View File

@ -10,6 +10,7 @@ import {
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import getVersionTag from "~/versionTag";
import { Button } from "@/components/ui/button";
const { t, locale } = useI18n();
const user = ref("");
@ -294,7 +295,7 @@ const submitChangeAction = async (action: string) => {
</div>
<hr />
<div class="justiy-center align-center text-center">
{{ t("app.settings") }} v0.0.3
{{ t("app.settings") }} v0.0.3 || Version: {{ getVersionTag() }}
</div>
</div>
</template>

View File

@ -14,7 +14,8 @@
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"wipedev": "./clean-dev-env.sh"
"wipedev": "./clean-dev-env.sh",
"generateVersionTag": "bun run versionTagGenerate.ts"
},
"dependencies": {
"@fontsource-variable/noto-sans-tc": "^5.2.5",

3
versionTag.ts Normal file
View File

@ -0,0 +1,3 @@
export default function versionTag() {
return "value";
}

16
versionTagGenerate.ts Normal file
View File

@ -0,0 +1,16 @@
import { $ } from "bun";
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function generateVersionTag() {
let slug = "";
let length = 8;
for (let times = 0; times < length; times++) {
slug += characters.charAt(Math.floor(Math.random() * characters.length));
}
return slug;
}
const tag = generateVersionTag();
// Command
await $`echo 'export default function versionTag() {return "${tag}";}' > ./versionTag.ts`;
console.log("Version Tag:", tag);