From 8003e3fb6757e9f8e900f0397c43f17e87d66424 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 25 Oct 2026 03:02:22 +0800 Subject: [PATCH] fix(ci): 修复缓存失效并对齐 JDK 构建配置 --- .github/workflows/maven.yml | 32 +++++++++++++++++++++----------- .github/workflows/yudao-ui-admin.yml | 51 --------------------------------------------------- 2 files changed, 21 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/yudao-ui-admin.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7c76592..fdef082 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,30 +1,40 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# 打包校验:JDK 版本取自根 pom.xml 的 java.version,与当前分支保持一致 +# 参考:https://docs.github.com/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven name: Java CI with Maven on: push: - branches: [ master ] + branches: [ master, master-jdk17, master-jdk25 ] # pull_request: # branches: [ master ] + workflow_dispatch: jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - java: [ '8', '11', '17' ] - steps: - - uses: actions/checkout@v2 - - name: Set up JDK ${{ matrix.Java }} - uses: actions/setup-java@v2 + - uses: actions/checkout@v7 + # 读取根 pom.xml 的 properties/java.version(1.8 -> 8),缺失或无效时直接失败 + - name: Resolve JDK version + id: jdk + run: | + python3 -I - <<'EOF' >> "$GITHUB_OUTPUT" + import xml.etree.ElementTree as ET + ns = {'m': 'http://maven.apache.org/POM/4.0.0'} + v = (ET.parse('pom.xml').getroot().findtext('m:properties/m:java.version', namespaces=ns) or '').strip().removeprefix('1.') + if not v.isdigit(): + raise SystemExit(f'根 pom.xml 的 properties/java.version 缺失或无效: {v!r}') + print(f'version={v}') + EOF + - name: Set up JDK ${{ steps.jdk.outputs.version }} + uses: actions/setup-java@v6 with: - java-version: ${{ matrix.java }} + java-version: ${{ steps.jdk.outputs.version }} distribution: 'temurin' cache: maven + cache-dependency-path: '**/pom.xml' - name: Build with Maven run: mvn -B package --file pom.xml -Dmaven.test.skip=true diff --git a/.github/workflows/yudao-ui-admin.yml b/.github/workflows/yudao-ui-admin.yml deleted file mode 100644 index a42a8f6..0000000 --- a/.github/workflows/yudao-ui-admin.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: yudao-ui-admin CI - -# 在master分支发生push事件时触发。 -on: - push: - branches: [ master ] - # pull_request: - # branches: [ master ] -env: # 设置环境变量 - TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用时区时间) - WORK_DIR: yudao-ui-admin #工作目录 - -defaults: - run: - shell: bash - working-directory: yudao-ui-admin - -jobs: - build: # 自定义名称 - runs-on: ubuntu-latest # 运行在虚拟机环境ubuntu-latest - - strategy: - matrix: - node_version: [14.x, 16.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - steps: - - name: Checkout # 步骤1 - uses: actions/checkout@v2 # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions - - - name: Install pnpm - uses: pnpm/action-setup@v2.0.1 - with: - version: 6.15.1 - - - name: Set node version to ${{ matrix.node_version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node_version }} - cache: "yarn" - cache-dependency-path: yudao-ui-admin/yarn.lock - - - name: Install deps - run: node --version && yarn --version && yarn install - - - name: Build - run: yarn build:prod - - # 查看 workflow 的文档来获取更多信息 - # @see https://github.com/crazy-max/ghaction-github-pages - -- libgit2 0.21.4