Skip to content

Commit

Permalink
change: Tag build artifacts more thoroughly
Browse files Browse the repository at this point in the history
The mod's version string now includes extra information about the sources used
to build the mod. If available, it will include the checked out revision in Git
and whether or not the source tree was dirty. If no information about the build
can be determined, the identifier "unknown" will be used.

This is being done because too many players, against our recommendation, are
downloading CI artifacts or compiling the mod themselves for daily use, and
are unable to provide any information about where the build came from when they
inevitably ask for technical support. Not having this information available to us
makes it impossible to diagnose issues over time and creates significant burden.

In the future, this information will be presented in the F3 screen.
  • Loading branch information
jellysquid3 committed Mar 20, 2021
1 parent 8efced1 commit 12886a1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 8
- name: Build with Gradle
- name: Build artifacts
run: ./gradlew build
- name: Upload build artifacts
uses: actions/upload-artifact@v1
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 8
- name: Upload assets to CurseForge
- name: Build artifacts
run: ./gradlew build
env:
BUILD_RELEASE: ${{ github.event.prerelease == false }}
- name: Upload assets to GitHub
uses: AButler/[email protected]
with:
Expand Down
70 changes: 37 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
plugins {
id 'fabric-loom' version '0.5.28'
id 'fabric-loom' version '0.6-SNAPSHOT'
id 'org.ajoberstar.grgit' version '4.1.0'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = "${project.archives_base_name}-mc${project.minecraft_version}"
version = project.mod_version
version = "${$project.mod_version}+${getVersionMetadata()}"
group = project.maven_group

def build_release = System.getenv("BUILD_RELEASE") == "true"
def build_id = System.getenv("BUILD_ID")

if (!build_release) {
version += "-SNAPSHOT"
}

if (build_id != null) {
version += "+build.${build_id}"
}

minecraft {
refmapName = "mixins.sodium.refmap.json"
accessWidener = file("src/main/resources/sodium.accesswidener")
Expand All @@ -32,20 +22,6 @@ dependencies {
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
}

processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"

expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

if (project.use_third_party_mods) {
repositories {
maven { url = "https://jitpack.io" }
Expand All @@ -60,21 +36,49 @@ if (project.use_third_party_mods) {
}
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
java {
withSourcesJar()
}

jar {
from "LICENSE.txt"
}

def getVersionMetadata() {
def build_id = System.getenv("GITHUB_RUN_NUMBER")

// CI builds only
if (build_id != null) {
return "build.${build_id}"
}

if (grgit == null) {
def head = grgit.head()
def id = head.abbreviatedId

// Flag the build if the build tree is not clean
if (!grgit.status().clean) {
id += "-dirty"
}

return "rev.${id}"
}

// No tracking information could be found about the build
return "unknown"
}

0 comments on commit 12886a1

Please sign in to comment.