Merge pull request #34 from kennethfan/kennethfan-patch-1 #4
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: JavaFX Submodule Package | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ master ] | |
| paths: | |
| - 'javafx-fxml-example/**' # 只监控子模块变化 | |
| - '.github/workflows/build-javafx.yml' | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - master | |
| paths: | |
| - 'javafx-fxml-example/**' # 只监控子模块变化 | |
| - '.github/workflows/build-javafx.yml' | |
| jobs: | |
| build-packages: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| # 切换到子模块目录 | |
| - name: Navigate to submodule | |
| working-directory: javafx-fxml-example | |
| run: pwd | |
| # Linux 依赖安装 | |
| - name: Install Linux dependencies | |
| if: runner.os == 'Linux' | |
| working-directory: javafx-fxml-example | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y fakeroot rpm | |
| # 构建项目 | |
| - name: Build with Maven | |
| working-directory: javafx-fxml-example | |
| run: mvn -B clean package | |
| # 创建运行时镜像 | |
| - name: Create runtime image | |
| working-directory: javafx-fxml-example | |
| run: mvn javafx:jlink | |
| # 平台特定打包 | |
| - name: Create native package | |
| working-directory: javafx-fxml-example | |
| run: | | |
| mkdir -p target/release | |
| # Windows 打包 | |
| if [[ "$RUNNER_OS" == "Windows" ]]; then | |
| jpackage \ | |
| --type msi \ | |
| --name "JavaFXExample" \ | |
| --runtime-image target/image \ | |
| --module io.github.kennethfan/io.github.kennethfan.MainApp \ | |
| --dest target/release \ | |
| --win-menu \ | |
| --win-shortcut \ | |
| # --icon src/main/resources/icons/win.ico | |
| # macOS 打包 | |
| elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
| jpackage \ | |
| --type dmg \ | |
| --name "JavaFXExample" \ | |
| --runtime-image target/image \ | |
| --module io.github.kennethfan/io.github.kennethfan.MainApp \ | |
| --dest target/release \ | |
| --mac-package-identifier "io.github.kennethfan.javafx" \ | |
| --mac-package-name "JavaFX Example" \ | |
| # --icon src/main/resources/icons/mac.icns | |
| # Linux 打包 | |
| elif [[ "$RUNNER_OS" == "Linux" ]]; then | |
| jpackage \ | |
| --type deb \ | |
| --name "javafx-example" \ | |
| --runtime-image target/image \ | |
| --module io.github.kennethfan/io.github.kennethfan.MainApp \ | |
| --dest target/release \ | |
| --linux-shortcut \ | |
| # --icon src/main/resources/icons/linux.png | |
| fi | |
| # 上传制品 | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: package-${{ runner.os }} | |
| path: javafx-fxml-example/target/release/* | |
| # 创建发布 | |
| create-release: | |
| needs: build-packages | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v3 | |
| - name: Create release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| package-ubuntu-latest/* | |
| package-windows-latest/* | |
| package-macos-latest/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |