[PORT] Fixed gradle.properties
#226
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: Publish on GitHub, CurseForge & Modrinth | |
| # Triggers: run on push, pull request, or manual dispatch | |
| on: [ push, pull_request, workflow_dispatch ] | |
| env: | |
| # Centralize key environment variables for easy updates | |
| JAVA_VERSION: 17 | |
| # Release name prefix for tagging and naming builds/releases | |
| RELEASE_NAME: Bok's Banging Butterflies v | |
| # Secure tokens stored as encrypted secrets for publishing platforms | |
| MODRINTH_TOKEN: ${{ secrets.PUBLISH_MODRINTH_TOKEN }} | |
| CURSEFORGE_TOKEN: ${{ secrets.PUBLISH_CURSEFORGE_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} | |
| # Minimum deploy permissions for the workflow to improve security | |
| permissions: | |
| contents: write | |
| jobs: | |
| # First check we have changed the version | |
| check_version_change: | |
| runs-on: 'ubuntu-latest' | |
| outputs: | |
| version_changed: ${{ steps.check_version_change.outputs.version_changed }} | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| # Checkout as many commits as needed for the diff | |
| fetch-depth: 0 | |
| - shell: pwsh | |
| id: check_version_change | |
| run: | | |
| # Diff HEAD with the previous commit | |
| $diff = git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | |
| # Check if a file under docs/ or with the .md extension has changed (added, modified, deleted) | |
| $SourceDiff = $diff | Where-Object { $_ -match 'gradle.properties' } | |
| $HasDiff = $SourceDiff.Length -gt 0 | |
| # Set the output named "version_changed" | |
| Write-Host "::set-output name=version_changed::$HasDiff" | |
| echo "version_changed=$HasDiff" | |
| build: | |
| # The environment where workflow runs, here Ubuntu latest stable | |
| runs-on: ubuntu-latest | |
| # Only run if the version has changed | |
| needs: [ check_version_change ] | |
| if: needs.check_version_change.outputs.version_changed == 'True' | |
| steps: | |
| # Display all environment variables for debugging purposes | |
| - name: Check Environment Variables | |
| run: env | |
| # Checkout the repository's latest state including submodules (if any) | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| # Extract the mod version dynamically from gradle.properties for consistent versioning | |
| - name: Extract version from gradle.properties | |
| id: get_version | |
| run: | | |
| VERSION=$(grep '^mod_version=' ./gradle.properties | cut -d'=' -f2 | tr -d '[:space:]') | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| # Display the extracted mod version for confirmation/debugging | |
| - name: Show extracted VERSION | |
| run: echo "Version is $VERSION" | |
| # Extract the Minecraft version dynamically from gradle.properties for consistent versioning | |
| - name: Extract Minecraft version from gradle.properties | |
| id: get_mc_version | |
| run: | | |
| # Try to get mapping_version first | |
| MC_VERSION=$(grep '^mapping_version=' ./gradle.properties | cut -d'=' -f2 | tr -d '[:space:]') | |
| # If empty, fallback to minecraft_version | |
| if [ -z "$MC_VERSION" ]; then | |
| MC_VERSION=$(grep '^minecraft_version=' ./gradle.properties | cut -d'=' -f2 | tr -d '[:space:]') | |
| fi | |
| # Export the value as an environment variable | |
| echo "MINECRAFT_VERSION=$MC_VERSION" >> $GITHUB_ENV | |
| # Display the extracted Minecraft version for confirmation/debugging | |
| - name: Show extracted MINECRAFT_VERSION | |
| run: echo "Minecraft version is $MINECRAFT_VERSION" | |
| # Set up the Java environment using specified distribution and version | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: "${{env.JAVA_VERSION}}" | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| # Ensure the Gradle wrapper script is executable on non-Windows runners | |
| - name: Make Gradle Wrapper Executable | |
| if: ${{ runner.os != 'Windows' }} | |
| run: chmod +x ./gradlew | |
| # Cache the Gradle packages to speed up runs. | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.gradle/caches | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*','gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| # Build the project using Gradle clean and build tasks | |
| - name: Build with Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| arguments: build | |
| # Publish the built mod to CurseForge, Modrinth, and GitHub Releases | |
| - name: Publish (CurseForge/Modrinth/GitHub) | |
| uses: Kir-Antipov/mc-publish@v3.3 | |
| with: | |
| curseforge-id: 929419 | |
| curseforge-token: "${{env.CURSEFORGE_TOKEN}}" | |
| modrinth-id: hUw80ZZs | |
| modrinth-token: "${{env.MODRINTH_TOKEN}}" | |
| github-tag: "v${{env.VERSION}}-for-${{env.MINECRAFT_VERSION}}" | |
| github-token: "${{env.GITHUB_TOKEN}}" | |
| name: "${{env.RELEASE_NAME}}${{env.VERSION}}" | |
| version: "${{env.VERSION}}" | |
| version-type: release | |
| changelog-file: CHANGELOG.md | |
| loaders: neoforge | |
| game-versions: "${{env.MINECRAFT_VERSION}}" | |
| java: "${{env.JAVA_VERSION}}" |