Skip to content

Commit

Permalink
Automated publishing (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramidzkh authored Oct 4, 2022
1 parent 18f267d commit 7f1a6e5
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 64 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -16,6 +16,22 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 17
- name: Use Gradle cache for faster builds
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Setup Gradle Wrapper Cache
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Build
run: ./gradlew build
- name: Upload artifacts
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish

on:
release:
types:
- published

permissions:
contents: write

jobs:
publish:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Build
run: ./gradlew build
env:
FABRISHOT_VERSION: ${{ github.event.release.tag_name }}
- name: Upload Release Artifact
uses: softprops/action-gh-release@v1
with:
files: build/libs/fabrishot-${{ github.event.release.tag_name }}.jar
tag_name: ${{ github.event.release.tag_name }}
- name: Upload to external sites
run: ./gradlew curseforge modrinth
env:
FABRISHOT_VERSION: ${{ github.event.release.tag_name }}
CURSEFORGE: ${{ secrets.CURSEFORGE }}
MODRINTH: ${{ secrets.MODRINTH }}
125 changes: 125 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
plugins {
id("fabric-loom") version "1.0-SNAPSHOT"
id("com.matthewprenger.cursegradle") version "1.4.0"
id("com.modrinth.minotaur") version "2.4.4"
}

group = "me.ramidzkh"
version = System.getenv("FABRISHOT_VERSION") ?: "0.0.0"

repositories {
maven {
name = "TerraformersMC"
url = uri("https://maven.terraformersmc.com/releases/")

content {
includeGroup("com.terraformersmc")
}
}

maven {
name = "shedaniel"
url = uri("https://maven.shedaniel.me/")

content {
includeGroup("me.shedaniel.cloth")
}
}
}

dependencies {
minecraft("net.minecraft:minecraft:1.19.2")
mappings("net.fabricmc:yarn:1.19.2+build.1")
modImplementation("net.fabricmc:fabric-loader:0.14.7")

modImplementation("net.fabricmc.fabric-api:fabric-api:0.62.0+1.19.2")
modImplementation("com.terraformersmc:modmenu:4.0.6")
modImplementation("me.shedaniel.cloth:cloth-config-fabric:8.2.88")
}

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

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

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

from("LICENSE")

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

////////////////
// CurseForge
System.getenv("CURSEFORGE")?.with { String key ->
curseforge {
apiKey = key

project {
id = "404870"
changelogType = "markdown"
changelog = "View changelog at [the release page](https://github.com/ramidzkh/fabrishot/releases/tag/${version})"

if (version.contains("alpha")) {
releaseType = "alpha"
} else if (version.contains("beta")) {
releaseType = "beta"
} else {
releaseType = "release"
}

addGameVersion("1.19.2")
addGameVersion("1.19.1")
addGameVersion("1.19")
addGameVersion("Fabric")

mainArtifact(remapJar) {
displayName = "${project.version}"

relations {
requiredDependency("fabric-api")
optionalDependency("modmenu")
optionalDependency("cloth-config")
}
}
}
}
}

////////////////
// Modrinth
modrinth {
token.set(System.getenv("MODRINTH"))
projectId.set("fabrishot")
changelog.set("View changelog at [the release page](https://github.com/ramidzkh/fabrishot/releases/tag/${version})")
versionNumber.set(project.version)

if (version.contains("alpha")) {
versionType.set("alpha")
} else if (version.contains("beta")) {
versionType.set("beta")
} else {
versionType.set("release")
}

uploadFile.set(remapJar)
gameVersions.addAll(["1.19.2", "1.19.1", "1.19"])

dependencies {
required.project("fabric-api")
optional.project("modmenu")
optional.project("cloth-config")
}
}

tasks.modrinth.onlyIf {
System.getenv("MODRINTH")
}
60 changes: 0 additions & 60 deletions build.gradle.kts

This file was deleted.

6 changes: 3 additions & 3 deletions settings.gradle.kts → settings.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
rootProject.name = "fabrishot"

pluginManagement {
repositories {
gradlePluginPortal()
jcenter()
mavenCentral()

maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
}
}

rootProject.name = "fabrishot"

0 comments on commit 7f1a6e5

Please sign in to comment.