feat: add version for frontend && backend (#230)

This commit is contained in:
Dream Hunter
2024-05-12 18:31:43 +08:00
committed by GitHub
parent 62bec9ef90
commit 9de2d23be1
7 changed files with 10 additions and 5 deletions
-1
View File
@@ -34,7 +34,6 @@ jobs:
cd frontend/ cd frontend/
echo "${{ secrets.FRONTEND_ENV }}" > .env.prod echo "${{ secrets.FRONTEND_ENV }}" > .env.prod
export project_name=${{ secrets.FRONTEND_NAME }} export project_name=${{ secrets.FRONTEND_NAME }}
export VITE_VERSION=${{ github.ref_name }}
pnpm install --no-frozen-lockfile pnpm install --no-frozen-lockfile
pnpm run deploy --project-name=$project_name pnpm run deploy --project-name=$project_name
echo "Deploying prodcution for ${{ github.ref_name }}" echo "Deploying prodcution for ${{ github.ref_name }}"
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "cloudflare_temp_email", "name": "cloudflare_temp_email",
"version": "0.0.0", "version": "0.4.2",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
+3 -1
View File
@@ -69,6 +69,8 @@ const { t } = useI18n({
} }
}); });
const version = import.meta.env.PACKAGE_VERSION ? `v${import.meta.env.PACKAGE_VERSION}` : "";
const menuOptions = computed(() => [ const menuOptions = computed(() => [
{ {
label: () => h(NButton, label: () => h(NButton,
@@ -171,7 +173,7 @@ const menuOptions = computed(() => [
href: "https://github.com/dreamhunter2333/cloudflare_temp_email", href: "https://github.com/dreamhunter2333/cloudflare_temp_email",
}, },
{ {
default: () => import.meta.env.VITE_VERSION || "Github", default: () => version || "Github",
icon: () => h(NIcon, { component: GithubAlt }) icon: () => h(NIcon, { component: GithubAlt })
} }
), ),
+3
View File
@@ -71,5 +71,8 @@ export default defineConfig({
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': fileURLToPath(new URL('./src', import.meta.url))
} }
},
define: {
'import.meta.env.PACKAGE_VERSION': JSON.stringify(process.env.npm_package_version),
} }
}) })
@@ -15,8 +15,6 @@ cp .env.example .env.prod
例如: `VITE_API_BASE=https://xxx.xxx.workers.dev` 例如: `VITE_API_BASE=https://xxx.xxx.workers.dev`
```bash ```bash
# 请修改为你的版本号, 可以不填
# export VITE_VERSION=0.0.0
pnpm build --emptyOutDir pnpm build --emptyOutDir
# 根据提示创建 pages # 根据提示创建 pages
pnpm run deploy pnpm run deploy
+2
View File
@@ -1,6 +1,7 @@
import { Hono } from 'hono' import { Hono } from 'hono'
import { getDomains, getPasswords, getBooleanValue } from './utils'; import { getDomains, getPasswords, getBooleanValue } from './utils';
import { CONSTANTS } from './constants';
const api = new Hono() const api = new Hono()
@@ -22,6 +23,7 @@ api.get('/open_api/settings', async (c) => {
"enableAutoReply": getBooleanValue(c.env.ENABLE_AUTO_REPLY), "enableAutoReply": getBooleanValue(c.env.ENABLE_AUTO_REPLY),
"copyright": c.env.COPYRIGHT, "copyright": c.env.COPYRIGHT,
"cfTurnstileSiteKey": c.env.CF_TURNSTILE_SITE_KEY, "cfTurnstileSiteKey": c.env.CF_TURNSTILE_SITE_KEY,
"version": CONSTANTS.VERSION,
}); });
}) })
+1
View File
@@ -1,4 +1,5 @@
export const CONSTANTS = { export const CONSTANTS = {
VERSION: 'v0.4.2',
ADDRESS_BLOCK_LIST_KEY: 'address_block_list', ADDRESS_BLOCK_LIST_KEY: 'address_block_list',
SEND_BLOCK_LIST_KEY: 'send_block_list', SEND_BLOCK_LIST_KEY: 'send_block_list',
AUTO_CLEANUP_KEY: 'auto_cleanup', AUTO_CLEANUP_KEY: 'auto_cleanup',