Skip to content

Commit

Permalink
build(github): add github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
DaiYuANg committed Dec 7, 2024
1 parent 279f461 commit f859429
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/javafx-gradle-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: JavaFX Build and Test with Gradle

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
build:
runs-on: ubuntu-latest # 使用最新的 Ubuntu 环境

steps:
- name: Checkout code
uses: actions/checkout@v3 # 检出代码

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '21' # 设置 JDK 版本,JavaFX 需要 JDK 17 及以上版本

- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches # 缓存 Gradle 的依赖
key: ${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle*') }} # 缓存 key
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build --no-daemon # 构建项目

# - name: Run tests
# run: ./gradlew test --no-daemon # 运行测试
#
# - name: Package JavaFX Application
# run: ./gradlew jfxJar # 使用 JavaFX 插件构建可运行的 JAR 文件(如果使用了 jfx-gradle-plugin)

# - name: Upload JAR artifact
# uses: actions/upload-artifact@v3
# with:
# name: javafx-artifact
# path: build/libs/*.jar # 上传生成的 JAR 文件
#
# - name: Deploy or release (optional)
# run: |
# echo "Deploying or releasing the application..."

0 comments on commit f859429

Please sign in to comment.