diff options
author | Linnea Gräf <nea@nea.moe> | 2024-07-01 20:29:11 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-07-01 20:29:11 +0200 |
commit | c7efda4ab706ffef50f4188d09f9b234020cb4cb (patch) | |
tree | dc4909f2fa5cbf9dd69322c66465ec6ec6fb123b | |
parent | d1738866ab1101ea847d2fa1505e323d75c2b10a (diff) | |
download | veloxcaelo-c7efda4ab706ffef50f4188d09f9b234020cb4cb.tar.gz veloxcaelo-c7efda4ab706ffef50f4188d09f9b234020cb4cb.tar.bz2 veloxcaelo-c7efda4ab706ffef50f4188d09f9b234020cb4cb.zip |
Add github action and version thingy
-rw-r--r-- | .github/workflows/build.yml | 24 | ||||
-rw-r--r-- | .github/workflows/release.yml | 34 | ||||
-rw-r--r-- | build.gradle.kts | 19 |
3 files changed, 76 insertions, 1 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3b5c147 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: Run Gradle Build +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4.1.1 + + - name: Setup Java + uses: actions/setup-java@v4.0.0 + with: + distribution: temurin + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Execute Gradle build + run: ./gradlew build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5f04e13 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Upload release files +on: + release: + types: [published] + +jobs: + build: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4.1.1 + + - name: Setup Java + uses: actions/setup-java@v4.0.0 + with: + distribution: temurin + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Execute Gradle build + run: ./gradlew clean build + + - uses: Kir-Antipov/mc-publish@v3.3 + with: + modrinth-id: r4AQF5mj + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} + files: 'build/-libs/*.jar' + loaders: forge + game-versions: 1.8.9 diff --git a/build.gradle.kts b/build.gradle.kts index 4a8c6f6..ffea384 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask +import java.io.ByteArrayOutputStream plugins { kotlin("jvm") version "1.9.22" @@ -8,8 +9,24 @@ plugins { id("xyz.wagyourtail.unimined") version "1.2.0-SNAPSHOT" } + +fun cmd(vararg args: String): String? { + val output = ByteArrayOutputStream() + val r = exec { + this.commandLine(args.toList()) + this.isIgnoreExitValue = true + this.standardOutput = output + this.errorOutput = ByteArrayOutputStream() + } + return if (r.exitValue == 0) output.toByteArray().decodeToString().trim() + else null +} + +val tag = cmd("git", "describe", "--tags", "HEAD") +val hash = cmd("git", "rev-parse", "--short", "HEAD")!! +val isSnapshot = tag == null || hash in tag group = "moe.nea" -version = "1.0.2" +version = (if (isSnapshot) hash else tag!!) repositories { maven("https://jitpack.io") |