Skip to content

Commit

Permalink
actions tm
Browse files Browse the repository at this point in the history
  • Loading branch information
ramidzkh committed Dec 16, 2022
1 parent 749af79 commit 5cdef71
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 195 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build
on:
- pull_request
- push

jobs:
build:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
run: apt install -y openjdk-17-jdk
- name: Use Gradle cache for faster builds
uses: actions/cache@v3
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@v3
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Build
run: ./gradlew build
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: arrp
path: build/libs/
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish

on:
release:
types:
- published

permissions:
contents: write

jobs:
publish:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
run: apt install -y openjdk-17-jdk
- name: Build
run: ./gradlew build
env:
ARRP_VERSION: ${{ github.event.release.tag_name }}
- name: Upload Release Artifact
uses: softprops/action-gh-release@v1
with:
files: build/libs/arrp-${{ github.event.release.tag_name }}.jar
tag_name: ${{ github.event.release.tag_name }}
- name: Upload to external sites
run: ./gradlew curseforge modrinth publishAllPublicationsToModmavenRepository
env:
ARRP_VERSION: ${{ github.event.release.tag_name }}
CURSEFORGE: ${{ secrets.CURSEFORGE }}
MODRINTH: ${{ secrets.MODRINTH }}
MODMAVEN: ${{ secrets.MODMAVEN }}
110 changes: 54 additions & 56 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,97 +1,95 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'maven-publish'
id "me.shedaniel.unified-publishing" version "0.1.+"
id("fabric-loom") version "1.0-SNAPSHOT"
id("me.shedaniel.unified-publishing") version "0.1.+"
id("maven-publish")
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
group = "net.devtech"
version = System.getenv("ARRP_VERSION") ?: "0.0.0"

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation include(fabricApi.module('fabric-api-base', project.fabric_version))
minecraft("com.mojang:minecraft:${minecraft_version}")
mappings("net.fabricmc:yarn:${yarn_mappings}:v2")
modImplementation("net.fabricmc:fabric-loader:${loader_version}")
modImplementation(include(fabricApi.module("fabric-api-base", fabric_version)))
}

processResources {
inputs.property "version", project.version
base {
archivesName.set("arrp")
}

filesMatching("fabric.mod.json") {
expand "version": project.version
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

withSourcesJar()
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

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

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

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
rename { "${it}_${base.archivesName.get()}"}
}
}


publishing {
publications {
mavenJava(MavenPublication) {
from components.java
from(components.java)
}
}

repositories {
maven {
def mavenUrl = project.hasProperty('maven_url') ? project.property('maven_url') : ""
url mavenUrl
if (mavenUrl.startsWith("http")) {
credentials {
username project.hasProperty('maven_username') ? project.property('maven_username') : ""
password project.hasProperty('maven_password') ? project.property('maven_password') : ""
}
name = "Project"
url = uri("${buildDir}/repo")
}

maven {
credentials {
username = ""
password = System.getenv("MODMAVEN")
}

name = "Modmaven"
url = "https://modmaven.dev/artifactory/local-releases/"
}
}
}

File file = file("tokens.properties")
if(file.exists()) {
Properties properties = new Properties()
try (InputStream stream = new FileInputStream(file)) {
properties.load(stream)
}
unifiedPublishing {
project {
gameVersions.add(minecraft_version)
gameVersions.add("fabric")

unifiedPublishing {
project {
gameVersions = ["1.19.3"]
gameLoaders = ["fabric"]
changelog.set("View changelog at [the release page](https://github.com/Devan-Kerman/ARRP/releases/tag/${version})")

mainPublication tasks.remapJar // Declares the publicated jar
mainPublication(tasks.remapJar)

var cfToken = properties.getProperty("cf_token")
if (cfToken != null) {
curseforge {
token = cfToken
id = "463113" // Required, must be a string, ID of CurseForge project
}
System.getenv("CURSEFORGE")?.with { String key ->
curseforge {
token.set(key)
id.set("463113")
}
}

var mrToken = properties.getProperty("mr_token")
if (mrToken != null) {
modrinth {
token = mrToken
id = "USLVyT7V" // Required, must be a string, ID of Modrinth project
}
System.getenv("MODRINTH")?.with { String key ->
modrinth {
token.set(key)
id.set("USLVyT7V")
}
}
}
}
}
8 changes: 2 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ minecraft_version=1.19.3
yarn_mappings=1.19.3+build.2
loader_version=0.14.11

#Fabric api
# Fabric api
fabric_version=0.68.1+1.19.3

# Mod Properties
mod_version=0.6.6
maven_group=net.devtech
archives_base_name=arrp
# Dependencies
org.gradle.jvmargs=-Xmx2G
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit 5cdef71

Please sign in to comment.