From 78fca4cc94b8d0187ac855e5295ff91411443011 Mon Sep 17 00:00:00 2001
From: log1997 <2694233102@qq.com>
Date: Fri, 5 Dec 2025 17:17:28 +0800
Subject: [PATCH 1/5] ci: actions
---
.github/workflows/release.yml | 74 +++++++++++++++++++++++++++++++++++
src/components.d.ts | 1 +
2 files changed, 75 insertions(+)
create mode 100644 .github/workflows/release.yml
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..d510f69
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,74 @@
+name: Build and Release
+
+on:
+ push:
+ tags:
+ - 'v*'
+
+jobs:
+ build-and-release:
+ runs-on: ubuntu-latest
+
+ permissions:
+ contents: write
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v2
+ with:
+ version: 8
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v3
+ with:
+ node-version: '22.x'
+ cache: 'pnpm'
+
+ - name: Install dependencies
+ run: pnpm install
+
+ - name: Build for production
+ run: pnpm build
+
+ - name: Build for file protocol
+ run: pnpm build:file
+
+ - name: Rename dist folders
+ run: |
+ mv dist dist-prod
+ mv dist-prod/index.html dist-prod/404.html
+ mv dist-file dist-file-prod
+
+ - name: Create source code archive
+ run: |
+ tar -czf source-code.tar.gz \
+ --exclude='.git' \
+ --exclude='node_modules' \
+ --exclude='dist-prod' \
+ --exclude='dist-file-prod' \
+ --exclude='*.tar.gz' \
+ .
+
+ - name: Create production build archive
+ run: |
+ tar -czf production-build.tar.gz dist-prod
+
+ - name: Create file protocol build archive
+ run: |
+ tar -czf file-protocol-build.tar.gz dist-file-prod
+
+ - name: Release
+ uses: softprops/action-gh-release@v1
+ with:
+ files: |
+ source-code.tar.gz
+ production-build.tar.gz
+ file-protocol-build.tar.gz
+ draft: true
+ prerelease: false
+ generate_release_notes: true
\ No newline at end of file
diff --git a/src/components.d.ts b/src/components.d.ts
index 8db03bd..89b8fbe 100644
--- a/src/components.d.ts
+++ b/src/components.d.ts
@@ -2,6 +2,7 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
+// biome-ignore lint: disable
export {}
/* prettier-ignore */
From a73abc098fce11ac97e310584206ca4b0509ceb8 Mon Sep 17 00:00:00 2001
From: log1997 <2694233102@qq.com>
Date: Fri, 5 Dec 2025 17:25:40 +0800
Subject: [PATCH 2/5] ci: actions
---
.github/workflows/release.yml | 2 +-
vite.config.ts | 243 +++++++++++++++++-----------------
2 files changed, 123 insertions(+), 122 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d510f69..1eb3fb4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -38,7 +38,7 @@ jobs:
- name: Build for file protocol
run: pnpm build:file
- - name: Rename dist folders
+ - name: Prepare directories
run: |
mv dist dist-prod
mv dist-prod/index.html dist-prod/404.html
diff --git a/vite.config.ts b/vite.config.ts
index a0e5b70..b873adc 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -19,132 +19,133 @@ const require = createRequire(import.meta.url)
const process = require('node:process')
export default defineConfig(({ mode }) => {
- const env = loadEnv(mode, __dirname)
- const chunkName = mode === 'prebuild' ? '[name]' : 'chunk'
+ const env = loadEnv(mode, __dirname)
+ const chunkName = mode === 'prebuild' ? '[name]' : 'chunk'
- return {
- base: mode === 'file' ? './' : '/log-lottery/',
- plugins: [
- vue(),
- mode === 'file'
- ? legacy({
- additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
- })
- : null,
- // vueDevTools(),
- viteCompression({
- verbose: true,
- disable: false,
- threshold: 10240,
- algorithm: 'gzip',
- ext: '.gz',
- }),
- visualizer({
- emitFile: true, // 是否被触摸
- filename: 'test.html', // 生成分析网页文件名
- open: true, // 在默认用户代理中打开生成的文件
- gzipSize: true, // 从源代码中收集 gzip 大小并将其显示在图表中
- brotliSize: true, // 从源代码中收集 brotli 大小并将其显示在图表中
- }),
+ return {
+ base: mode === 'file' ? './' : '/log-lottery/',
+ plugins: [
+ vue(),
+ mode === 'file'
+ ? legacy({
+ additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
+ })
+ : null,
+ // vueDevTools(),
+ viteCompression({
+ verbose: true,
+ disable: false,
+ threshold: 10240,
+ algorithm: 'gzip',
+ ext: '.gz',
+ }),
+ visualizer({
+ emitFile: true, // 是否被触摸
+ filename: 'test.html', // 生成分析网页文件名
+ open: true, // 在默认用户代理中打开生成的文件
+ gzipSize: true, // 从源代码中收集 gzip 大小并将其显示在图表中
+ brotliSize: true, // 从源代码中收集 brotli 大小并将其显示在图表中
+ }),
- createSvgIconsPlugin({
- // 指定需要缓存的图标文件夹
- iconDirs: [path.resolve(process.cwd(), 'src/icons')],
- // 指定symbolId格式
- symbolId: 'icon-[dir]-[name]',
- }),
- AutoImport({
- resolvers: [
- // 自动导入图标组件
- IconsResolver({
- prefix: 'Icon',
- }),
+ createSvgIconsPlugin({
+ // 指定需要缓存的图标文件夹
+ iconDirs: [path.resolve(process.cwd(), 'src/icons')],
+ // 指定symbolId格式
+ symbolId: 'icon-[dir]-[name]',
+ }),
+ AutoImport({
+ resolvers: [
+ // 自动导入图标组件
+ IconsResolver({
+ prefix: 'Icon',
+ }),
+ ],
+ dts: path.resolve(path.resolve(__dirname, 'src'), 'auto-imports.d.ts'),
+ }),
+ Components({
+ resolvers: [
+ // 自动注册图标组件
+ IconsResolver({
+ enabledCollections: ['ep'],
+ }),
+ ],
+ dts: path.resolve(path.resolve(__dirname, 'src'), 'components.d.ts'),
+ }),
+ Icons({
+ autoInstall: true,
+ }),
],
- dts: path.resolve(path.resolve(__dirname, 'src'), 'auto-imports.d.ts'),
- }),
- Components({
- resolvers: [
- // 自动注册图标组件
- IconsResolver({
- enabledCollections: ['ep'],
- }),
- ],
- dts: path.resolve(path.resolve(__dirname, 'src'), 'components.d.ts'),
- }),
- Icons({
- autoInstall: true,
- }),
- ],
- css: {
- preprocessorOptions: {
- scss: {
- additionalData: '@use "@/style/global.scss" as *;',
+ css: {
+ preprocessorOptions: {
+ scss: {
+ additionalData: '@use "@/style/global.scss" as *;',
+ },
+ },
+ // postcss: {
+ // plugins: [
+ // require('tailwindcss'),
+ // require('autoprefixer'),
+ // ]
+ // }
},
- },
- // postcss: {
- // plugins: [
- // require('tailwindcss'),
- // require('autoprefixer'),
- // ]
- // }
- },
- server: {
- host: 'localhost',
- port: 6719,
- proxy: {
- '/api': {
- target: env.VITE_BASE_URL,
- // 是否跨域
- changeOrigin: true,
- // 路径重写
- rewrite: path => path.replace(/^\/api/, ''),
+ server: {
+ host: 'localhost',
+ port: 6719,
+ proxy: {
+ '/api': {
+ target: env.VITE_BASE_URL,
+ // 是否跨域
+ changeOrigin: true,
+ // 路径重写
+ rewrite: path => path.replace(/^\/api/, ''),
+ },
+ },
},
- },
- },
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './src'),
- },
- },
- build: {
- minify: 'terser',
- terserOptions: {
- compress: {
- // 生产环境时移除console
- drop_console: true,
- drop_debugger: true,
+ resolve: {
+ alias: {
+ '@': path.resolve(__dirname, './src'),
+ },
},
- },
- // 关闭文件计算
- reportCompressedSize: false,
- // 关闭生成map文件 可以达到缩小打包体积
- sourcemap: false, // 这个生产环境一定要关闭,不然打包的产物会很大
- rollupOptions: {
- output: {
- chunkFileNames: `js/${chunkName}-[hash].js`, // 引入文件名的名称
- entryFileNames: `js/${chunkName}-[hash].js`, // 包的入口文件名称
- assetFileNames: `[ext]/${chunkName}-[hash].[ext]`, // 资源文件像 字体,图片等
- manualChunks(id: any): string {
- if (id.includes('node_modules')) {
- return id
- .toString()
- .split('node_modules/')[1]
- .split('/')[0]
- .toString()
- }
- },
+ build: {
+ outDir: mode === 'file' ? 'dist-file' : 'dist',
+ minify: 'terser',
+ terserOptions: {
+ compress: {
+ // 生产环境时移除console
+ drop_console: true,
+ drop_debugger: true,
+ },
+ },
+ // 关闭文件计算
+ reportCompressedSize: false,
+ // 关闭生成map文件 可以达到缩小打包体积
+ sourcemap: false, // 这个生产环境一定要关闭,不然打包的产物会很大
+ rollupOptions: {
+ output: {
+ chunkFileNames: `js/${chunkName}-[hash].js`, // 引入文件名的名称
+ entryFileNames: `js/${chunkName}-[hash].js`, // 包的入口文件名称
+ assetFileNames: `[ext]/${chunkName}-[hash].[ext]`, // 资源文件像 字体,图片等
+ manualChunks(id: any): string {
+ if (id.includes('node_modules')) {
+ return id
+ .toString()
+ .split('node_modules/')[1]
+ .split('/')[0]
+ .toString()
+ }
+ },
+ },
+ },
},
- },
- },
- // 使用这个必须在上面加/// 不然会有类型报错
- test: {
- globals: true, // --> 0.8.1+ 请修改成globals
- environment: 'jsdom',
- // include: ['**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
- // passWithNoTests: true,
- transformMode: {
- web: [/\.[jt]sx$/],
- },
- },
- }
+ // 使用这个必须在上面加/// 不然会有类型报错
+ test: {
+ globals: true, // --> 0.8.1+ 请修改成globals
+ environment: 'jsdom',
+ // include: ['**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
+ // passWithNoTests: true,
+ transformMode: {
+ web: [/\.[jt]sx$/],
+ },
+ },
+ }
})
From 001853d3f55d2361bc37cd4bda06cae08e39b5ad Mon Sep 17 00:00:00 2001
From: log1997 <2694233102@qq.com>
Date: Fri, 5 Dec 2025 17:34:12 +0800
Subject: [PATCH 3/5] ci: ci fix
---
.github/workflows/release.yml | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1eb3fb4..e4a42ff 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -46,13 +46,20 @@ jobs:
- name: Create source code archive
run: |
- tar -czf source-code.tar.gz \
- --exclude='.git' \
- --exclude='node_modules' \
- --exclude='dist-prod' \
- --exclude='dist-file-prod' \
- --exclude='*.tar.gz' \
- .
+ mkdir -p temp_source
+ cp -r .git temp_source/.git
+ cp -r src temp_source/src
+ cp -r public temp_source/public
+ cp -r .github temp_source/.github
+ cp package.json temp_source/
+ cp vite.config.ts temp_source/
+ cp tsconfig.json temp_source/
+ cp tsconfig.node.json temp_source/
+ cp index.html temp_source/
+ cp README.md temp_source/
+ cp Dockerfile temp_source/
+ tar -czf source-code.tar.gz -C temp_source .
+ rm -rf temp_source
- name: Create production build archive
run: |
From 7447bab9399c421f400e028d6b74fc425bdce2e7 Mon Sep 17 00:00:00 2001
From: log1997 <2694233102@qq.com>
Date: Fri, 5 Dec 2025 17:34:53 +0800
Subject: [PATCH 4/5] =?UTF-8?q?build(package):=20=E6=9B=B4=E6=96=B0?=
=?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E8=87=B30.0.4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
将 package.json 中的 version 字段从 0.0.3 升级到 0.0.4
---
package.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index 0e47df5..4ad1910 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "log-lottery",
"private": true,
- "version": "0.0.3",
+ "version": "0.0.4",
"type": "module",
"license": "MIT",
"scripts": {
@@ -83,4 +83,4 @@
"vitest": "^2.1.5",
"vue-tsc": "^2.1.10"
}
-}
+}
\ No newline at end of file
From bc09902a3be46b398f7d57e0d64ab52db86d3545 Mon Sep 17 00:00:00 2001
From: log1997 <2694233102@qq.com>
Date: Fri, 5 Dec 2025 17:43:05 +0800
Subject: [PATCH 5/5] ci: release actions
---
.github/workflows/release.yml | 27 ++++-----------------------
1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e4a42ff..002c943 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -42,40 +42,21 @@ jobs:
run: |
mv dist dist-prod
mv dist-prod/index.html dist-prod/404.html
- mv dist-file dist-file-prod
-
- - name: Create source code archive
- run: |
- mkdir -p temp_source
- cp -r .git temp_source/.git
- cp -r src temp_source/src
- cp -r public temp_source/public
- cp -r .github temp_source/.github
- cp package.json temp_source/
- cp vite.config.ts temp_source/
- cp tsconfig.json temp_source/
- cp tsconfig.node.json temp_source/
- cp index.html temp_source/
- cp README.md temp_source/
- cp Dockerfile temp_source/
- tar -czf source-code.tar.gz -C temp_source .
- rm -rf temp_source
- name: Create production build archive
run: |
- tar -czf production-build.tar.gz dist-prod
+ tar -czf dist.tar.gz dist-prod
- name: Create file protocol build archive
run: |
- tar -czf file-protocol-build.tar.gz dist-file-prod
+ tar -czf dist-file.tar.gz dist-file
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
- source-code.tar.gz
- production-build.tar.gz
- file-protocol-build.tar.gz
+ dist.tar.gz
+ dist-file.tar.gz
draft: true
prerelease: false
generate_release_notes: true
\ No newline at end of file