Skip to content

Commit 2a54e16

Browse files
committed
feat/document
2 parents 51a763f + b8ca174 commit 2a54e16

587 files changed

Lines changed: 42985 additions & 11954 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codecheck/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ tool_params:
88
secsolar:
99
source_dir: ./
1010
cmetrics:
11-
exclude: vite.config.js|package.json|index.js|axios.js|.eslintrc.js|mockServer|packages/vue-generator/test|packages/vue-generator/src/templates|packages/build/vite-plugin-meta-comments/src/test
11+
exclude: vite.config.js|package.json|index.js|axios.js|.eslintrc.js|mockServer|packages/engine-cli/template|packages/vue-generator/test|packages/vue-generator/src/templates|packages/build/vite-plugin-meta-comments/src/test

.github/workflows/deploy-cdn.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: Deploy to CDN
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
is_latest_release:
7+
description: '当前分支是否是最新release版本'
8+
required: true
9+
default: true
10+
type: boolean
11+
12+
env:
13+
HUAWEI_CLOUD_AK: ${{ secrets.HUAWEI_CLOUD_AK }}
14+
HUAWEI_CLOUD_SK: ${{ secrets.HUAWEI_CLOUD_SK }}
15+
HUAWEI_CLOUD_ENDPOINT: ${{ secrets.HUAWEI_CLOUD_ENDPOINT }}
16+
HUAWEI_CLOUD_BUCKET: ${{ secrets.HUAWEI_CLOUD_BUCKET }}
17+
18+
jobs:
19+
check-secrets:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
secrets-ready: ${{ steps.check.outputs.secrets-ready }}
23+
steps:
24+
- name: Check required secrets
25+
id: check
26+
run: |
27+
if [[ -z "${{ secrets.HUAWEI_CLOUD_AK }}" ]] || \
28+
[[ -z "${{ secrets.HUAWEI_CLOUD_SK }}" ]] || \
29+
[[ -z "${{ secrets.HUAWEI_CLOUD_ENDPOINT }}" ]] || \
30+
[[ -z "${{ secrets.HUAWEI_CLOUD_BUCKET }}" ]]; then
31+
echo "secrets-ready=false" >> $GITHUB_OUTPUT
32+
echo "::error::Required Huawei Cloud secrets are not configured."
33+
echo "::error::Please set: HUAWEI_CLOUD_AK, HUAWEI_CLOUD_SK, HUAWEI_CLOUD_ENDPOINT, HUAWEI_CLOUD_BUCKET"
34+
exit 1
35+
fi
36+
echo "secrets-ready=true" >> $GITHUB_OUTPUT
37+
echo "✅ All required secrets are configured"
38+
39+
build:
40+
runs-on: ubuntu-latest
41+
needs: check-secrets
42+
outputs:
43+
version-timestamp: ${{ steps.prepare-version.outputs.version_timestamp }}
44+
cdn-base: ${{ steps.prepare-version.outputs.cdn_base }}
45+
cdn-base-latest: ${{ steps.prepare-version.outputs.cdn_base_latest }}
46+
obs-path: ${{ steps.prepare-version.outputs.obs_path }}
47+
obs-path-latest: ${{ steps.prepare-version.outputs.obs_path_latest }}
48+
concurrency:
49+
group: deploy-cdn
50+
cancel-in-progress: true
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Install pnpm
56+
uses: pnpm/action-setup@v4
57+
with:
58+
version: 10
59+
run_install: false
60+
61+
- name: Setup Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
registry-url: 'https://registry.npmjs.org'
66+
67+
- name: Install dependencies
68+
run: pnpm install
69+
70+
- name: add environment variable
71+
run: |
72+
VITE_ORIGIN_URL="https://agent.opentiny.design/"
73+
cat <<EOF >> designer-demo/env/.env.alpha
74+
# ---- appended by CI (deploy-cdn) ----
75+
VITE_ORIGIN=$VITE_ORIGIN_URL
76+
EOF
77+
echo "VITE_ORIGIN_URL=$VITE_ORIGIN_URL"
78+
79+
- id: prepare-version
80+
name: Prepare version-timestamp
81+
run: |
82+
# Extract version from package.json
83+
VERSION=$(node -p "require('./designer-demo/package.json').version")
84+
85+
# Generate timestamp in YYYYMMDD-HHMMSS format
86+
TIMESTAMP=$(TZ="Asia/Shanghai" date +%Y%m%d-%H%M%S)
87+
88+
# Combine for version-timestamp
89+
VERSION_TIMESTAMP="${VERSION}-${TIMESTAMP}"
90+
91+
# Set CDN base path
92+
CDN_BASE="https://res-static.opentiny.design/tiny-engine-designer/${VERSION_TIMESTAMP}/"
93+
CDN_BASE_LATEST="https://res-static.opentiny.design/tiny-engine-designer/latest/"
94+
OBS_PATH="tiny-engine-designer/${VERSION_TIMESTAMP}/"
95+
OBS_PATH_LATEST="tiny-engine-designer/latest"
96+
97+
# Export as environment variables for subsequent steps
98+
echo "VERSION_TIMESTAMP=$VERSION_TIMESTAMP" >> $GITHUB_ENV
99+
echo "CDN_BASE=$CDN_BASE" >> $GITHUB_ENV
100+
echo "OBS_PATH=$OBS_PATH" >> $GITHUB_ENV
101+
102+
# Set outputs for job-level export
103+
echo "version_timestamp=$VERSION_TIMESTAMP" >> $GITHUB_OUTPUT
104+
echo "cdn_base=$CDN_BASE" >> $GITHUB_OUTPUT
105+
echo "cdn_base_latest=$CDN_BASE_LATEST" >> $GITHUB_OUTPUT
106+
echo "obs_path=$OBS_PATH" >> $GITHUB_OUTPUT
107+
echo "obs_path_latest=$OBS_PATH_LATEST" >> $GITHUB_OUTPUT
108+
109+
echo "Version-Timestamp: $VERSION_TIMESTAMP"
110+
echo "CDN Base: $CDN_BASE"
111+
echo "OBS Path: $OBS_PATH"
112+
113+
- name: Run Build
114+
run: |
115+
set -eo pipefail
116+
pnpm run build:plugin 2>&1 | tee /tmp/build-plugin.log
117+
# Run build:alpha equivalent with --base parameter
118+
pnpm run build:alpha --base=${{ env.CDN_BASE }} 2>&1 | tee /tmp/build-alpha.log
119+
120+
- name: Upload build artifacts
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: designer-demo-dist
124+
path: ./designer-demo/dist/
125+
retention-days: 1
126+
127+
deploy-cdn:
128+
runs-on: ubuntu-latest
129+
needs: [check-secrets, build]
130+
steps:
131+
- name: Checkout
132+
uses: actions/checkout@v4
133+
134+
- name: Download build artifacts
135+
uses: actions/download-artifact@v4
136+
with:
137+
name: designer-demo-dist
138+
path: ./designer-demo/dist/
139+
140+
- name: Install obsutil
141+
run: |
142+
curl -o obsutil.tar.gz https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_amd64.tar.gz
143+
tar -xzf obsutil.tar.gz
144+
chmod +x obsutil_linux_amd64_*/obsutil
145+
sudo mv obsutil_linux_amd64_*/obsutil /usr/local/bin/obsutil
146+
147+
- name: Configure and Upload to OBS
148+
run: |
149+
obsutil config -i=${{ env.HUAWEI_CLOUD_AK }} \
150+
-k=${{ env.HUAWEI_CLOUD_SK }} \
151+
-e=${{ env.HUAWEI_CLOUD_ENDPOINT }}
152+
# Upload to versioned path
153+
obsutil cp ./designer-demo/dist \
154+
obs://${{ env.HUAWEI_CLOUD_BUCKET }}/${{ needs.build.outputs.obs-path }} \
155+
-r -f -flat
156+
157+
# If is_latest_release is true, also upload to latest path
158+
if [ "${{ github.event.inputs.is_latest_release }}" = "true" ]; then
159+
# use cdn-base-latest replace cdn-base in all ./designer-demo/dist files
160+
find ./designer-demo/dist -type f \( -name "*.html" -o -name "*.js" -o -name "*.mjs" -o -name "*.css" \) \
161+
-exec sed -i "s|${{ needs.build.outputs.cdn-base }}|${{ needs.build.outputs.cdn-base-latest }}|g" {} +
162+
obsutil cp ./designer-demo/dist \
163+
obs://${{ env.HUAWEI_CLOUD_BUCKET }}/${{ needs.build.outputs.obs-path-latest }} \
164+
-r -f -flat
165+
fi
166+
167+
echo "Uploaded to: obs://${{ env.HUAWEI_CLOUD_BUCKET }}/${{ needs.build.outputs.obs-path }}"
168+
echo "CDN URL: https://res-static.opentiny.design/${{ needs.build.outputs.obs-path }}"

