diff --git a/.github/workflows/internal.gradle.build.yaml b/.github/workflows/internal.gradle.build.yaml new file mode 100644 index 0000000..0c36f4b --- /dev/null +++ b/.github/workflows/internal.gradle.build.yaml @@ -0,0 +1,50 @@ +name: "[Gradle] Build project" + +on: + workflow_call: + inputs: + image: + description: Which image to run the different tasks on (image must support bash) + type: string + required: true + java: + description: The version of Java to use to run Gradle + type: string + required: true + gradle_build_task: + description: The name of the gradle build task to use + type: string + required: true + version: + description: The version to use during compilation + type: string + required: true + secrets: + GRADLE_ENCRYPTION_KEY: + description: The AES key to enable Gradle cache encryption + required: false + +permissions: + contents: read + +jobs: + build: + runs-on: ${{ inputs.image }} + steps: + - name: "📦 Checkout" + uses: actions/checkout@v4 + + - name: "📦 Fetch tags" # See https://github.com/actions/checkout/issues/2041 + run: git fetch --tags + + - name: "⚙️ Configure Java" + run: echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV" + + - name: "⚙️ Configure Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: wrapper + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} + + - name: "🏗️ Build" + run: ./gradlew --build-cache ${{ inputs.gradle_build_task }} -PfullVersion=${{ inputs.version }} diff --git a/.github/workflows/internal.gradle.publish.yaml b/.github/workflows/internal.gradle.publish.yaml new file mode 100644 index 0000000..9346a0e --- /dev/null +++ b/.github/workflows/internal.gradle.publish.yaml @@ -0,0 +1,84 @@ +name: "[Gradle] Publish project to Github/JFrog/CurseForge/Crowdin" + +on: + workflow_call: + inputs: + image: + description: Which image to run the different tasks on (image must support bash) + type: string + required: true + java: + description: The version of Java to use to run Gradle + type: string + required: true + version: + description: The version to use during compilation + type: string + required: true + gradle_publish_task: + description: The name of the gradle publish task to use + type: string + required: true + release_type: + description: The type of release to make on Curse, can either be 'beta' or 'release' + type: string + required: false + secrets: + GRADLE_ENCRYPTION_KEY: + description: The AES key to enable Gradle cache encryption + required: false + GITHUB_PUBLISH_USER: + description: The user to use to publish to Github Packages + required: false + GITHUB_PUBLISH_TOKEN: + description: The token to publish to Github Packages + required: false + JFROG_PUBLISH_USER: + description: The user to use to publish to JFrog + required: false + JFROG_PUBLISH_PASSWORD: + description: The password for the user to publish to JFrog + required: false + CURSE_API_KEY: + description: The API key to publish to CurseForge + required: false + CROWDIN_API_KEY: + description: The API key to publish to Crowdin + +permissions: + contents: read + +jobs: + publish: + runs-on: ${{ inputs.image }} + steps: + - name: "📦 Checkout" + uses: actions/checkout@v4 + + - name: "📦 Fetch tags" # See https://github.com/actions/checkout/issues/2041 + run: git fetch --tags + + - name: "⚙️ Configure Java" + run: echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV" + + - name: "⚙️ Configure Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: wrapper + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} + + - name: "🚀 Publish" + run: ./gradlew --build-cache ${{ inputs.gradle_publish_task }} -PmodVersion=${{ inputs.version }} + env: + # Github + GITHUB_USERNAME: ${{ secrets.GITHUB_PUBLISH_USER }} + GITHUB_TOKEN: ${{ secrets.GITHUB_PUBLISH_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} + # JFrog + LDTTeamJfrogUsername: ${{ secrets.JFROG_PUBLISH_USER }} + LDTTeamJfrogPassword: ${{ secrets.JFROG_PUBLISH_PASSWORD }} + # CurseForge + CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} + CURSE_RELEASE_TYPE: ${{ inputs.release_type }} + # Crowdin + CROWD_IN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} diff --git a/.github/workflows/internal.gradle.version.yaml b/.github/workflows/internal.gradle.version.yaml new file mode 100644 index 0000000..bcbfe4f --- /dev/null +++ b/.github/workflows/internal.gradle.version.yaml @@ -0,0 +1,139 @@ +name: "[Gradle] Determine Build Version" + +on: + workflow_call: + inputs: + image: + description: Which image to run the different tasks on (image must support bash) + type: string + required: true + version_suffix: + description: The version suffix + type: string + required: true + increment_version: + description: How to increment the version, or none if no version increment is necessary + type: string + required: true + outputs: + minecraft_version: + description: The minecraft version string + value: ${{ jobs.compute-version.outputs.minecraft_version }} + current_mod_version: + description: The current mod version string + value: ${{ jobs.compute-version.outputs.current_mod_version }} + current_tag_version: + description: The current tag version string + value: ${{ jobs.compute-version.outputs.current_tag_version }} + current_full_version: + description: The current full version string + value: ${{ jobs.compute-version.outputs.current_full_version }} + next_tag_version: + description: The next tag version string + value: ${{ jobs.compute-version.outputs.next_tag_version }} + next_mod_version: + description: The next mod version string + value: ${{ jobs.compute-version.outputs.next_mod_version }} + next_full_version: + description: The next full version string + value: ${{ jobs.compute-version.outputs.next_mod_version }} + release_name: + description: The name for the release version + value: ${{ jobs.compute-version.outputs.release_name }} + +permissions: + contents: read + +jobs: + compute-version: + runs-on: ${{ inputs.image }} + outputs: + minecraft_version: ${{ steps.getMinecraftVersion.outputs.version }} + current_mod_version: ${{ steps.getModVersion.outputs.version }} + current_tag_version: v${{ steps.getMinecraftVersion.outputs.version }}-${{ steps.getModVersion.outputs.version }} + current_full_version: ${{ steps.generateFullVersion.outputs.current_full_version }} + next_mod_version: ${{ steps.getNextModVersion.outputs.version }} + next_tag_version: v${{ steps.getMinecraftVersion.outputs.version }}-${{ steps.getNextModVersion.outputs.version }} + next_full_version: ${{ steps.generateFullVersion.outputs.next_full_version }} + release_name: ${{ steps.generateReleaseName.outputs.release_name }} + steps: + - name: "📦 Checkout" + uses: actions/checkout@v4 + + - name: "📦 Fetch tags" # See https://github.com/actions/checkout/issues/2041 + run: git fetch --tags + + - id: getVersionOrdering + name: "⚙️ Get version ordering" + run: | + uses_mc_version_order_first=$(cat gradle.properties | grep usesMCVersionOrderFirst | cut -d "=" -f 2) + if [ -z "$uses_mc_version_order_first" ]; then + uses_mc_version_order_first=false + fi + echo "Using MC version order first: $uses_mc_version_order_first" + echo "uses_mc_version_order_first=$uses_mc_version_order_first" >> "$GITHUB_OUTPUT" + + - id: getMinecraftVersion + name: "⚙️ Generate Minecraft version" + run: | + version=$(cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2) + echo "Minecraft version: $version" + echo "version=$version" >> "$GITHUB_OUTPUT" + + - id: getModVersion + name: "⚙️ Get mod version" + run: | + version=$(git describe --abbrev=0 --tags $(git rev-list --tags=${{ github.ref_name }} --max-count=1) | sed s/v${{ steps.getMinecraftVersion.outputs.version }}-//) + echo "Current mod version: $version" + echo "version=$version" >> "$GITHUB_OUTPUT" + + - id: generateModVersion + name: "⚙️ Generate next mod version" + uses: cbrgm/semver-bump-action@v1.0.43 + if: ${{ inputs.increment_version != 'none'}} + with: + current-version: ${{ steps.getModVersion.outputs.version }} + bump-level: ${{ inputs.increment_version }} + + - id: getNextModVersion + name: "⚙️ Get next mod version" + run: | + version=${{ steps.generateModVersion.conclusion != 'skipped' && steps.generateModVersion.outputs.new_version || steps.getModVersion.outputs.version }} + echo "Next mod version: $version" + echo "version=$version" >> "$GITHUB_OUTPUT" + - id: generateFullVersion + + - id: generateFullVersion + name: "Generate full version" + run: | + if [[ -n "${{inputs.version_suffix}}" ]] + then + if [ ${{ steps.getVersionOrdering.outputs.uses_mc_version_order_first }} == "true" ] + then + current_full_version="${{ steps.getMinecraftVersion.outputs.version }}-${{ steps.getModVersion.outputs.version }}-${{ inputs.version_suffix }}" + next_full_version="${{ steps.getMinecraftVersion.outputs.version }}-${{ steps.getNextModVersion.outputs.version }}-${{ inputs.version_suffix }}" + else + current_full_version="${{ steps.getModVersion.outputs.version }}-${{ steps.getMinecraftVersion.outputs.minecraft_version }}-${{ inputs.version_suffix }}" + next_full_version="${{ steps.getNextModVersion.outputs.version }}-${{ steps.getMinecraftVersion.outputs.minecraft_version }}-${{ inputs.version_suffix }}" + fi + else + if [ ${{ steps.getVersionOrdering.outputs.uses_mc_version_order_first }} == "true" ] + then + current_full_version="${{ steps.getMinecraftVersion.outputs.minecraft_version }}-${{ steps.getModVersion.outputs.version }}" + next_full_version="${{ steps.getMinecraftVersion.outputs.minecraft_version }}-${{ steps.getNextModVersion.outputs.version }}" + else + current_full_version="${{ steps.getModVersion.outputs.version }}-${{ steps.getMinecraftVersion.outputs.minecraft_version }}" + next_full_version="${{ steps.getNextModVersion.outputs.version }}-${{ steps.getMinecraftVersion.outputs.minecraft_version }}" + fi + fi + echo "Current full version: ${next_full_version}" + echo "Next full version: ${next_full_version}" + echo "current_full_version=${current_full_version}" >> "$GITHUB_OUTPUT" + echo "next_full_version=${next_full_version}" >> "$GITHUB_OUTPUT" + + - id: generateReleaseName + name: "⚙️ Generate release name" + run: | + release_name="Version ${{ steps.getNextModVersion.outputs.version }} for Minecraft ${{ steps.getMinecraftVersion.outputs.version }}" + echo "Release name: $release_name" + echo "release_name=$release_name" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/project.build.yaml b/.github/workflows/project.build.yaml new file mode 100644 index 0000000..609e8aa --- /dev/null +++ b/.github/workflows/project.build.yaml @@ -0,0 +1,85 @@ +name: "[Project] Build project & pre-release" + +on: + workflow_call: + inputs: + image: + description: Which image to run the different tasks on (image must support bash) + type: string + required: false + default: ubuntu-latest + java: + description: The version of Java to use to run Gradle + type: string + required: false + default: "21" + version_suffix: + description: The suffix to put behind the branch, defaults to the pull request number. If not a pull request you must define this by hand. + type: string + required: false + default: ${{ github.event.number }} + create_prerelease: + description: Whether to make a prerelease version or not + type: boolean + required: false + default: false + gradle_build_task: + description: The name of the gradle build task to use + type: string + required: false + default: build + gradle_publish_task: + description: The name of the gradle publish task to use + type: string + required: false + default: publish + secrets: + GRADLE_ENCRYPTION_KEY: + description: The AES key to enable Gradle cache encryption + required: false + +permissions: + contents: read + +jobs: + validate-inputs: + runs-on: ${{ inputs.image }} + if: | + (inputs.image == '') || + (inputs.java <= 0) || + (inputs.version_suffix == '') || + (inputs.gradle_build_task == '') && + (inputs.gradle_publish_task == '') + steps: + - run: exit 1 + + compute-version: + uses: ./.github/workflows/internal.gradle.version.yaml + with: + image: ${{ inputs.image }} + version_suffix: ${{ inputs.version_suffix }}-rc + increment_version: ${{ inputs.create_prerelease && 'prepatch' || 'none' }} + secrets: inherit + + build: + needs: + - compute-version + uses: ./.github/workflows/internal.gradle.build.yaml + with: + image: ${{ inputs.image }} + java: ${{ inputs.java }} + gradle_build_task: ${{ inputs.gradle_build_task }} + version: ${{ needs.compute-version.outputs.next_full_version }} + secrets: inherit + + pre-release: + needs: + - compute-version + if: ${{ inputs.create_prerelease }} + uses: ./.github/workflows/internal.gradle.publish.yaml + with: + image: ${{ inputs.image }} + java: ${{ inputs.java }} + gradle_publish_task: ${{ inputs.gradle_publish_task }} + version: ${{ needs.compute-version.outputs.next_full_version }} + secrets: inherit diff --git a/.github/workflows/project.release.trigger.yaml b/.github/workflows/project.release.trigger.yaml new file mode 100644 index 0000000..73a825c --- /dev/null +++ b/.github/workflows/project.release.trigger.yaml @@ -0,0 +1,67 @@ +name: "[Project] Trigger automated releases" + +on: + workflow_call: + inputs: + image: + description: Which image to run the different tasks on (image must support bash) + type: string + required: false + default: ubuntu-latest + release_yaml_file: + description: The release yaml file within your project to trigger + type: string + required: false + default: project.release.yaml + branch_pattern: + description: The pattern to select which branches to trigger a release for + type: string + required: true + +env: + GH_TOKEN: ${{ github.token }} + +permissions: + actions: write + +jobs: + validate-inputs: + runs-on: ${{ inputs.image }} + if: | + (inputs.image == '') || + (inputs.release_yaml_file == '') || + (inputs.branch_pattern == '') + steps: + - run: exit 1 + + determine-branches: + runs-on: ${{ inputs.image }} + outputs: + branches: ${{ steps.branchNames.outputs.branches }} + steps: + - name: "📦 Checkout" + uses: actions/checkout@v4 + + - id: branchNames + name: "⚙️ Get branch names" + run: | + branches=($(git branch -r -l --format="'%(refname:lstrip=3)'" origin/${{ inputs.branch_pattern }})) + branches_raw=$(printf ",%s" "${branches[@]}") + branches_json=[${branches_raw:1}] + echo $branches_json + echo "branches=${branches_json}" >> "$GITHUB_OUTPUT" + + trigger-release: + runs-on: ${{ inputs.image }} + needs: + - determine-branches + strategy: + matrix: + branch: ${{ fromJson(needs.determine-branches.outputs.branches) }} + continue-on-error: true + steps: + - name: "📦 Checkout" + uses: actions/checkout@v4 + + - name: "🚀 Trigger release workflows" + run: gh workflow run ${{ inputs.release_yaml_file }} -r ${{ matrix.branch }} diff --git a/.github/workflows/project.release.yaml b/.github/workflows/project.release.yaml new file mode 100644 index 0000000..48a305f --- /dev/null +++ b/.github/workflows/project.release.yaml @@ -0,0 +1,203 @@ +name: "[Project] Release new version" + +on: + workflow_call: + inputs: + image: + description: Which image to run the different tasks on (image must support bash) + required: false + type: string + default: ubuntu-latest + java: + description: The version of Java to use to run Gradle + required: true + type: number + default: 21 + gradle_publish_task: + description: The name of the gradle publish task to use + type: string + required: false + default: publish + release_type: + description: The type of release to make on Curse, can either be 'beta' or 'release' + required: false + type: string + default: beta + increment_version: + description: How to increment the version, or none if no version increment is necessary. One of 'major', 'minor' or 'patch' + type: string + required: false + default: patch + secrets: + DISCORD_WEBHOOK: + required: true + MAVEN_USER: + required: true + MAVEN_PASSWORD: + required: true + CURSE_API_KEY: + required: true + CROWDIN_API_KEY: + required: true + GRADLE_ENCRYPTION_KEY: + description: The AES key to enable Gradle cache encryption + required: true + +permissions: + contents: write + statuses: write + +jobs: + validate-inputs: + runs-on: ${{ inputs.image }} + if: | + (inputs.image == '') || + (inputs.java <= 0) || + (inputs.gradle_publish_task == '') && + (inputs.release_type != 'beta' && inputs.release_type != 'release') || + (inputs.increment_version != 'major' && inputs.increment_version != 'minor' && inputs.increment_version != 'patch') + steps: + - run: exit 1 + + generate-release-information: + runs-on: ${{ inputs.image }} + outputs: + release_version_suffix: ${{ steps.generateReleaseSuffix.outputs.release_version_suffix }} + steps: + - id: generateReleaseSuffix + name: "⚙️ Compute release suffix" + run: | + release_version_suffix="alpha" + if [[ ${{ inputs.release_type }} == release ]]; then + release_version_suffix="" + elif [[ ${{ inputs.release_type }} == beta ]]; then + release_version_suffix="snapshot" + fi + echo "Release version suffix: ${release_version_suffix}" + echo "release_version_suffix=${release_version_suffix}" >> "$GITHUB_OUTPUT" + + compute-version: + needs: + - generate-release-information + uses: ./.github/workflows/internal.gradle.version.yaml + with: + image: ${{ inputs.image }} + version_suffix: ${{ needs.generate-release-information.outputs.release_version_suffix }} + increment_version: ${{ inputs.increment_version }} + + notify-build-start: + needs: + - compute-version + runs-on: ${{ inputs.image }} + steps: + - uses: neoforged/action-webhooks@v1 + name: "🔴 Send Discord start notification" + with: + webhook_url: ${{ secrets.DISCORD_WEBHOOK }} + status: started + version: ${{ needs.compute-version.outputs.next_full_version }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: neoforged/action-github-status@v1 + name: "🚧 Set pending status" + with: + authToken: ${{secrets.GITHUB_TOKEN}} + context: Publishing + state: pending + description: ${{ needs.compute-version.outputs.release_name }} + target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + + release: + needs: + - compute-version + runs-on: ${{ inputs.image }} + steps: + - name: "📦 Checkout" + uses: actions/checkout@v4 + + - name: "📦 Fetch tags" # See https://github.com/actions/checkout/issues/2041 + run: git fetch --tags + + - name: "⚙️ Configure Java" + run: echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV" + + - name: "⚙️ Configure Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: wrapper + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} + + - name: "⚙️ Generate release changelog" + run: | + echo "# Changelog" > changelog.md + echo "" >> changelog.md + echo "[Full Changelog](${{ github.server_url }}/${{ github.repository }}/compare/${{ needs.compute-version.outputs.current_full_version }}..${{ needs.compute-version.outputs.next_full_version }})" >> changelog.md + echo "" >> changelog.md + ./gradlew --build-cache outputChangelogHeader -PfullVersion=${{ needs.compute-version.outputs.next_full_version }} + echo "### Commits:" >> changelog.md + echo "" >> changelog.md + echo "$(git log --pretty=format:"- %s ([commit](${{ github.server_url }}/${{ github.repository }}/commit/%H))" v${{ needs.compute-version.outputs.current_mod_version }}..v${{ needs.compute-version.outputs.next_full_version }})" >> changelog.md + echo "" >> changelog.md + ./gradlew --build-cache outputChangelogFooter -PfullVersion=${{ needs.compute-version.outputs.next_full_version }} + sed -i -E "s|\(#([[:digit:]]+)\)|([#\1](${{ github.server_url }}/${{ github.repository }}/pull/\1))|" changelog.md + echo "Outputting full changelog" + cat changelog.md + + - name: "⚙️ Create tag" + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "maintainer+github@ldtteam.com" + git tag -f "v${{ needs.compute-version.outputs.next_full_version }}" + + - name: "🚀 Create GitHub release" + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ needs.compute-version.outputs.next_full_version }} + release_name: ${{ needs.compute-version.outputs.release_name }} + body_path: changelog.md + prerelease: ${{ inputs.release_type != 'release' }} + + publish: + needs: + - release + - compute-version + uses: ./.github/workflows/internal.gradle.publish.yaml + with: + image: ${{ inputs.image }} + java: ${{ inputs.java }} + version: ${{ needs.compute-version.outputs.next_full_version }} + gradle_publish_task: publish + release_type: ${{ inputs.release_type }} + secrets: + GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }} + JFROG_PUBLISH_USER: ${{ secrets.MAVEN_USER }} + JFROG_PUBLISH_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} + CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} + + notify-build-end: + needs: + - compute-version + - publish + if: ${{ always() }} + runs-on: ${{ inputs.image }} + steps: + - uses: neoforged/action-webhooks@v1 + name: "🔴 Send Discord end notification" + with: + webhook_url: ${{ secrets.DISCORD_WEBHOOK }} + status: ${{ needs.publish.result }} + version: "${{ needs.compute-version.outputs.next_full_version }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: neoforged/action-github-status@v1 + name: "🚧 Set build status" + with: + authToken: ${{ secrets.GITHUB_TOKEN }} + context: "Publishing" + state: ${{ needs.publish.result }} + description: ${{ needs.compute-version.outputs.release_name }} + target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/gradle/mod.gradle b/gradle/mod.gradle index b2d21fa..0ad15e6 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -267,34 +267,38 @@ group = project.modGroup def useMCVersionOrder = opc.isFeatureEnabled("MCVersionOrderFirst") -def versionNumber = opc.hasPropertySet("modVersion") ? opc.getProperty("modVersion") : "0.0.1" -def versionSuffix = opc.hasPropertySet("modVersionSuffix") ? opc.getProperty("modVersionSuffix") : "" -def versionString -if (versionSuffix == "") { - versionString = useMCVersionOrder - ? project.exactMinecraftVersion + "-" + versionNumber - : versionNumber + "-" + project.exactMinecraftVersion +if (opc.hasPropertySet("fullVersion")) { + version = opc.getProperty("fullVersion") } else { - versionString = useMCVersionOrder - ? project.exactMinecraftVersion + "-" + versionNumber + "-" + versionSuffix - : versionNumber + "-" + project.exactMinecraftVersion + "-" + versionSuffix -} - -if (opc.isFeatureEnabled("MCVersionBasedVersioning") - && opc.hasPropertySet("mcVersionElementIndex") - && opc.hasPropertySet("sourceVersionElementIndex") - && opc.hasPropertySet("sourceVersionName")) { - logger.lifecycle("MC based versioning active") - - version = opc.buildVersionNumberWithOffset( - versionString, - project.exactMinecraftVersion, - opc.getProperty("sourceVersionName"), - opc.getIntProperty("sourceVersionElementIndex"), - opc.getIntProperty("mcVersionElementIndex") - ) -} else { - version = versionString + def versionNumber = opc.hasPropertySet("modVersion") ? opc.getProperty("modVersion") : "0.0.1" + def versionSuffix = opc.hasPropertySet("modVersionSuffix") ? opc.getProperty("modVersionSuffix") : "" + def versionString + if (versionSuffix == "") { + versionString = useMCVersionOrder + ? project.exactMinecraftVersion + "-" + versionNumber + : versionNumber + "-" + project.exactMinecraftVersion + } else { + versionString = useMCVersionOrder + ? project.exactMinecraftVersion + "-" + versionNumber + "-" + versionSuffix + : versionNumber + "-" + project.exactMinecraftVersion + "-" + versionSuffix + } + + if (opc.isFeatureEnabled("MCVersionBasedVersioning") + && opc.hasPropertySet("mcVersionElementIndex") + && opc.hasPropertySet("sourceVersionElementIndex") + && opc.hasPropertySet("sourceVersionName")) { + logger.lifecycle("MC based versioning active") + + version = opc.buildVersionNumberWithOffset( + versionString, + project.exactMinecraftVersion, + opc.getProperty("sourceVersionName"), + opc.getIntProperty("sourceVersionElementIndex"), + opc.getIntProperty("mcVersionElementIndex") + ) + } else { + version = versionString + } } archivesBaseName = project.modId project.properties.file = [