Update meta.ts #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build on Push | |
| on: | |
| push: | |
| branches: | |
| - frontend-remake | |
| pull_request: | |
| branches: | |
| - frontend-remake | |
| workflow_dispatch: # 允许手动触发 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| id: setup-node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'pnpm' | |
| check-latest: true | |
| - name: Verify installation | |
| shell: bash | |
| run: | | |
| echo "Checking installations..." | |
| node --version | |
| npm --version | |
| pnpm --version | |
| echo "All installations verified." | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Check version info | |
| id: check-version | |
| shell: bash | |
| run: | | |
| # 获取当前版本信息 | |
| CURRENT_PACKAGE_VERSION=$(jq -r .version package.json) | |
| CURRENT_POLICY_VERSION=$(jq -r .policyVersion public/config/version.json) | |
| CURRENT_APP_VERSION=$(jq -r .appVersion public/config/version.json) | |
| echo "Current versions:" | |
| echo " Package: $CURRENT_PACKAGE_VERSION" | |
| echo " Policy: $CURRENT_POLICY_VERSION" | |
| echo " App: $CURRENT_APP_VERSION" | |
| # 尝试获取上一个提交的版本信息(如果存在) | |
| if git log -n 1 --oneline > /dev/null 2>&1; then | |
| PREV_PACKAGE_VERSION=$(git show HEAD~1:package.json 2>/dev/null | jq -r .version 2>/dev/null || echo "none") | |
| PREV_POLICY_VERSION=$(git show HEAD~1:public/config/version.json 2>/dev/null | jq -r .policyVersion 2>/dev/null || echo "none") | |
| PREV_APP_VERSION=$(git show HEAD~1:public/config/version.json 2>/dev/null | jq -r .appVersion 2>/dev/null || echo "none") | |
| echo "Previous versions:" | |
| echo " Package: $PREV_PACKAGE_VERSION" | |
| echo " Policy: $PREV_POLICY_VERSION" | |
| echo " App: $PREV_APP_VERSION" | |
| # 检查版本变化(仅用于信息输出) | |
| if [[ "$CURRENT_PACKAGE_VERSION" != "$PREV_PACKAGE_VERSION" ]]; then | |
| echo "⚠️ Package version changed from $PREV_PACKAGE_VERSION to $CURRENT_PACKAGE_VERSION" | |
| fi | |
| if [[ "$CURRENT_POLICY_VERSION" != "$PREV_POLICY_VERSION" ]]; then | |
| echo "⚠️ Policy version changed from $PREV_POLICY_VERSION to $CURRENT_POLICY_VERSION" | |
| fi | |
| if [[ "$CURRENT_APP_VERSION" != "$PREV_APP_VERSION" ]]; then | |
| echo "⚠️ App version changed from $PREV_APP_VERSION to $CURRENT_APP_VERSION" | |
| fi | |
| else | |
| echo "No previous commit found (first commit or shallow clone)" | |
| fi | |
| - name: Build SPA | |
| run: | | |
| # 构建SPA版本 | |
| echo "Building SPA version..." | |
| pnpm run build | |
| # 将SPA构建产物移动到spa-dist目录 | |
| mv dist spa-dist | |
| echo "SPA build completed. Output directory: spa-dist/" | |
| - name: Build SSG | |
| run: | | |
| # 构建SSG版本 | |
| echo "Building SSG version..." | |
| pnpm run build:ssg | |
| # 将SSG构建产物移动到ssg-dist目录 | |
| mv dist ssg-dist | |
| echo "SSG build completed. Output directory: ssg-dist/" | |
| - name: Upload SPA artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: spa-dist | |
| path: spa-dist/ | |
| retention-days: 7 | |
| - name: Upload SSG artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ssg-dist | |
| path: ssg-dist/ | |
| retention-days: 7 | |