build: 更新构建配置和 CI 工作流 #17
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
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| # This workflow will build a Java project with Gradle 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-gradle | |
| name: Java CI with Gradle | |
| on: | |
| push: | |
| paths-ignore: | |
| - "**.md" | |
| - "**.txt" | |
| - "docs/**" | |
| pull_request: | |
| paths-ignore: | |
| - "**.md" | |
| - "**.txt" | |
| - "docs/**" | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 8 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: "8" | |
| distribution: "temurin" | |
| - name: Clean Gradle cache (if needed) | |
| run: | | |
| if [ -d ~/.gradle/caches/forge_gradle ]; then | |
| rm -rf ~/.gradle/caches/forge_gradle | |
| fi | |
| if [ -d ~/.gradle/caches/minecraft ]; then | |
| rm -rf ~/.gradle/caches/minecraft | |
| fi | |
| - name: Build with Gradle (with retry) | |
| run: | | |
| # Try building up to 3 times | |
| for i in {1..3}; do | |
| echo "Build attempt $i" | |
| if ./gradlew build --refresh-dependencies --no-daemon --stacktrace; then | |
| echo "Build succeeded on attempt $i" | |
| break | |
| else | |
| echo "Build failed on attempt $i" | |
| if [ $i -eq 3 ]; then | |
| echo "All build attempts failed" | |
| exit 1 | |
| fi | |
| echo "Cleaning cache and retrying..." | |
| rm -rf ~/.gradle/caches/forge_gradle || true | |
| rm -rf ~/.gradle/caches/minecraft || true | |
| rm -rf ~/.gradle/caches/modules-2 || true | |
| sleep 15 | |
| fi | |
| done | |
| - name: Upload JAR artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: proxy-protocol-support-1.16.5 | |
| path: build/libs/*.jar | |
| if-no-files-found: error |