Fix compile issues from rebasing upstream #483
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 Package | |
| on: [push, workflow_dispatch] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # needed by build-tag-number and mc-publish | |
| packages: write | |
| actions: write | |
| steps: | |
| #------------------------------------------------------------------ | |
| # 0) Checkout + JDK | |
| #------------------------------------------------------------------ | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # fetch the entire history and all tags | |
| fetch-depth: 50 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| server-id: github | |
| settings-path: ${{ github.workspace }} | |
| #------------------------------------------------------------------ | |
| # 1) Gradle wrapper validation + caches | |
| #------------------------------------------------------------------ | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Cache Loom | |
| uses: actions/cache@v4 | |
| with: | |
| path: .gradle/loom-cache | |
| key: loom-cache-${{ runner.os }}-${{ hashFiles('**/libs.versions.toml', | |
| 'fabric/**/build.gradle.kts', | |
| 'bukkit/**/build.gradle.kts') }} | |
| restore-keys: | | |
| loom-cache-${{ runner.os }} | |
| #------------------------------------------------------------------ | |
| # 2) Resolve VERSIONs **before** building | |
| #------------------------------------------------------------------ | |
| - name: Compute MAIN version (default build) | |
| id: ver_main | |
| run: | | |
| VERSION=$(./gradlew -q printVersion | grep '^VERSION=' | cut -d'=' -f2) | |
| echo "main_version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "MAIN_VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "Main version: $VERSION" | |
| - name: Compute LITE version (-PshadePE=false) | |
| id: ver_lite | |
| run: | | |
| VERSION=$(./gradlew -q -PshadePE=false printVersion | grep '^VERSION=' | cut -d'=' -f2) | |
| echo "lite_version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "LITE_VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "Lite version: $VERSION" | |
| #------------------------------------------------------------------ | |
| # 3) Build shaded / “main” jars (all modules) | |
| #------------------------------------------------------------------ | |
| - name: Build (all platforms, shaded) | |
| run: ./gradlew build | |
| #------------------------------------------------------------------ | |
| # 4) Build **lite** Bukkit jar | |
| #------------------------------------------------------------------ | |
| - name: Build Bukkit-Lite (no shaded PacketEvents) | |
| run: ./gradlew :bukkit:build -PshadePE=false | |
| #------------------------------------------------------------------ | |
| # 4.5) Rename jars to LightningGrim-* before we upload/publish | |
| #------------------------------------------------------------------ | |
| - name: Rename jars to LightningGrim | |
| shell: bash | |
| run: | | |
| set -e | |
| mv "bukkit/build/libs/grimac-bukkit-${MAIN_VERSION}.jar" \ | |
| "bukkit/build/libs/LightningGrim-bukkit-${MAIN_VERSION}.jar" | |
| mv "bukkit/build/libs/grimac-bukkit-${LITE_VERSION}.jar" \ | |
| "bukkit/build/libs/LightningGrim-bukkit-${LITE_VERSION}.jar" | |
| mv "fabric/build/libs/grimac-fabric-${MAIN_VERSION}.jar" \ | |
| "fabric/build/libs/LightningGrim-fabric-${MAIN_VERSION}.jar" | |
| #------------------------------------------------------------------ | |
| # 5) Upload MAIN Bukkit + Fabric artefacts | |
| #------------------------------------------------------------------ | |
| - name: Upload Bukkit – MAIN | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: grimac-bukkit | |
| path: bukkit/build/libs/LightningGrim-bukkit-${{ env.MAIN_VERSION }}.jar | |
| if-no-files-found: error | |
| - name: Upload Fabric | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: grimac-fabric | |
| path: fabric/build/libs/LightningGrim-fabric-${{ env.MAIN_VERSION }}.jar | |
| if-no-files-found: error | |
| #------------------------------------------------------------------ | |
| # 6) Upload LITE artefact | |
| #------------------------------------------------------------------ | |
| - name: Upload Bukkit – LITE | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: grimac-bukkit-lite | |
| path: bukkit/build/libs/LightningGrim-bukkit-${{ env.LITE_VERSION }}.jar | |
| if-no-files-found: error | |
| #------------------------------------------------------------------ | |
| # 7) Auto-generate CHANGELOG (since previous build tag) | |
| #------------------------------------------------------------------ | |
| - name: Generate changelog | |
| id: changelog | |
| if: contains(fromJSON('["merge","release","main","lightning"]'), github.ref_name) | |
| run: | | |
| set -e | |
| git fetch --tags --quiet | |
| # Most recent tag that looks like “build-*”; empty if none exist | |
| LAST_TAG=$(git describe --tags --match "build-*" --abbrev=0 2>/dev/null || echo "") | |
| echo "Last tag: ${LAST_TAG:-<none>}" | |
| if [ -z "$LAST_TAG" ]; then | |
| # First build (or no previous tag) → grab latest 50 commits | |
| NOTES=$(git log -n 50 --pretty=format:'* %s (%h)' --no-merges) | |
| else | |
| # Normal case → commits since the last build tag | |
| NOTES=$(git log "$LAST_TAG"..HEAD --pretty=format:'* %s (%h)' --no-merges) | |
| fi | |
| # Fallback if there were no code changes | |
| if [ -z "$NOTES" ]; then | |
| NOTES="* No code changes since last build" | |
| fi | |
| # Export multiline output for downstream steps | |
| { | |
| echo "notes<<EOF" | |
| echo "$NOTES" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| echo "Changelog generated:" | |
| echo "$NOTES" | |
| #------------------------------------------------------------------ | |
| # 8) Generate incremental build number (after changelog step!) | |
| #------------------------------------------------------------------ | |
| - name: Generate build number | |
| if: contains(fromJSON('["merge","release","main","lightning"]'), github.ref_name) | |
| id: buildnumber | |
| uses: onyxmueller/build-tag-number@v1 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| #------------------------------------------------------------------ | |
| # 9-A) Publish **Bukkit** jars to Modrinth | |
| #------------------------------------------------------------------ | |
| - name: Publish to Modrinth (Bukkit) | |
| if: contains(fromJSON('["merge","release","main","lightning"]'), github.ref_name) | |
| uses: Kir-Antipov/[email protected] | |
| with: | |
| modrinth-id: ${{ vars.MODRINTH_ID }} # Bukkit & Fabric can share or differ | |
| modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
| modrinth-featured: true | |
| modrinth-unfeature-mode: subset | |
| files: | | |
| bukkit/build/libs/LightningGrim-bukkit-${{ env.MAIN_VERSION }}.jar | |
| bukkit/build/libs/LightningGrim-bukkit-${{ env.LITE_VERSION }}.jar | |
| name: Lightning Grim Anticheat (Bukkit) ${{ env.MAIN_VERSION }}-b${{ steps.buildnumber.outputs.build_number }} | |
| version: ${{ env.MAIN_VERSION }}-b${{ steps.buildnumber.outputs.build_number }} | |
| version-type: alpha | |
| changelog: ${{ steps.changelog.outputs.notes }} | |
| loaders: | | |
| bukkit | |
| spigot | |
| paper | |
| folia | |
| purpur | |
| game-versions: | | |
| >=1.7 | |
| retry-attempts: 2 | |
| retry-delay: 10000 | |
| fail-mode: fail | |
| #------------------------------------------------------------------ | |
| # 9-B) Publish **Fabric** jar to Modrinth | |
| #------------------------------------------------------------------ | |
| - name: Publish to Modrinth (Fabric) | |
| if: contains(fromJSON('["merge","release","main","lightning"]'), github.ref_name) | |
| uses: Kir-Antipov/[email protected] | |
| with: | |
| modrinth-id: ${{ vars.MODRINTH_ID_FABRIC || vars.MODRINTH_ID }} | |
| modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
| modrinth-featured: true | |
| modrinth-unfeature-mode: subset | |
| files: | | |
| fabric/build/libs/LightningGrim-fabric-${{ env.MAIN_VERSION }}.jar | |
| name: Lightning Grim Anticheat (Fabric) ${{ env.MAIN_VERSION }}-b${{ steps.buildnumber.outputs.build_number }} | |
| version: ${{ env.MAIN_VERSION }}-b${{ steps.buildnumber.outputs.build_number }} | |
| version-type: alpha | |
| changelog: ${{ steps.changelog.outputs.notes }} | |
| loaders: | | |
| fabric | |
| game-versions: | | |
| >=1.16.1 | |
| retry-attempts: 2 | |
| retry-delay: 10000 | |
| fail-mode: fail |