diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 76cb5cf..870df2b 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -5,43 +5,46 @@ on: branches: - main pull_request: - jobs: build: - runs-on: macos-latest + name: SpringBootApp 在 ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'temurin' + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '21' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: 'true' - - name: Cache Maven packages - uses: actions/cache@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 + - name: 配置 Maven + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '17' - - name: Install GraalVM compatible with Java 17 - uses: DeLaGuardo/setup-graalvm@5.0 - with: - graalvm-version: '21.3.0' # Make sure this version is compatible with Java 17 - java-version: '17' + - name: 使用 Maven 构建原生镜像 + run: mvn -Pnative -DskipTests package - - name: Install native-image component - run: gu install native-image + - name: 将原生可执行文件重命名并移动到 target 目录 + run: | + mv target/*-runner target/${{ runner.os }}-application # 根据您的 Spring Boot Maven 输出目录和可执行文件名称调整此行。 + if: ${{ matrix.os != 'windows-latest' }} + + - name: 将原生可执行文件重命名并移动到 target 目录 (Windows) + run: | + mv target\*-runner.exe target\application.exe + if: ${{ matrix.os == 'windows-latest' }} - - name: Set execute permissions for mvnw - run: chmod +x ./mvnw - - - name: Build native image with Maven - run: ./mvnw native:compile -Pnative - - - name: Upload native image from target folder - uses: actions/upload-artifact@v2 - with: - name: native-image - path: target/gpt-4-copilot-0.0.4 + - name: 上传二进制文件 + uses: actions/upload-artifact@v2 + with: + name: springbootapp-${{ matrix.os }} + path: | + target/${{ runner.os }}-application + target/application.exe