chore: gitea actions
This commit is contained in:
60
.gitea/actions/get-version/action.yaml
Normal file
60
.gitea/actions/get-version/action.yaml
Normal file
@@ -0,0 +1,60 @@
|
||||
name: Get Version
|
||||
description: 从 package.json 读取版本号,与最新 tag 对比决定使用哪个版本
|
||||
|
||||
outputs:
|
||||
version:
|
||||
description: 最终确定的版本号 (带 v 前缀)
|
||||
value: ${{ steps.get_version.outputs.version }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Get version from package.json
|
||||
id: get_version
|
||||
shell: bash
|
||||
run: |
|
||||
PKG_VERSION=$(node -p "require('./package.json').version")
|
||||
echo "Package.json version: ${PKG_VERSION}"
|
||||
|
||||
# 获取最新的tag(按版本号排序)
|
||||
LATEST_TAG=$(git ls-remote --tags origin 'refs/tags/v*' 2>/dev/null | sed 's/.*refs\/tags\///' | sed 's/\^{}//' | sort -V | tail -n 1 || echo "")
|
||||
echo "Latest tag: ${LATEST_TAG}"
|
||||
|
||||
# 版本比较函数
|
||||
version_compare() {
|
||||
# 返回: 0 = 相等, 1 = v1 > v2, 2 = v1 < v2
|
||||
if [[ "$1" == "$2" ]]; then echo 0; return; fi
|
||||
local IFS=.
|
||||
local i v1=($1) v2=($2)
|
||||
for ((i=0; i<${#v1[@]} || i<${#v2[@]}; i++)); do
|
||||
local n1=${v1[i]:-0} n2=${v2[i]:-0}
|
||||
if ((n1 > n2)); then echo 1; return; fi
|
||||
if ((n1 < n2)); then echo 2; return; fi
|
||||
done
|
||||
echo 0
|
||||
}
|
||||
|
||||
if [[ -z "${LATEST_TAG}" ]]; then
|
||||
# 没有任何tag,直接使用package.json版本
|
||||
NEW_TAG="v${PKG_VERSION}"
|
||||
echo "No existing tags, using package.json version: ${NEW_TAG}"
|
||||
else
|
||||
# 去掉v前缀进行比较
|
||||
LATEST_VERSION="${LATEST_TAG#v}"
|
||||
COMPARE_RESULT=$(version_compare "${PKG_VERSION}" "${LATEST_VERSION}")
|
||||
|
||||
if [[ "${COMPARE_RESULT}" == "1" ]]; then
|
||||
# package.json版本更大,使用它
|
||||
NEW_TAG="v${PKG_VERSION}"
|
||||
echo "Package.json version is greater, using: ${NEW_TAG}"
|
||||
else
|
||||
# 最新tag版本更大或相等,在其基础上递增patch
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "${LATEST_VERSION}"
|
||||
PATCH=$((PATCH + 1))
|
||||
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"
|
||||
echo "Incrementing from latest tag, new version: ${NEW_TAG}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "version=${NEW_TAG}" >> $GITHUB_OUTPUT
|
||||
echo "Final Version: ${NEW_TAG}"
|
||||
124
.gitea/actions/wecom-notification/action.yaml
Normal file
124
.gitea/actions/wecom-notification/action.yaml
Normal file
@@ -0,0 +1,124 @@
|
||||
name: WeChat Work Notification
|
||||
description: 发送企业微信群机器人通知
|
||||
author: Your Team
|
||||
|
||||
inputs:
|
||||
webhook_url:
|
||||
description: 企业微信群机器人 Webhook URL
|
||||
required: true
|
||||
status:
|
||||
description: 构建状态 (success/failure/cancelled)
|
||||
required: true
|
||||
default: success
|
||||
title:
|
||||
description: 通知标题
|
||||
required: true
|
||||
repository:
|
||||
description: 仓库名称
|
||||
required: false
|
||||
default: ${{ github.repository }}
|
||||
branch:
|
||||
description: 分支名称
|
||||
required: false
|
||||
default: ''
|
||||
version:
|
||||
description: 版本号
|
||||
required: false
|
||||
default: ''
|
||||
actor:
|
||||
description: 构建触发人
|
||||
required: false
|
||||
default: ${{ github.actor }}
|
||||
run_number:
|
||||
description: 运行序号
|
||||
required: false
|
||||
default: ${{ github.run_number }}
|
||||
run_url:
|
||||
description: 运行详情 URL
|
||||
required: false
|
||||
default: ''
|
||||
failed_step:
|
||||
description: 失败的步骤名称
|
||||
required: false
|
||||
default: ''
|
||||
extra_content:
|
||||
description: 额外的通知内容 (markdown 格式)
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Send WeChat Work Notification
|
||||
shell: bash
|
||||
run: |
|
||||
# 设置状态图标和文本
|
||||
if [ "${{ inputs.status }}" = "success" ]; then
|
||||
STATUS_ICON="✅"
|
||||
STATUS_TEXT="成功"
|
||||
elif [ "${{ inputs.status }}" = "cancelled" ]; then
|
||||
STATUS_ICON="⚠️"
|
||||
STATUS_TEXT="已取消"
|
||||
else
|
||||
STATUS_ICON="❌"
|
||||
STATUS_TEXT="失败"
|
||||
fi
|
||||
|
||||
# 构建通知内容
|
||||
CONTENT="## ${STATUS_ICON} ${{ inputs.title }} ${STATUS_TEXT}"
|
||||
|
||||
# 添加仓库信息
|
||||
if [ -n "${{ inputs.repository }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **仓库**: ${{ inputs.repository }}"
|
||||
fi
|
||||
|
||||
# 添加分支信息
|
||||
if [ -n "${{ inputs.branch }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **分支**: ${{ inputs.branch }}"
|
||||
fi
|
||||
|
||||
# 添加版本信息
|
||||
if [ -n "${{ inputs.version }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **版本**: ${{ inputs.version }}"
|
||||
fi
|
||||
|
||||
# 添加构建人
|
||||
if [ -n "${{ inputs.actor }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **构建人**: ${{ inputs.actor }}"
|
||||
fi
|
||||
|
||||
# 添加运行序号
|
||||
if [ -n "${{ inputs.run_number }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **运行序号**: #${{ inputs.run_number }}"
|
||||
fi
|
||||
|
||||
# 添加失败步骤信息
|
||||
if [ -n "${{ inputs.failed_step }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **失败步骤**: ${{ inputs.failed_step }}"
|
||||
fi
|
||||
|
||||
# 添加额外内容
|
||||
if [ -n "${{ inputs.extra_content }}" ]; then
|
||||
CONTENT="${CONTENT}\n> ${{ inputs.extra_content }}"
|
||||
fi
|
||||
|
||||
# 添加查看详情链接
|
||||
if [ -n "${{ inputs.run_url }}" ]; then
|
||||
CONTENT="${CONTENT}\n> [查看详情](${{ inputs.run_url }})"
|
||||
fi
|
||||
|
||||
echo "========== 企业微信通知 =========="
|
||||
echo "状态: ${STATUS_ICON} ${STATUS_TEXT}"
|
||||
echo "标题: ${{ inputs.title }}"
|
||||
echo "Webhook URL: ${{ inputs.webhook_url }}"
|
||||
echo "=================================="
|
||||
|
||||
# 发送通知
|
||||
curl -s -X POST "${{ inputs.webhook_url }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"msgtype\": \"markdown\",
|
||||
\"markdown\": {
|
||||
\"content\": \"${CONTENT}\"
|
||||
}
|
||||
}"
|
||||
58
.gitea/workflows/deploy-dev.yaml
Normal file
58
.gitea/workflows/deploy-dev.yaml
Normal file
@@ -0,0 +1,58 @@
|
||||
name: Deploy Dev
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
# 分支
|
||||
target_branch:
|
||||
description: 请输入要发布的分支名称
|
||||
required: true
|
||||
default: dev
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: node-22
|
||||
|
||||
steps:
|
||||
- uses: https://gitee.com/youtellme/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.target_branch }}
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup pnpm
|
||||
id: setup_pnpm
|
||||
uses: https://gitee.com/youtellme/pnpm-action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install dependencies
|
||||
id: install
|
||||
run: |
|
||||
rm -rf pnpm-lock.yaml node_modules
|
||||
pnpm install
|
||||
|
||||
- run: pnpm run build:web
|
||||
|
||||
# 压缩 dist 文件夹
|
||||
- name: zip dist folder
|
||||
run: |
|
||||
TIMESTAMP=$(date +%Y%m%d%H%M%S)
|
||||
BRANCH_NAME="${{ inputs.target_branch }}"
|
||||
SAFE_BRANCH_NAME="${BRANCH_NAME//\//_}"
|
||||
mkdir -p zip-output
|
||||
zip -r -q zip-output/cslab-dcs-web_${SAFE_BRANCH_NAME}_${TIMESTAMP}.zip apps/web/dist/
|
||||
ls -lh zip-output/
|
||||
|
||||
# 上传 zip 文件到 RustFS
|
||||
- name: Upload zip to RustFS (S3)
|
||||
uses: jakejarvis/s3-sync-action@master
|
||||
with:
|
||||
args: --acl public-read
|
||||
env:
|
||||
AWS_S3_BUCKET: ${{ vars.RUSTFS_AWS_S3_BUCKET }}
|
||||
AWS_ACCESS_KEY_ID: ${{ vars.RUSTFS_ACCESS_KEY }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ vars.RUSTFS_SECRET_KEY }}
|
||||
AWS_REGION: us-east-1
|
||||
AWS_S3_ENDPOINT: ${{ vars.RUSTFS_AWS_S3_ENDPOINT }}
|
||||
SOURCE_DIR: zip-output
|
||||
@@ -8,7 +8,7 @@ const coreRoot = resolve(__dirname, '../../packages/core')
|
||||
export default defineConfig({
|
||||
...createSharedViteConfig(coreRoot),
|
||||
root: __dirname,
|
||||
base: './', // 确保相对路径,方便部署
|
||||
base: '/dcs-web/', // 确保相对路径,方便部署
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
emptyOutDir: true,
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ElConfigProvider } from 'element-plus'
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
|
||||
const locale = zhCn
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="locale">
|
||||
<ElConfigProvider :locale="zhCn">
|
||||
<router-view />
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
3
packages/core/src/layout/online-layout.vue
Normal file
3
packages/core/src/layout/online-layout.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<div>在线版</div>
|
||||
</template>
|
||||
0
packages/core/src/layout/stand-alone.vue
Normal file
0
packages/core/src/layout/stand-alone.vue
Normal file
@@ -5,14 +5,14 @@ const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: () => import('../views/Home.vue'),
|
||||
component: () => import('../views/index.vue'),
|
||||
meta: { title: '首页' },
|
||||
},
|
||||
// 可以添加更多路由
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(), // 使用 Hash 模式兼容 Electron
|
||||
history: createWebHashHistory('/dcs-web'), // 使用 Hash 模式兼容 Electron
|
||||
routes,
|
||||
})
|
||||
|
||||
|
||||
95
packages/core/src/views/index.vue
Normal file
95
packages/core/src/views/index.vue
Normal file
@@ -0,0 +1,95 @@
|
||||
<script setup lang="ts">
|
||||
import type { IPlatformBridge } from '@cslab-dcs/bridge'
|
||||
import { bridge as defaultBridge } from '@cslab-dcs/bridge'
|
||||
import { inject, onMounted, ref } from 'vue'
|
||||
|
||||
const platformInfo = ref<any>(null)
|
||||
const appVersion = ref('')
|
||||
|
||||
const bridge = inject<IPlatformBridge>('bridge', defaultBridge)
|
||||
|
||||
onMounted(async () => {
|
||||
platformInfo.value = await bridge.system.getPlatformInfo()
|
||||
appVersion.value = await bridge.system.getAppVersion()
|
||||
})
|
||||
|
||||
async function handleOpenFile() {
|
||||
const result = await bridge.file.openDialog({
|
||||
title: '打开配置',
|
||||
filters: [{ name: 'JSON', extensions: ['json'] }],
|
||||
})
|
||||
if (result) {
|
||||
await bridge.dialog.message({
|
||||
title: '选择文件',
|
||||
message: `你选择了: ${Array.isArray(result) ? result.join(', ') : result}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function handleGreet() {
|
||||
bridge.dialog.message({
|
||||
title: 'Hello',
|
||||
message: `Welcome to DCS Editor on ${platformInfo.value?.name}`,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="home-container">
|
||||
<div class="content">
|
||||
<h1>DCS Editor ({{ platformInfo?.name || 'Loading...' }})</h1>
|
||||
<p>Version: {{ appVersion }}</p>
|
||||
|
||||
<div class="card">
|
||||
<el-button type="primary" @click="handleGreet">
|
||||
打招呼
|
||||
</el-button>
|
||||
<el-button type="success" @click="handleOpenFile">
|
||||
打开文件
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div class="debug-info">
|
||||
<h3>Platform Info:</h3>
|
||||
<pre>{{ JSON.stringify(platformInfo, null, 2) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.home-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
|
||||
.content {
|
||||
text-align: center;
|
||||
background: white;
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||
|
||||
.card {
|
||||
margin: 20px 0;
|
||||
gap: 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.debug-info {
|
||||
margin-top: 20px;
|
||||
text-align: left;
|
||||
background: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
3
packages/core/src/views/online/index.vue
Normal file
3
packages/core/src/views/online/index.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<div>在线版</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user