mirror of
https://github.com/TibiNonEst/cauldron-dyeing.git
synced 2024-11-24 11:37:19 -05:00
Improve build/publish
This commit is contained in:
parent
a230808ca7
commit
25527412e5
4 changed files with 112 additions and 28 deletions
22
.github/workflows/build-gradle.yml
vendored
22
.github/workflows/build-gradle.yml
vendored
|
@ -5,20 +5,34 @@ on: [ push, pull_request ]
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout latest commit
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
|
||||||
|
- name: Restore Gradle cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: ${{ runner.os }}-gradle
|
||||||
|
|
||||||
|
- name: Validate Gradle wrapper
|
||||||
|
uses: gradle/wrapper-validation-action@v1
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: build-artifacts
|
name: build-artifacts
|
||||||
path: ./build/libs
|
path: ./build/libs
|
||||||
|
|
32
.github/workflows/build-release.yml
vendored
32
.github/workflows/build-release.yml
vendored
|
@ -8,20 +8,40 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout latest commit
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: Restore Gradle cache
|
||||||
run: ./gradlew build
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: ${{ runner.os }}-gradle
|
||||||
|
|
||||||
|
- name: Validate Gradle wrapper
|
||||||
|
uses: gradle/wrapper-validation-action@v1
|
||||||
|
|
||||||
|
- name: Build and publish with Gradle
|
||||||
|
run: ./gradlew build publish modrinth curseforge
|
||||||
|
env:
|
||||||
|
MAVEN_URL: ${{ secrets.MAVEN_URL }}
|
||||||
|
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
|
||||||
|
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
||||||
|
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
|
||||||
|
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: AButler/upload-release-assets@v2.0
|
uses: AButler/upload-release-assets@v2.0
|
||||||
with:
|
with:
|
||||||
files: 'build/libs/!(*-@(dev|sources)).jar'
|
files: 'build/libs/!(*-sources).jar'
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
82
build.gradle
82
build.gradle
|
@ -3,6 +3,9 @@ plugins {
|
||||||
alias(libs.plugins.loom.quiltflower)
|
alias(libs.plugins.loom.quiltflower)
|
||||||
alias(libs.plugins.qmol)
|
alias(libs.plugins.qmol)
|
||||||
alias(libs.plugins.grgit)
|
alias(libs.plugins.grgit)
|
||||||
|
alias(libs.plugins.minotaur)
|
||||||
|
alias(libs.plugins.cursegradle)
|
||||||
|
id "maven-publish"
|
||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = project.archives_base_name
|
archivesBaseName = project.archives_base_name
|
||||||
|
@ -11,10 +14,10 @@ group = project.maven_group
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = 'Modrinth'
|
name = "Modrinth"
|
||||||
url = 'https://api.modrinth.com/maven'
|
url = "https://api.modrinth.com/maven"
|
||||||
content {
|
content {
|
||||||
includeGroup 'maven.modrinth'
|
includeGroup "maven.modrinth"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,16 +38,16 @@ loom {
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
inputs.property 'version', project.version
|
inputs.property "version", project.version
|
||||||
filteringCharset 'UTF-8'
|
filteringCharset "UTF-8"
|
||||||
|
|
||||||
filesMatching('fabric.mod.json') {
|
filesMatching("fabric.mod.json") {
|
||||||
expand 'version': project.version
|
expand "version": project.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
it.options.encoding = 'UTF-8'
|
it.options.encoding = "UTF-8"
|
||||||
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
||||||
it.options.release = 17
|
it.options.release = 17
|
||||||
}
|
}
|
||||||
|
@ -58,34 +61,79 @@ java {
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from('LICENSE') {
|
from("LICENSE") {
|
||||||
rename { "${it}_${project.archivesBaseName}"}
|
rename { "${it}_${project.archivesBaseName}"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getMetadata() {
|
modrinth {
|
||||||
def build_id = System.getenv('GITHUB_RUN_NUMBER')
|
projectId = "5AgJnN8I"
|
||||||
def workflow_id = System.getenv('GITHUB_WORKFLOW')
|
uploadFile = remapJar
|
||||||
|
}
|
||||||
|
tasks.modrinth.dependsOn remapJar
|
||||||
|
|
||||||
def metadata = libs.versions.minecraft.get()
|
def ENV = System.getenv()
|
||||||
|
curseforge {
|
||||||
|
if (ENV.CURSEFORGE_TOKEN) {
|
||||||
|
apiKey = ENV.CURSEFORGE_TOKEN
|
||||||
|
}
|
||||||
|
|
||||||
|
project {
|
||||||
|
id = "564870"
|
||||||
|
changelog = "No changelog provided"
|
||||||
|
releaseType = "release"
|
||||||
|
addGameVersion libs.versions.minecraft.get()
|
||||||
|
addGameVersion "Fabric"
|
||||||
|
addGameVersion "Quilt"
|
||||||
|
|
||||||
|
mainArtifact(jar) {
|
||||||
|
displayName = "Cauldron Dyeing ${project.mod_version}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks.curseforge.dependsOn remapJar
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = ENV.MAVEN_URL
|
||||||
|
credentials {
|
||||||
|
username = ENV.MAVEN_USERNAME
|
||||||
|
password = ENV.MAVEN_PASSWORD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getMetadata() {
|
||||||
|
def build_id = System.getenv("GITHUB_RUN_NUMBER")
|
||||||
|
def workflow_id = System.getenv("GITHUB_WORKFLOW")
|
||||||
|
|
||||||
|
def metadata = ""
|
||||||
|
|
||||||
// Release builds only
|
// Release builds only
|
||||||
if (workflow_id == 'build-release') {
|
if (workflow_id == "build-release") {
|
||||||
return metadata
|
return metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
if (build_id != null) {
|
if (build_id != null) {
|
||||||
metadata += "-build.${build_id}"
|
metadata += "build.${build_id}"
|
||||||
} else if (grgit != null) {
|
} else if (grgit != null) {
|
||||||
def head = grgit.head()
|
def head = grgit.head()
|
||||||
def id = head.abbreviatedId
|
def id = head.abbreviatedId
|
||||||
|
|
||||||
// Flag the build if the build tree is not clean
|
// Flag the build if the build tree is not clean
|
||||||
if (!grgit.status().clean) {
|
if (!grgit.status().clean) {
|
||||||
id += '-dirty'
|
id += "-dirty"
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata += "-${id}"
|
metadata += "${id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
|
@ -18,4 +18,6 @@ sodium = { module = "maven.modrinth:sodium", version.ref = "sodium" }
|
||||||
fabric_loom = { id = "fabric-loom", version = "0.12.+" }
|
fabric_loom = { id = "fabric-loom", version = "0.12.+" }
|
||||||
loom_quiltflower = { id = "io.github.juuxel.loom-quiltflower", version = "1.7.+" }
|
loom_quiltflower = { id = "io.github.juuxel.loom-quiltflower", version = "1.7.+" }
|
||||||
qmol = { id = "org.quiltmc.quilt-mappings-on-loom", version = "4.2.0" }
|
qmol = { id = "org.quiltmc.quilt-mappings-on-loom", version = "4.2.0" }
|
||||||
grgit = { id = "org.ajoberstar.grgit", version = "5.0.0" }
|
grgit = { id = "org.ajoberstar.grgit", version = "5.+" }
|
||||||
|
minotaur = { id = "com.modrinth.minotaur", version = "2.+" }
|
||||||
|
cursegradle = { id = "com.matthewprenger.cursegradle", version = "1.+" }
|
||||||
|
|
Loading…
Reference in a new issue