.github/workflows/deploy-gh-pages.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ name: Deploy to GitHub Pages
33
on:
44
push:
55
branches: [develop]
6+
workflow_dispatch:
7+
inputs:
8+
environment:
9+
description: 'Backend environment'
10+
required: true
11+
default: 'alpha'
12+
type: choice
13+
options:
14+
- alpha
15+
- production
616

717
jobs:
818
deploy-gh-pages:
@@ -31,14 +41,17 @@ jobs:
3141

3242
- name: add environment variable
3343
run: |
34-
cat <<'EOF' >> designer-demo/env/.env.alpha
35-
// ---- appended by CI (gh-pages) ----
36-
VITE_ORIGIN=https://agent.opentiny.design/
44+
ENV=${{ github.event.inputs.environment || 'alpha' }}
45+
VITE_ORIGIN_URL="https://agent-alpha.opentiny.design/"
46+
if [ "$ENV" = "production" ]; then
47+
VITE_ORIGIN_URL="https://agent.opentiny.design/"
48+
fi
49+
cat <<EOF >> designer-demo/env/.env.alpha
50+
# ---- appended by CI (gh-pages) ----
51+
VITE_ORIGIN=$VITE_ORIGIN_URL
3752
EOF
38-
- name: change material url
39-
run: |
40-
sed -i "s#material: \['/mock/bundle.json'\]#material: \['https://opentiny.github.io/tiny-engine/mock/bundle.json'\]#g" designer-demo/engine.config.js
41-
echo "Updated material url in designer-demo/engine.config.js"
53+
echo "DEPLOY_ENV=$ENV"
54+
echo "VITE_ORIGIN_URL=$VITE_ORIGIN_URL"
4255
- name: Run Build
4356
run: |
4457
set -eo pipefail

designer-demo/engine.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default {
22
id: 'engine.config',
33
theme: 'light',
4-
material: ['/mock/bundle.json'],
4+
material: ['./mock/bundle.json'],
55
scripts: [],
66
styles: [],
77
// 是否开启 TailWindCSS 特性

designer-demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
5+
<link rel="icon" type="image/svg+xml" href="./favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Vite + Vue</title>
88
</head>

designer-demo/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "designer-demo",
33
"private": true,
4-
"version": "2.8.0",
4+
"version": "2.9.0",
55
"type": "module",
66
"scripts": {
77
"dev": "cross-env vite",
8+
"dev:withAuth": "cross-env VITE_AUTH=true vite",
89
"build:alpha": "cross-env NODE_OPTIONS=--max-old-space-size=10240 vite build --mode alpha",
910
"build": "cross-env NODE_OPTIONS=--max-old-space-size=10240 vite build",
1011
"test": "vitest run",
46.4 KB
Loading

0 commit comments

Comments
 (0)