mirror of
https://github.com/certd/certd.git
synced 2026-04-03 14:10:54 +08:00
perf: 优化源码方式部署,前端无需编译
This commit is contained in:
56
.github/workflows/publish-atom.yaml
vendored
Normal file
56
.github/workflows/publish-atom.yaml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: publish-atomgit
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['v2-dev']
|
||||||
|
paths:
|
||||||
|
- "trigger/publish.trigger"
|
||||||
|
# workflow_run:
|
||||||
|
# workflows: [ "deploy-demo" ]
|
||||||
|
# types:
|
||||||
|
# - completed
|
||||||
|
|
||||||
|
# schedule:
|
||||||
|
# - # 国际时间 19:17 执行,北京时间3:17 ↙↙↙ 改成你想要每天自动执行的时间
|
||||||
|
# - cron: '17 19 * * *'
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish-atomgit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
lfs: true
|
||||||
|
|
||||||
|
- name: get_certd_version
|
||||||
|
id: get_certd_version
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
with:
|
||||||
|
result-encoding: string
|
||||||
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const pnpmWorkspace = "./pnpm-workspace.yaml";
|
||||||
|
fs.unlinkSync(pnpmWorkspace)
|
||||||
|
const jsonFilePath = "./packages/ui/certd-server/package.json";
|
||||||
|
const jsonContent = fs.readFileSync(jsonFilePath, 'utf-8');
|
||||||
|
const pkg = JSON.parse(jsonContent)
|
||||||
|
console.log("certd_version:",pkg.version);
|
||||||
|
return pkg.version
|
||||||
|
|
||||||
|
- name: zip_front
|
||||||
|
id: zip_front
|
||||||
|
run: |
|
||||||
|
rm -rf ./packages/ui/certd-client/dist/**/*.gz
|
||||||
|
zip -r ui.zip ./packages/ui/certd-client/dist
|
||||||
|
|
||||||
|
- name: publish_to_atomgit
|
||||||
|
id: publish_to_atomgit
|
||||||
|
run: |
|
||||||
|
export ATOMGIT_TOKEN=${{ secrets.ATOMGIT_TOKEN }}
|
||||||
|
npm run publish_to_atomgit
|
||||||
|
working-directory: ./
|
||||||
2
.github/workflows/release-image.yml
vendored
2
.github/workflows/release-image.yml
vendored
@@ -130,4 +130,4 @@ jobs:
|
|||||||
headers: |
|
headers: |
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
retry-count: 3
|
retry-count: 3
|
||||||
retry-delay: 5000
|
retry-delay: 5000
|
||||||
2
.npmrc
2
.npmrc
@@ -3,4 +3,4 @@ prefer-workspace-packages=true
|
|||||||
better_sqlite3_binary_host=https://registry.npmmirror.com/-/binary/better-sqlite3
|
better_sqlite3_binary_host=https://registry.npmmirror.com/-/binary/better-sqlite3
|
||||||
better_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/better-sqlite3
|
better_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/better-sqlite3
|
||||||
better-sqlite3_binary_host=https://registry.npmmirror.com/-/binary/better-sqlite3
|
better-sqlite3_binary_host=https://registry.npmmirror.com/-/binary/better-sqlite3
|
||||||
better-sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/better-sqlite3
|
better-sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/better-sqlite3
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
"prepublishOnly1": "npm run check && lerna run build ",
|
"prepublishOnly1": "npm run check && lerna run build ",
|
||||||
"prepublishOnly2": "npm run check && npm run before-build && lerna run build ",
|
"prepublishOnly2": "npm run check && npm run before-build && lerna run build ",
|
||||||
"before-build": "npm run transform-sql && cd ./packages/core/basic && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\"",
|
"before-build": "npm run transform-sql && cd ./packages/core/basic && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\"",
|
||||||
"deploy1": "node --experimental-json-modules deploy.js ",
|
"deploy1": "node --experimental-json-modules ./scripts/deploy.js ",
|
||||||
"check": "node --experimental-json-modules publish-check.js",
|
"check": "node --experimental-json-modules ./scripts/publish-check.js",
|
||||||
"init": "lerna run build",
|
"init": "lerna run build",
|
||||||
"init:dev": "lerna run build",
|
"init:dev": "lerna run build",
|
||||||
"docs:dev": "vitepress dev docs",
|
"docs:dev": "vitepress dev docs",
|
||||||
@@ -36,7 +36,9 @@
|
|||||||
"docs:preview": "vitepress preview docs",
|
"docs:preview": "vitepress preview docs",
|
||||||
"pub": "echo 1",
|
"pub": "echo 1",
|
||||||
"dev": "pnpm run -r --parallel compile ",
|
"dev": "pnpm run -r --parallel compile ",
|
||||||
"release": "time /t >trigger/release.trigger && git add trigger/release.trigger && git commit -m \"build: release\" && git push"
|
"release": "time /t >trigger/release.trigger && git add trigger/release.trigger && git commit -m \"build: release\" && git push",
|
||||||
|
"publish_to_atomgit": "node --experimental-json-modules ./scripts/publish-atomgit.js",
|
||||||
|
"get_version": "node --experimental-json-modules ./scripts/version.js"
|
||||||
},
|
},
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export default {
|
|||||||
vip_group_priority: "可加VIP群,您的需求将优先实现",
|
vip_group_priority: "可加VIP群,您的需求将优先实现",
|
||||||
unlimited_site_certificate_monitoring: "站点证书监控无限制",
|
unlimited_site_certificate_monitoring: "站点证书监控无限制",
|
||||||
more_notification_methods: "更多通知方式",
|
more_notification_methods: "更多通知方式",
|
||||||
plugins_fully_open: "插件全开放,群辉等更多插件",
|
plugins_fully_open: "插件全开放,群晖等更多插件",
|
||||||
click_to_get_7_day_trial: "点击获取7天试用",
|
click_to_get_7_day_trial: "点击获取7天试用",
|
||||||
years: "年",
|
years: "年",
|
||||||
afdian_support_vip: "新用户开通永久专业版立享50优惠券",
|
afdian_support_vip: "新用户开通永久专业版立享50优惠券",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import http from 'axios'
|
import http from 'axios'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
//读取 packages/core/pipline/package.json的版本号
|
//读取 packages/core/pipline/package.json的版本号
|
||||||
import {default as packageJson} from './packages/core/pipeline/package.json' assert { type: "json" };
|
import {default as packageJson} from '../packages/core/pipeline/package.json' assert { type: "json" };
|
||||||
|
|
||||||
const certdVersion = packageJson.version
|
const certdVersion = packageJson.version
|
||||||
console.log("certdVersion", certdVersion)
|
console.log("certdVersion", certdVersion)
|
||||||
181
scripts/publish-atomgit.js
Normal file
181
scripts/publish-atomgit.js
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
import fs from 'fs'
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
|
||||||
|
const AtomgitAccessToken = process.env.ATOMGIT_TOKEN
|
||||||
|
// CHANGELOG.md
|
||||||
|
const changelog = fs.readFileSync('./CHANGELOG.md', 'utf8')
|
||||||
|
// 解析CHANGELOG.md
|
||||||
|
let lines = changelog.split('\n')
|
||||||
|
const versionLineIndex = lines.findIndex(line => line.startsWith('## '))
|
||||||
|
const versionLine = lines[versionLineIndex]
|
||||||
|
// ## [1.37.16](https://github.com/certd/certd/compare/v1.37.15...v1.37.16) (2025-12-15)
|
||||||
|
const versionTitle = versionLine.match(/\[(.*?)\]/)[1]
|
||||||
|
|
||||||
|
const contentStart = versionLineIndex + 1
|
||||||
|
lines = lines.slice(contentStart)
|
||||||
|
const contentEnd = lines.findIndex(line => {
|
||||||
|
return line.startsWith('## ')
|
||||||
|
})
|
||||||
|
const content = lines.slice(0, contentEnd).join('\n')
|
||||||
|
console.log("-------title------/n")
|
||||||
|
console.log(versionTitle)
|
||||||
|
console.log("-------content------/n")
|
||||||
|
console.log(content)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建仓库Release
|
||||||
|
POST
|
||||||
|
https://api.atomgit.com/api/v5/repos/:owner/:repo/releases
|
||||||
|
Request
|
||||||
|
Path Parameters
|
||||||
|
owner
|
||||||
|
string
|
||||||
|
required
|
||||||
|
仓库所属空间地址(企业、组织或个人的地址path)
|
||||||
|
|
||||||
|
repo
|
||||||
|
string
|
||||||
|
required
|
||||||
|
仓库路径
|
||||||
|
|
||||||
|
Query Parameters
|
||||||
|
access_token
|
||||||
|
string
|
||||||
|
required
|
||||||
|
用户授权码
|
||||||
|
|
||||||
|
application/json
|
||||||
|
Body
|
||||||
|
tag_name
|
||||||
|
string
|
||||||
|
required
|
||||||
|
tag名称
|
||||||
|
|
||||||
|
name
|
||||||
|
string
|
||||||
|
required
|
||||||
|
release名称
|
||||||
|
|
||||||
|
body
|
||||||
|
string
|
||||||
|
required
|
||||||
|
release描述
|
||||||
|
|
||||||
|
target_commitish
|
||||||
|
string
|
||||||
|
分支名称或者commit SHA,如果tag不存在,需要新建tag则传入该参数,如果不传入该参数,则为默认分支的最新提交
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 创建release
|
||||||
|
async function createRelease() {
|
||||||
|
const response = await axios.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: `https://api.atomgit.com/api/v5/repos/certd/certd/releases`,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
access_token: AtomgitAccessToken
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
tag_name: `v${versionTitle}`,
|
||||||
|
name: `v${versionTitle}`,
|
||||||
|
body: content,
|
||||||
|
target_commitish: 'v2'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
console.log("createRelease success")
|
||||||
|
return response.data
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Release附件上传地址
|
||||||
|
GET
|
||||||
|
https://api.atomgit.com/api/v5/repos/:owner/:repo/releases/:tag/upload_url
|
||||||
|
Request
|
||||||
|
Path Parameters
|
||||||
|
owner
|
||||||
|
string
|
||||||
|
required
|
||||||
|
仓库所属空间地址(企业、组织或个人的地址path)
|
||||||
|
|
||||||
|
repo
|
||||||
|
string
|
||||||
|
required
|
||||||
|
仓库路径
|
||||||
|
|
||||||
|
tag
|
||||||
|
string
|
||||||
|
required
|
||||||
|
tag名称
|
||||||
|
|
||||||
|
Query Parameters
|
||||||
|
access_token
|
||||||
|
string
|
||||||
|
required
|
||||||
|
用户授权码
|
||||||
|
|
||||||
|
file_name
|
||||||
|
string
|
||||||
|
required
|
||||||
|
要上传的文件名称
|
||||||
|
|
||||||
|
Responses
|
||||||
|
200
|
||||||
|
Response Headers
|
||||||
|
application/json
|
||||||
|
Schema
|
||||||
|
Example (auto)
|
||||||
|
Schema
|
||||||
|
url
|
||||||
|
string
|
||||||
|
required
|
||||||
|
上传的地址,使用put请求
|
||||||
|
|
||||||
|
headers
|
||||||
|
object
|
||||||
|
|
||||||
|
*/
|
||||||
|
async function getUploadUrl() {
|
||||||
|
const response = await axios.request({
|
||||||
|
method: 'GET',
|
||||||
|
url: `https://api.atomgit.com/api/v5/repos/certd/certd/releases/v${versionTitle}/upload_url`,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
access_token: AtomgitAccessToken,
|
||||||
|
file_name: `ui-${versionTitle}.zip`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
console.log("getUploadUrl success:",response.data?.url)
|
||||||
|
return response.data // {url: string, headers: any}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadFile(url, headers, data) {
|
||||||
|
const response = await axios.request({
|
||||||
|
method: 'PUT',
|
||||||
|
url,
|
||||||
|
headers,
|
||||||
|
data,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return response.data
|
||||||
|
}
|
||||||
|
|
||||||
|
async function publishToAtomgit() {
|
||||||
|
const release = await createRelease()
|
||||||
|
const uploadUrl = await getUploadUrl()
|
||||||
|
const fileName = `ui.zip`
|
||||||
|
const fileData = fs.createReadStream(fileName)
|
||||||
|
const contentLength = fs.statSync(fileName).size
|
||||||
|
uploadUrl.headers['Content-Length'] = contentLength
|
||||||
|
const response = await uploadFile(uploadUrl.url, uploadUrl.headers, fileData)
|
||||||
|
console.log("uploadFile success:")
|
||||||
|
console.log("publishToAtomgit success")
|
||||||
|
}
|
||||||
|
|
||||||
|
publishToAtomgit()
|
||||||
3
scripts/version.js
Normal file
3
scripts/version.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import fs from 'fs'
|
||||||
|
const pkg = JSON.parse(fs.readFileSync('./packages/ui/certd-server/package.json'))
|
||||||
|
console.log(pkg.version)
|
||||||
32
start.sh
32
start.sh
@@ -18,10 +18,10 @@ fi
|
|||||||
# fi
|
# fi
|
||||||
# find ./packages -mindepth 1 -maxdepth 1 -type d ! -name 'ui' -exec rm -rf {} +
|
# find ./packages -mindepth 1 -maxdepth 1 -type d ! -name 'ui' -exec rm -rf {} +
|
||||||
# echo "删除成功"
|
# echo "删除成功"
|
||||||
|
echo "修改 pnpm-workspace.yaml"
|
||||||
cat > pnpm-workspace.yaml << EOF
|
cat > pnpm-workspace.yaml << EOF
|
||||||
packages:
|
packages:
|
||||||
- 'packages/ui/**'
|
- 'packages/ui/certd-server'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
@@ -43,17 +43,31 @@ $SUDO_CMD npm install -g pnpm --registry https://registry.npmmirror.com
|
|||||||
echo "安装依赖"
|
echo "安装依赖"
|
||||||
$SUDO_CMD pnpm install --registry https://registry.npmmirror.com
|
$SUDO_CMD pnpm install --registry https://registry.npmmirror.com
|
||||||
|
|
||||||
echo "开始构建"
|
|
||||||
echo "构建certd-client"
|
|
||||||
export NODE_OPTIONS=--max-old-space-size=32768
|
|
||||||
cd packages/ui/certd-client
|
|
||||||
$SUDO_CMD_E pnpm run build
|
|
||||||
cp -r dist/* ../certd-server/public
|
|
||||||
|
|
||||||
|
# 获取版本号
|
||||||
|
version=$(node --experimental-json-modules ./scripts/version.js)
|
||||||
|
echo "当前版本号为: $version"
|
||||||
|
|
||||||
|
echo "开始构建"
|
||||||
|
cd packages/ui/certd-server
|
||||||
echo "构建certd-server"
|
echo "构建certd-server"
|
||||||
cd ../certd-server
|
|
||||||
$SUDO_CMD_E pnpm run build
|
$SUDO_CMD_E pnpm run build
|
||||||
echo "构建完成"
|
echo "构建完成"
|
||||||
|
|
||||||
|
|
||||||
|
echo "下载前端ui"
|
||||||
|
# 如果zip有了就不下载
|
||||||
|
if [ -f ui-$version.zip ]; then
|
||||||
|
echo "ui-$version.zip 已经存在,不需要下载"
|
||||||
|
else
|
||||||
|
# 下载之前清理一下
|
||||||
|
rm -rf ui-*.zip
|
||||||
|
# https://atomgit.com/certd/certd/releases/download/v1.37.16/ui-1.37.16.zip
|
||||||
|
# 判断是否下载失败
|
||||||
|
wget https://atomgit.com/certd/certd/releases/download/v$version/ui-$version.zip
|
||||||
|
# 覆盖解压缩
|
||||||
|
unzip -o ui-$version.zip -d ./public
|
||||||
|
|
||||||
echo "启动服务"
|
echo "启动服务"
|
||||||
|
|
||||||
# 前台运行
|
# 前台运行
|
||||||
|
|||||||
1
trigger/publish.trigger
Normal file
1
trigger/publish.trigger
Normal file
@@ -0,0 +1 @@
|
|||||||
|
4
|
||||||
Reference in New Issue
Block a user