mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
refactor: commit hash in dev version
This commit is contained in:
parent
80c611aec8
commit
e1c4a94e02
45
.github/workflows/build.yml
vendored
45
.github/workflows/build.yml
vendored
@ -89,7 +89,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pnpm install
|
pnpm install
|
||||||
pnpm add @mihomo-party/sysproxy-win32-${{ matrix.arch }}-msvc
|
pnpm add @mihomo-party/sysproxy-win32-${{ matrix.arch }}-msvc
|
||||||
pnpm prepare --${{ matrix.arch }}
|
- name: Update Version for Dev Build
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
env:
|
||||||
|
GITHUB_EVENT_NAME: workflow_dispatch
|
||||||
|
run: node scripts/update-version.mjs
|
||||||
|
- name: Prepare
|
||||||
|
run: pnpm prepare --${{ matrix.arch }}
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
npm_config_arch: ${{ matrix.arch }}
|
npm_config_arch: ${{ matrix.arch }}
|
||||||
@ -159,7 +165,13 @@ jobs:
|
|||||||
pnpm add @mihomo-party/sysproxy-win32-${{ matrix.arch }}-msvc
|
pnpm add @mihomo-party/sysproxy-win32-${{ matrix.arch }}-msvc
|
||||||
pnpm add -D electron@22.3.27
|
pnpm add -D electron@22.3.27
|
||||||
(Get-Content electron-builder.yml) -replace 'windows', 'win7' | Set-Content electron-builder.yml
|
(Get-Content electron-builder.yml) -replace 'windows', 'win7' | Set-Content electron-builder.yml
|
||||||
pnpm prepare --${{ matrix.arch }}
|
- name: Update Version for Dev Build
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
env:
|
||||||
|
GITHUB_EVENT_NAME: workflow_dispatch
|
||||||
|
run: node scripts/update-version.mjs
|
||||||
|
- name: Prepare
|
||||||
|
run: pnpm prepare --${{ matrix.arch }}
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
npm_config_arch: ${{ matrix.arch }}
|
npm_config_arch: ${{ matrix.arch }}
|
||||||
@ -228,7 +240,13 @@ jobs:
|
|||||||
pnpm install
|
pnpm install
|
||||||
pnpm add @mihomo-party/sysproxy-linux-${{ matrix.arch }}-gnu
|
pnpm add @mihomo-party/sysproxy-linux-${{ matrix.arch }}-gnu
|
||||||
sed -i "s/productName: Clash Party/productName: mihomo-party/" electron-builder.yml
|
sed -i "s/productName: Clash Party/productName: mihomo-party/" electron-builder.yml
|
||||||
pnpm prepare --${{ matrix.arch }}
|
- name: Update Version for Dev Build
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
env:
|
||||||
|
GITHUB_EVENT_NAME: workflow_dispatch
|
||||||
|
run: node scripts/update-version.mjs
|
||||||
|
- name: Prepare
|
||||||
|
run: pnpm prepare --${{ matrix.arch }}
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
npm_config_arch: ${{ matrix.arch }}
|
npm_config_arch: ${{ matrix.arch }}
|
||||||
@ -290,7 +308,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pnpm install
|
pnpm install
|
||||||
pnpm add @mihomo-party/sysproxy-darwin-${{ matrix.arch }}
|
pnpm add @mihomo-party/sysproxy-darwin-${{ matrix.arch }}
|
||||||
pnpm prepare --${{ matrix.arch }}
|
- name: Update Version for Dev Build
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
env:
|
||||||
|
GITHUB_EVENT_NAME: workflow_dispatch
|
||||||
|
run: node scripts/update-version.mjs
|
||||||
|
- name: Prepare
|
||||||
|
run: pnpm prepare --${{ matrix.arch }}
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
npm_config_arch: ${{ matrix.arch }}
|
npm_config_arch: ${{ matrix.arch }}
|
||||||
@ -376,7 +400,13 @@ jobs:
|
|||||||
pnpm install
|
pnpm install
|
||||||
pnpm add @mihomo-party/sysproxy-darwin-${{ matrix.arch }}
|
pnpm add @mihomo-party/sysproxy-darwin-${{ matrix.arch }}
|
||||||
pnpm add -D electron@32.2.2
|
pnpm add -D electron@32.2.2
|
||||||
pnpm prepare --${{ matrix.arch }}
|
- name: Update Version for Dev Build
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
env:
|
||||||
|
GITHUB_EVENT_NAME: workflow_dispatch
|
||||||
|
run: node scripts/update-version.mjs
|
||||||
|
- name: Prepare
|
||||||
|
run: pnpm prepare --${{ matrix.arch }}
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
npm_config_arch: ${{ matrix.arch }}
|
npm_config_arch: ${{ matrix.arch }}
|
||||||
@ -451,6 +481,11 @@ jobs:
|
|||||||
run: npm install -g pnpm
|
run: npm install -g pnpm
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
- name: Update Version for Dev Build
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
env:
|
||||||
|
GITHUB_EVENT_NAME: workflow_dispatch
|
||||||
|
run: node scripts/update-version.mjs
|
||||||
- name: Telegram Notification
|
- name: Telegram Notification
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
env:
|
env:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mihomo-party",
|
"name": "mihomo-party",
|
||||||
"version": "1.8.6-dev",
|
"version": "1.8.6",
|
||||||
"description": "Clash Party",
|
"description": "Clash Party",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "mihomo-party-org",
|
"author": "mihomo-party-org",
|
||||||
@ -12,6 +12,7 @@
|
|||||||
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
|
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
|
||||||
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
||||||
"prepare": "node scripts/prepare.mjs",
|
"prepare": "node scripts/prepare.mjs",
|
||||||
|
"prepare:dev": "node scripts/update-version.mjs && node scripts/prepare.mjs",
|
||||||
"updater": "node scripts/updater.mjs",
|
"updater": "node scripts/updater.mjs",
|
||||||
"checksum": "node scripts/checksum.mjs",
|
"checksum": "node scripts/checksum.mjs",
|
||||||
"telegram": "node scripts/telegram.mjs release",
|
"telegram": "node scripts/telegram.mjs release",
|
||||||
@ -20,8 +21,11 @@
|
|||||||
"dev": "electron-vite dev",
|
"dev": "electron-vite dev",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"build:win": "electron-vite build && electron-builder --publish never --win",
|
"build:win": "electron-vite build && electron-builder --publish never --win",
|
||||||
|
"build:win:dev": "npm run prepare:dev && electron-vite build && electron-builder --publish never --win",
|
||||||
"build:mac": "electron-vite build && electron-builder --publish never --mac",
|
"build:mac": "electron-vite build && electron-builder --publish never --mac",
|
||||||
"build:linux": "electron-vite build && electron-builder --publish never --linux"
|
"build:mac:dev": "npm run prepare:dev && electron-vite build && electron-builder --publish never --mac",
|
||||||
|
"build:linux": "electron-vite build && electron-builder --publish never --linux",
|
||||||
|
"build:linux:dev": "npm run prepare:dev && electron-vite build && electron-builder --publish never --linux"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@electron-toolkit/preload": "^3.0.2",
|
"@electron-toolkit/preload": "^3.0.2",
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { readFileSync } from 'fs'
|
import { readFileSync } from 'fs'
|
||||||
|
import { getProcessedVersion, isDevBuild, getDownloadUrl, generateDownloadLinksMarkdown, getGitCommitHash } from './version-utils.mjs'
|
||||||
|
|
||||||
const chat_id = '@MihomoPartyChannel'
|
const chat_id = '@MihomoPartyChannel'
|
||||||
const pkg = readFileSync('package.json', 'utf-8')
|
const pkg = readFileSync('package.json', 'utf-8')
|
||||||
const changelog = readFileSync('changelog.md', 'utf-8')
|
const changelog = readFileSync('changelog.md', 'utf-8')
|
||||||
const { version } = JSON.parse(pkg)
|
const { version: packageVersion } = JSON.parse(pkg)
|
||||||
|
|
||||||
|
// 获取处理后的版本号
|
||||||
|
const version = getProcessedVersion()
|
||||||
const releaseType = process.env.RELEASE_TYPE || process.argv[2] || 'release'
|
const releaseType = process.env.RELEASE_TYPE || process.argv[2] || 'release'
|
||||||
const isDevRelease = releaseType === 'dev'
|
const isDevRelease = releaseType === 'dev' || isDevBuild()
|
||||||
|
|
||||||
function convertMarkdownToTelegramHTML(content) {
|
function convertMarkdownToTelegramHTML(content) {
|
||||||
return content
|
return content
|
||||||
@ -42,50 +45,34 @@ function convertMarkdownToTelegramHTML(content) {
|
|||||||
let content = '';
|
let content = '';
|
||||||
|
|
||||||
if (isDevRelease) {
|
if (isDevRelease) {
|
||||||
|
// 版本号中提取commit hash
|
||||||
const commitSha = process.env.GITHUB_SHA || 'unknown'
|
const shortCommitSha = getGitCommitHash(true)
|
||||||
const shortCommitSha = commitSha.substring(0, 7)
|
const commitSha = getGitCommitHash(false)
|
||||||
|
|
||||||
content = `<b>🚧 <a href="https://github.com/mihomo-party-org/mihomo-party/releases/tag/dev">Clash Party Dev Build</a> 开发版本发布</b>\n\n`
|
content = `<b>🚧 <a href="https://github.com/mihomo-party-org/clash-party/releases/tag/dev">Clash Party Dev Build</a> 开发版本发布</b>\n\n`
|
||||||
content += `<b>基于版本:</b> ${version}\n`
|
content += `<b>基于版本:</b> ${version}\n`
|
||||||
content += `<b>提交哈希:</b> <a href="https://github.com/mihomo-party-org/mihomo-party/commit/${commitSha}">${shortCommitSha}</a>\n\n`
|
content += `<b>提交哈希:</b> <a href="https://github.com/mihomo-party-org/clash-party/commit/${commitSha}">${shortCommitSha}</a>\n\n`
|
||||||
content += `<b>更新日志:</b>\n`
|
content += `<b>更新日志:</b>\n`
|
||||||
content += convertMarkdownToTelegramHTML(changelog)
|
content += convertMarkdownToTelegramHTML(changelog)
|
||||||
content += '\n\n<b>⚠️ 注意:这是开发版本,可能存在不稳定性,仅供测试使用</b>\n'
|
content += '\n\n<b>⚠️ 注意:这是开发版本,可能存在不稳定性,仅供测试使用</b>\n'
|
||||||
} else {
|
} else {
|
||||||
// 正式版本通知
|
// 正式版本通知
|
||||||
content = `<b>🌟 <a href="https://github.com/mihomo-party-org/mihomo-party/releases/tag/v${version}">Clash Party v${version}</a> 正式发布</b>\n\n`
|
content = `<b>🌟 <a href="https://github.com/mihomo-party-org/clash-party/releases/tag/v${version}">Clash Party v${version}</a> 正式发布</b>\n\n`
|
||||||
content += convertMarkdownToTelegramHTML(changelog)
|
content += convertMarkdownToTelegramHTML(changelog)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建下载链接
|
// 构建下载链接
|
||||||
const downloadUrl = isDevRelease
|
const downloadUrl = getDownloadUrl(isDevRelease, version)
|
||||||
? `https://github.com/mihomo-party-org/mihomo-party/releases/download/dev`
|
|
||||||
: `https://github.com/mihomo-party-org/mihomo-party/releases/download/v${version}`
|
|
||||||
|
|
||||||
content += '\n<b>下载地址:</b>\n<b>Windows10/11:</b>\n'
|
const downloadLinksMarkdown = generateDownloadLinksMarkdown(downloadUrl, version)
|
||||||
content += `安装版:<a href="${downloadUrl}/mihomo-party-windows-${version}-x64-setup.exe">64位</a> | <a href="${downloadUrl}/mihomo-party-windows-${version}-ia32-setup.exe">32位</a> | <a href="${downloadUrl}/mihomo-party-windows-${version}-arm64-setup.exe">ARM64</a>\n`
|
content += convertMarkdownToTelegramHTML(downloadLinksMarkdown)
|
||||||
content += `便携版:<a href="${downloadUrl}/mihomo-party-windows-${version}-x64-portable.7z">64位</a> | <a href="${downloadUrl}/mihomo-party-windows-${version}-ia32-portable.7z">32位</a> | <a href="${downloadUrl}/mihomo-party-windows-${version}-arm64-portable.7z">ARM64</a>\n`
|
|
||||||
content += '\n<b>Windows7/8:</b>\n'
|
|
||||||
content += `安装版:<a href="${downloadUrl}/mihomo-party-win7-${version}-x64-setup.exe">64位</a> | <a href="${downloadUrl}/mihomo-party-win7-${version}-ia32-setup.exe">32位</a>\n`
|
|
||||||
content += `便携版:<a href="${downloadUrl}/mihomo-party-win7-${version}-x64-portable.7z">64位</a> | <a href="${downloadUrl}/mihomo-party-win7-${version}-ia32-portable.7z">32位</a>\n`
|
|
||||||
content += '\n<b>macOS 11+:</b>\n'
|
|
||||||
content += `PKG:<a href="${downloadUrl}/mihomo-party-macos-${version}-x64.pkg
|
|
||||||
">Intel</a> | <a href="${downloadUrl}/mihomo-party-macos-${version}-arm64.pkg">Apple Silicon</a>\n`
|
|
||||||
content += '\n<b>macOS 10.15+:</b>\n'
|
|
||||||
content += `PKG:<a href="${downloadUrl}/mihomo-party-catalina-${version}-x64.pkg
|
|
||||||
">Intel</a> | <a href="${downloadUrl}/mihomo-party-catalina-${version}-arm64.pkg">Apple Silicon</a>\n`
|
|
||||||
content += '\n<b>Linux:</b>\n'
|
|
||||||
content += `DEB:<a href="${downloadUrl}/mihomo-party-linux-${version}-amd64.deb
|
|
||||||
">64位</a> | <a href="${downloadUrl}/mihomo-party-linux-${version}-arm64.deb">ARM64</a>\n`
|
|
||||||
content += `RPM:<a href="${downloadUrl}/mihomo-party-linux-${version}-x86_64.rpm">64位</a> | <a href="${downloadUrl}/mihomo-party-linux-${version}-aarch64.rpm">ARM64</a>`
|
|
||||||
|
|
||||||
await axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, {
|
await axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, {
|
||||||
chat_id,
|
chat_id,
|
||||||
text: content,
|
text: content,
|
||||||
link_preview_options: {
|
link_preview_options: {
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
url: 'https://github.com/mihomo-party-org/mihomo-party',
|
url: 'https://github.com/mihomo-party-org/clash-party',
|
||||||
prefer_large_media: true
|
prefer_large_media: true
|
||||||
},
|
},
|
||||||
parse_mode: 'HTML'
|
parse_mode: 'HTML'
|
||||||
|
|||||||
34
scripts/update-version.mjs
Normal file
34
scripts/update-version.mjs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { readFileSync, writeFileSync } from 'fs'
|
||||||
|
import { getProcessedVersion, isDevBuild } from './version-utils.mjs'
|
||||||
|
|
||||||
|
// 更新package.json中的版本号
|
||||||
|
function updatePackageVersion() {
|
||||||
|
try {
|
||||||
|
const packagePath = 'package.json'
|
||||||
|
const packageContent = readFileSync(packagePath, 'utf-8')
|
||||||
|
const packageData = JSON.parse(packageContent)
|
||||||
|
|
||||||
|
// 获取处理后的版本号
|
||||||
|
const newVersion = getProcessedVersion()
|
||||||
|
|
||||||
|
console.log(`当前版本: ${packageData.version}`)
|
||||||
|
console.log(`${isDevBuild() ? 'Dev构建' : '正式构建'} - 新版本: ${newVersion}`)
|
||||||
|
|
||||||
|
packageData.version = newVersion
|
||||||
|
|
||||||
|
// 写回package.json
|
||||||
|
writeFileSync(packagePath, JSON.stringify(packageData, null, 2) + '\n')
|
||||||
|
|
||||||
|
console.log(`✅ package.json版本号已更新为: ${newVersion}`)
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ 更新package.json版本号失败:', error.message)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
|
updatePackageVersion()
|
||||||
|
}
|
||||||
|
|
||||||
|
export { updatePackageVersion }
|
||||||
@ -1,28 +1,23 @@
|
|||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
import { readFileSync, writeFileSync } from 'fs'
|
import { readFileSync, writeFileSync } from 'fs'
|
||||||
|
import { getProcessedVersion, isDevBuild, getDownloadUrl, generateDownloadLinksMarkdown } from './version-utils.mjs'
|
||||||
|
|
||||||
const pkg = readFileSync('package.json', 'utf-8')
|
const pkg = readFileSync('package.json', 'utf-8')
|
||||||
let changelog = readFileSync('changelog.md', 'utf-8')
|
let changelog = readFileSync('changelog.md', 'utf-8')
|
||||||
const { version } = JSON.parse(pkg)
|
const { version: packageVersion } = JSON.parse(pkg)
|
||||||
const downloadUrl = `https://github.com/mihomo-party-org/mihomo-party/releases/download/v${version}`
|
|
||||||
|
// 获取处理后的版本号
|
||||||
|
const version = getProcessedVersion()
|
||||||
|
const isDev = isDevBuild()
|
||||||
|
const downloadUrl = getDownloadUrl(isDev, version)
|
||||||
|
|
||||||
const latest = {
|
const latest = {
|
||||||
version,
|
version,
|
||||||
changelog
|
changelog
|
||||||
}
|
}
|
||||||
|
|
||||||
changelog += '\n### 下载地址:\n\n#### Windows10/11:\n\n'
|
// 使用统一的下载链接生成函数
|
||||||
changelog += `- 安装版:[64位](${downloadUrl}/mihomo-party-windows-${version}-x64-setup.exe) | [32位](${downloadUrl}/mihomo-party-windows-${version}-ia32-setup.exe) | [ARM64](${downloadUrl}/mihomo-party-windows-${version}-arm64-setup.exe)\n\n`
|
changelog += generateDownloadLinksMarkdown(downloadUrl, version)
|
||||||
changelog += `- 便携版:[64位](${downloadUrl}/mihomo-party-windows-${version}-x64-portable.7z) | [32位](${downloadUrl}/mihomo-party-windows-${version}-ia32-portable.7z) | [ARM64](${downloadUrl}/mihomo-party-windows-${version}-arm64-portable.7z)\n\n`
|
|
||||||
changelog += '\n#### Windows7/8:\n\n'
|
|
||||||
changelog += `- 安装版:[64位](${downloadUrl}/mihomo-party-win7-${version}-x64-setup.exe) | [32位](${downloadUrl}/mihomo-party-win7-${version}-ia32-setup.exe)\n\n`
|
|
||||||
changelog += `- 便携版:[64位](${downloadUrl}/mihomo-party-win7-${version}-x64-portable.7z) | [32位](${downloadUrl}/mihomo-party-win7-${version}-ia32-portable.7z)\n\n`
|
|
||||||
changelog += '\n#### macOS 11+:\n\n'
|
|
||||||
changelog += `- PKG:[Intel](${downloadUrl}/mihomo-party-macos-${version}-x64.pkg) | [Apple Silicon](${downloadUrl}/mihomo-party-macos-${version}-arm64.pkg)\n\n`
|
|
||||||
changelog += '\n#### macOS 10.15+:\n\n'
|
|
||||||
changelog += `- PKG:[Intel](${downloadUrl}/mihomo-party-catalina-${version}-x64.pkg) | [Apple Silicon](${downloadUrl}/mihomo-party-catalina-${version}-arm64.pkg)\n\n`
|
|
||||||
changelog += '\n#### Linux:\n\n'
|
|
||||||
changelog += `- DEB:[64位](${downloadUrl}/mihomo-party-linux-${version}-amd64.deb) | [ARM64](${downloadUrl}/mihomo-party-linux-${version}-arm64.deb)\n\n`
|
|
||||||
changelog += `- RPM:[64位](${downloadUrl}/mihomo-party-linux-${version}-x86_64.rpm) | [ARM64](${downloadUrl}/mihomo-party-linux-${version}-aarch64.rpm)`
|
|
||||||
|
|
||||||
changelog += '\n\n### 机场推荐:\n- 高性能海外机场,稳定首选:[https://狗狗加速.com](https://party.dginv.click/#/register?code=ARdo0mXx)'
|
changelog += '\n\n### 机场推荐:\n- 高性能海外机场,稳定首选:[https://狗狗加速.com](https://party.dginv.click/#/register?code=ARdo0mXx)'
|
||||||
|
|
||||||
|
|||||||
86
scripts/version-utils.mjs
Normal file
86
scripts/version-utils.mjs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
import { execSync } from 'child_process'
|
||||||
|
import { readFileSync } from 'fs'
|
||||||
|
|
||||||
|
// 获取Git commit hash
|
||||||
|
export function getGitCommitHash(short = true) {
|
||||||
|
try {
|
||||||
|
const command = short ? 'git rev-parse --short HEAD' : 'git rev-parse HEAD'
|
||||||
|
return execSync(command, { encoding: 'utf-8' }).trim()
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to get git commit hash:', error.message)
|
||||||
|
return 'unknown'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前月份日期
|
||||||
|
export function getCurrentMonthDate() {
|
||||||
|
const now = new Date()
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(now.getDate()).padStart(2, '0')
|
||||||
|
return `${month}${day}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从package.json读取基础版本号
|
||||||
|
export function getBaseVersion() {
|
||||||
|
try {
|
||||||
|
const pkg = readFileSync('package.json', 'utf-8')
|
||||||
|
const { version } = JSON.parse(pkg)
|
||||||
|
// 移除dev版本格式后缀
|
||||||
|
return version.replace('-dev', '').replace(/-\d{4}-[a-f0-9]{7}$/, '')
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to read package.json:', error.message)
|
||||||
|
return '1.0.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成dev版本号
|
||||||
|
export function getDevVersion() {
|
||||||
|
const baseVersion = getBaseVersion()
|
||||||
|
const monthDate = getCurrentMonthDate()
|
||||||
|
const commitHash = getGitCommitHash(true)
|
||||||
|
|
||||||
|
return `${baseVersion}-${monthDate}-${commitHash}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查当前环境是否为dev构建
|
||||||
|
export function isDevBuild() {
|
||||||
|
return process.env.NODE_ENV === 'development' ||
|
||||||
|
process.argv.includes('--dev') ||
|
||||||
|
process.env.GITHUB_EVENT_NAME === 'workflow_dispatch'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取处理后的版本号
|
||||||
|
export function getProcessedVersion() {
|
||||||
|
if (isDevBuild()) {
|
||||||
|
return getDevVersion()
|
||||||
|
} else {
|
||||||
|
return getBaseVersion()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成下载URL
|
||||||
|
export function getDownloadUrl(isDev, version) {
|
||||||
|
if (isDev) {
|
||||||
|
return 'https://github.com/mihomo-party-org/clash-party/releases/download/dev'
|
||||||
|
} else {
|
||||||
|
return `https://github.com/mihomo-party-org/clash-party/releases/download/v${version}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function generateDownloadLinksMarkdown(downloadUrl, version) {
|
||||||
|
let links = '\n### 下载地址:\n\n#### Windows10/11:\n\n'
|
||||||
|
links += `- 安装版:[64位](${downloadUrl}/clash-party-windows-${version}-x64-setup.exe) | [32位](${downloadUrl}/clash-party-windows-${version}-ia32-setup.exe) | [ARM64](${downloadUrl}/clash-party-windows-${version}-arm64-setup.exe)\n\n`
|
||||||
|
links += `- 便携版:[64位](${downloadUrl}/clash-party-windows-${version}-x64-portable.7z) | [32位](${downloadUrl}/clash-party-windows-${version}-ia32-portable.7z) | [ARM64](${downloadUrl}/clash-party-windows-${version}-arm64-portable.7z)\n\n`
|
||||||
|
links += '\n#### Windows7/8:\n\n'
|
||||||
|
links += `- 安装版:[64位](${downloadUrl}/clash-party-win7-${version}-x64-setup.exe) | [32位](${downloadUrl}/clash-party-win7-${version}-ia32-setup.exe)\n\n`
|
||||||
|
links += `- 便携版:[64位](${downloadUrl}/clash-party-win7-${version}-x64-portable.7z) | [32位](${downloadUrl}/clash-party-win7-${version}-ia32-portable.7z)\n\n`
|
||||||
|
links += '\n#### macOS 11+:\n\n'
|
||||||
|
links += `- PKG:[Intel](${downloadUrl}/clash-party-macos-${version}-x64.pkg) | [Apple Silicon](${downloadUrl}/clash-party-macos-${version}-arm64.pkg)\n\n`
|
||||||
|
links += '\n#### macOS 10.15+:\n\n'
|
||||||
|
links += `- PKG:[Intel](${downloadUrl}/clash-party-catalina-${version}-x64.pkg) | [Apple Silicon](${downloadUrl}/clash-party-catalina-${version}-arm64.pkg)\n\n`
|
||||||
|
links += '\n#### Linux:\n\n'
|
||||||
|
links += `- DEB:[64位](${downloadUrl}/clash-party-linux-${version}-amd64.deb) | [ARM64](${downloadUrl}/clash-party-linux-${version}-arm64.deb)\n\n`
|
||||||
|
links += `- RPM:[64位](${downloadUrl}/clash-party-linux-${version}-x86_64.rpm) | [ARM64](${downloadUrl}/clash-party-linux-${version}-aarch64.rpm)`
|
||||||
|
|
||||||
|
return links
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user