TODO: implement ultimate #55
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: Gradle Build | |
| on: [pull_request, push] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Validate Gradle wrapper | |
| uses: gradle/actions/wrapper-validation@v4 | |
| - name: Setup JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'microsoft' | |
| - name: Make Gradle wrapper executable | |
| run: chmod +x ./gradlew | |
| - name: Extract version from properties | |
| id: get_version | |
| run: | | |
| MOD_VERSION=$(grep 'mod_version' gradle.properties | cut -d '=' -f 2 | tr -d '[:space:]') | |
| if [ -z "$MOD_VERSION" ]; then | |
| echo "Error: mod_version not found or empty in gradle.properties" | |
| exit 1 | |
| fi | |
| echo "Detected Version: $MOD_VERSION" | |
| echo "RELEASE_VERSION=$MOD_VERSION" >> $GITHUB_ENV | |
| - name: Run Gradle Clean Build | |
| run: ./gradlew clean build | |
| - name: Publish to GitHub Packages (Conditional) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/release' | |
| run: ./gradlew publish | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release (Conditional) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/release' | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ env.RELEASE_VERSION }} | |
| name: Release v${{ env.RELEASE_VERSION }} | |
| files: build/libs/*.jar | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Artifacts | |
| path: build/libs/ |