Skip to content

Commit

Permalink
Added alpha releases
Browse files Browse the repository at this point in the history
  • Loading branch information
OakLoaf committed Sep 18, 2024
1 parent 290d6bd commit 1b5eac2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/version-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,18 @@ jobs:
chmod +x ./gradlew
./gradlew shadowJar
# - name: Post GitHub Release
# uses: svenstaro/upload-release-action@v2
# if: env.TAG_EXISTS == 'false'
# with:
# repo_token: ${{ secrets.REPO_TOKEN }}
# file: build/libs/*.jar
# file_glob: true
# asset_name: PluginUpdater-${{ env.VERSION }}
# tag: v${{ env.VERSION }}
# overwrite: false
- name: Post GitHub Release
uses: svenstaro/upload-release-action@v2
if: env.TAG_EXISTS == 'false'
with:
repo_token: ${{ secrets.REPO_TOKEN }}
file: build/libs/*.jar
file_glob: true
asset_name: PluginUpdater-${{ env.VERSION }}
tag: v${{ env.VERSION }}
overwrite: false

- name: Post Modrinth Release
if: env.TAG_EXISTS == 'false'
run: |
chmod +x ./gradlew
./gradlew modrinth
32 changes: 27 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import java.io.BufferedReader
import java.io.InputStreamReader

plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow") version("8.1.1")
id("com.modrinth.minotaur") version("2.+")
id("com.github.johnrengelman.shadow") version ("8.1.1")
id("com.modrinth.minotaur") version ("2.+")
}

allprojects {
Expand Down Expand Up @@ -80,7 +83,7 @@ tasks {
archiveFileName.set("${project.name}-${project.version}.jar")
}

processResources{
processResources {
expand(project.properties)

inputs.property("version", rootProject.version)
Expand All @@ -104,9 +107,15 @@ publishing {
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("IBSpJfbm")
versionNumber.set(rootProject.version.toString())
versionNumber.set(
if (System.getenv("TAG_EXISTS") == "false") {
rootProject.version.toString()
} else {
rootProject.version.toString() + "-" + getCurrentCommitHash()
}
)
uploadFile.set(file("build/libs/${project.name}-${project.version}.jar"))
versionType.set("release")
versionType.set(if (System.getenv("TAG_EXISTS") == "false") "release" else "false")
gameVersions.addAll(
"1.18", "1.18.1", "1.18.2",
"1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4",
Expand All @@ -115,4 +124,17 @@ modrinth {
)
loaders.addAll("spigot", "paper", "purpur")
syncBodyFrom.set(rootProject.file("README.md").readText())
}

fun getCurrentCommitHash(): String {
val process = ProcessBuilder("git", "rev-parse", "HEAD").start()
val reader = BufferedReader(InputStreamReader(process.inputStream))
val commitHash = reader.readLine()
reader.close()
process.waitFor()
if (process.exitValue() == 0) {
return commitHash ?: ""
} else {
throw IllegalStateException("Failed to retrieve the commit hash.")
}
}

0 comments on commit 1b5eac2

Please sign in to comment.