Commit 8003e3fb6757e9f8e900f0397c43f17e87d66424

Authored by YunaiV
1 parent b172e9c8

fix(ci): 修复缓存失效并对齐 JDK 构建配置

- 升级 checkout 与 setup-java,使用新版 Maven 缓存
- 根据根 POM 选择 JDK,覆盖三个主分支并支持手动触发
- 移除已失效的内嵌前端构建流水线
.github/workflows/maven.yml
1   -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2   -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
  1 +# 打包校验:JDK 版本取自根 pom.xml 的 java.version,与当前分支保持一致
  2 +# 参考:https://docs.github.com/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven
3 3  
4 4 name: Java CI with Maven
5 5  
6 6 on:
7 7 push:
8   - branches: [ master ]
  8 + branches: [ master, master-jdk17, master-jdk25 ]
9 9 # pull_request:
10 10 # branches: [ master ]
  11 + workflow_dispatch:
11 12  
12 13 jobs:
13 14 build:
14 15  
15 16 runs-on: ubuntu-latest
16 17  
17   - strategy:
18   - matrix:
19   - java: [ '8', '11', '17' ]
20   -
21 18 steps:
22   - - uses: actions/checkout@v2
23   - - name: Set up JDK ${{ matrix.Java }}
24   - uses: actions/setup-java@v2
  19 + - uses: actions/checkout@v7
  20 + # 读取根 pom.xml 的 properties/java.version(1.8 -> 8),缺失或无效时直接失败
  21 + - name: Resolve JDK version
  22 + id: jdk
  23 + run: |
  24 + python3 -I - <<'EOF' >> "$GITHUB_OUTPUT"
  25 + import xml.etree.ElementTree as ET
  26 + ns = {'m': 'http://maven.apache.org/POM/4.0.0'}
  27 + v = (ET.parse('pom.xml').getroot().findtext('m:properties/m:java.version', namespaces=ns) or '').strip().removeprefix('1.')
  28 + if not v.isdigit():
  29 + raise SystemExit(f'根 pom.xml 的 properties/java.version 缺失或无效: {v!r}')
  30 + print(f'version={v}')
  31 + EOF
  32 + - name: Set up JDK ${{ steps.jdk.outputs.version }}
  33 + uses: actions/setup-java@v6
25 34 with:
26   - java-version: ${{ matrix.java }}
  35 + java-version: ${{ steps.jdk.outputs.version }}
27 36 distribution: 'temurin'
28 37 cache: maven
  38 + cache-dependency-path: '**/pom.xml'
29 39 - name: Build with Maven
30 40 run: mvn -B package --file pom.xml -Dmaven.test.skip=true
... ...
.github/workflows/yudao-ui-admin.yml deleted
1   -name: yudao-ui-admin CI
2   -
3   -# 在master分支发生push事件时触发。
4   -on:
5   - push:
6   - branches: [ master ]
7   - # pull_request:
8   - # branches: [ master ]
9   -env: # 设置环境变量
10   - TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用时区时间)
11   - WORK_DIR: yudao-ui-admin #工作目录
12   -
13   -defaults:
14   - run:
15   - shell: bash
16   - working-directory: yudao-ui-admin
17   -
18   -jobs:
19   - build: # 自定义名称
20   - runs-on: ubuntu-latest # 运行在虚拟机环境ubuntu-latest
21   -
22   - strategy:
23   - matrix:
24   - node_version: [14.x, 16.x]
25   - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
26   -
27   - steps:
28   - - name: Checkout # 步骤1
29   - uses: actions/checkout@v2 # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions
30   -
31   - - name: Install pnpm
32   - uses: pnpm/action-setup@v2.0.1
33   - with:
34   - version: 6.15.1
35   -
36   - - name: Set node version to ${{ matrix.node_version }}
37   - uses: actions/setup-node@v2
38   - with:
39   - node-version: ${{ matrix.node_version }}
40   - cache: "yarn"
41   - cache-dependency-path: yudao-ui-admin/yarn.lock
42   -
43   - - name: Install deps
44   - run: node --version && yarn --version && yarn install
45   -
46   - - name: Build
47   - run: yarn build:prod
48   -
49   - # 查看 workflow 的文档来获取更多信息
50   - # @see https://github.com/crazy-max/ghaction-github-pages
51   -