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

or not.
This commit is contained in:
yuanhau 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 source files
COPY . . COPY . .
RUN bun run generateVersionTag
# Build the application # Build the application
RUN bun run build RUN bun run build

View file

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

View file

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

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);