Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include git hash in snapshot build versions #2547

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/auto-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: ./.github/actions/build_setup
- name: Get Version
id: ver
run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT
run: echo "version=$(./gradlew -q printModVersion)" >> $GITHUB_OUTPUT
- name: Build
run: ./gradlew build --build-cache
- name: Publish to Maven
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- if: ${{ inputs.publishCurseForgeAndModrinth }}
name: Get Version
id: var
run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT
run: echo "version=$(./gradlew -q printModVersion)" >> $GITHUB_OUTPUT

- if: ${{ inputs.publishCurseForgeAndModrinth }}
name: mc-publish-forge
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
env:
SNAPSHOT: true
steps:
- uses: actions/checkout@v4
- name: Check Path Filter
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
ref: ${{ inputs.branch }}
- name: Get Version
id: ver
run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT
run: echo "version=$(./gradlew -q printModVersion)" >> $GITHUB_OUTPUT
- name: Build
run: ./gradlew assemble --build-cache
- name: Upload Build Artifacts
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'com.palantir.git-version'
alias libs.plugins.modDevGradle
alias libs.plugins.machete // automatic jar compressing on build
//alias libs.plugins.shadow
Expand All @@ -15,9 +16,9 @@ group = maven_group

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

// Formats the mod version to include the loader, Minecraft version, build number (if present), and '-SNAPSHOT-<timestamp>' if enabled.
// Formats the mod version to include SNAPSHOT and the git hash for snapshot builds
boolean isSnapshot = System.getenv("SNAPSHOT")
version = "${mod_version}" + (isSnapshot ? "-SNAPSHOT" : "")
version = "${mod_version}" + (isSnapshot ? "-SNAPSHOT-" + versionDetails().gitHash : "")

sourceSets {
// Include resources generated by data generators.
Expand Down
2 changes: 1 addition & 1 deletion gradle/scripts/resources.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def mod_description = getConfig("mod_description")
def mod_url = getConfig("mod_url")
def mod_issue_tracker = getConfig("mod_issue_tracker")

task printVersion {
task printModVersion {
doLast {
println mod_version
}
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pluginManagement {
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '2.0.21'
id 'com.palantir.git-version' version '3.1.0'
}
}

Expand Down