Skip to content

Commit

Permalink
change: Update version string
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed May 25, 2024
1 parent 02a162f commit f8462db
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
build:
if: github.repository_owner == 'FlashyReese'
runs-on: self-hosted
steps:
- name: Checkout Repository
Expand All @@ -20,11 +21,10 @@ jobs:
java-version: 21
check-latest: true
- name: Upload assets to releases
run: ./gradlew build publishAllPublicationsToFlashyReeseReleasesRepository
run: ./gradlew build publishAllPublicationsToFlashyReeseReleasesRepository -Pbuild.release
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
BUILD_RELEASE: ${{ github.event.prerelease == false }}
- name: Publish to Modrinth & CurseForge
uses: Kir-Antipov/[email protected]
with:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/self-hosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [ push ]

jobs:
build:
if: github.repository_owner == 'FlashyReese'
runs-on: self-hosted

steps:
Expand All @@ -17,8 +18,11 @@ jobs:
distribution: 'temurin'
java-version: 21
check-latest: true
- name: Build with Gradle
run: ./gradlew build
- name: Build and Publish with Gradle
run: ./gradlew build publishAllPublicationsToFlashyReeseSnapshotsRepository
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
- name: Upload Auild Artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
44 changes: 18 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
id 'org.ajoberstar.grgit' version '5.2.1'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
id 'signing'
Expand All @@ -9,7 +8,7 @@ sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

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

repositories {
Expand Down Expand Up @@ -94,35 +93,28 @@ publishing {
}
}

def getVersionMetadata() {
def build_id = System.getenv("GITHUB_RUN_NUMBER")
def createVersionString() {
def builder = new StringBuilder()

// CI builds only
if (build_id != null) {
return "build.${build_id}"
def isReleaseBuild = project.hasProperty("build.release")
def buildId = System.getenv("GITHUB_RUN_NUMBER")

if (isReleaseBuild) {
builder.append(mod_version)
} else {
builder.append(mod_version.split('-')[0])
builder.append("-snapshot")
}

if (grgit != null) {
def head = grgit.head()
def id = head.abbreviatedId
builder.append("+mc").append(minecraft_version)

// Flag the build if the build tree is not clean
if (!grgit.status().clean) {
id += "-dirty"
if (!isReleaseBuild) {
if (buildId != null) {
builder.append("-build.${buildId}")
} else {
builder.append("-local")
}

return "rev.${id}"
}

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

static def getVersionType(String version_type, String revision) {
version_type = version_type.trim().toLowerCase()
revision = revision.trim().toLowerCase()
if (version_type != "release") {
return "-${version_type}${revision}"
}
return ""
return builder.toString()
}
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ org.gradle.jvmargs=-Xmx1G
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
# Mod Properties
version_type=release
revision=1
mod_version=1.7.2
maven_group=me.flashyreese.mods
archives_base_name=reeses_sodium_options
Expand Down

0 comments on commit f8462db

Please sign in to comment.