Skip to content

Commit

Permalink
More build and publish tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Jan 1, 2023
1 parent be46ee0 commit c5f3e6f
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 63 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/publish-curseforge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: publish-curseforge

on:
workflow_dispatch:
inputs:
version:
description: 'Mod Version'
required: true
default: '0.0.0'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ubuntu-latest-gradle-

- name: Publish to Curseforge (Forge)
run: ./gradlew -Psemver='${{ github.event.inputs.version }}' forge:curseforge
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
CHANGELOG: ${{ github.event.release.body }}

- name: Publish to Curseforge (Fabric)
run: ./gradlew -Psemver='${{ github.event.inputs.version }}' fabric:curseforge
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
CHANGELOG: ${{ github.event.release.body }}
41 changes: 41 additions & 0 deletions .github/workflows/publish-modrinth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: publish-modrinth

on:
workflow_dispatch:
inputs:
version:
description: 'Mod Version'
required: true
default: '0.0.0'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ubuntu-latest-gradle-

- name: Publish to modrinth (Forge)
run: ./gradlew -Psemver='${{ github.event.inputs.version }}' forge:modrinth
env:
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }}
CHANGELOG: ${{ github.event.release.body }}

- name: Publish to modrinth (Fabric)
run: ./gradlew -Psemver='${{ github.event.inputs.version }}' fabric:modrinth
env:
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }}
CHANGELOG: ${{ github.event.release.body }}
33 changes: 20 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Extract Version from Tag
uses: rishabhgupta/split-by@v1
id: split_tag
with:
string: ${{ github.event.release.tag_name }}
split-by: '/'

- name: Set up JDK
uses: actions/setup-java@v1
with:
Expand All @@ -27,7 +34,7 @@ jobs:
key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ubuntu-latest-gradle-
- name: Build with Gradle
run: ./gradlew -Psemver='${{ github.event.release.tag_name }}' build
run: ./gradlew -Psemver='${{ steps.split_tag.outputs._1 }}' build

- name: Remove extra JARs
run: |
Expand All @@ -43,38 +50,38 @@ jobs:
with:
asset_paths: '["./forge/build/libs/*.jar","./fabric/build/libs/*.jar"]'

- name: Publish to Github Packages
run: gradle -Psemver='${{ github.event.release.tag_name }}' forge:publish
- name: Publish to Github Packages (Forge)
run: gradle -Psemver='${{ steps.split_tag.outputs._1 }}' forge:publish
env:
GITHUB_MAVEN_URL: 'https://maven.pkg.github.com/${{ github.repository }}'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to Github Packages
run: gradle -Psemver='${{ github.event.release.tag_name }}' fabric:publish
- name: Publish to Github Packages (Fabric)
run: gradle -Psemver='${{ steps.split_tag.outputs._1 }}' fabric:publish
env:
GITHUB_MAVEN_URL: 'https://maven.pkg.github.com/${{ github.repository }}'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to Curseforge
run: ./gradlew -Psemver='${{ github.event.release.tag_name }}' forge:curseforge
- name: Publish to Curseforge (Forge)
run: ./gradlew -Psemver='${{ steps.split_tag.outputs._1 }}' forge:curseforge
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
CHANGELOG: ${{ github.event.release.body }}

- name: Publish to Curseforge
run: ./gradlew -Psemver='${{ github.event.release.tag_name }}' fabric:curseforge
- name: Publish to Curseforge (Fabric)
run: ./gradlew -Psemver='${{ steps.split_tag.outputs._1 }}' fabric:curseforge
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
CHANGELOG: ${{ github.event.release.body }}

- name: Publish to modrinth
run: ./gradlew -Psemver='${{ github.event.release.tag_name }}' forge:modrinth
- name: Publish to modrinth (Forge)
run: ./gradlew -Psemver='${{ steps.split_tag.outputs._1 }}' forge:modrinth
env:
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }}
CHANGELOG: ${{ github.event.release.body }}

- name: Publish to modrinth
run: ./gradlew -Psemver='${{ github.event.release.tag_name }}' fabric:modrinth
- name: Publish to modrinth (Fabric)
run: ./gradlew -Psemver='${{ steps.split_tag.outputs._1 }}' fabric:modrinth
env:
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }}
CHANGELOG: ${{ github.event.release.body }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 Florian "Sangar" Nücke
Copyright (c) 2021-2023 Florian "Sangar" Nücke

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
34 changes: 30 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.0-SNAPSHOT" apply false
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
id "com.modrinth.minotaur" version "2.5.0" apply false
}

architectury {
Expand All @@ -24,25 +26,35 @@ def getGitRef() {
try {
final def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
commandLine "git", "rev-parse", "--short", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim()
} catch (final Throwable ignored) {
return 'unknown'
return "unknown"
}
}

allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "com.matthewprenger.cursegradle"
apply plugin: "com.modrinth.minotaur"
apply plugin: "maven-publish"

archivesBaseName = rootProject.archives_base_name
archivesBaseName = "${rootProject.archives_base_name}-MC${rootProject.minecraft_version}-${project.name}"
version = "${rootProject.semver}+${getGitRef()}"
group = rootProject.maven_group

repositories {
maven {
url "https://cursemaven.com"
content { includeGroup "curse.maven" }
}
}

dependencies {
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
}

tasks.withType(JavaCompile) {
Expand All @@ -53,4 +65,18 @@ allprojects {
java {
withSourcesJar()
}

jar {
from("LICENSE") {
rename { "${it}_${rootProject.archivesBaseName}" }
}
}

idea {
module {
for (final String exclude in ["out", "logs"]) {
excludeDirs += file(exclude)
}
}
}
}
17 changes: 0 additions & 17 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ loom {
}

dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
}

publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}
22 changes: 14 additions & 8 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.matthewprenger.cursegradle" version "1.4.0"
id "com.modrinth.minotaur" version "2.2.0"
}

project.archivesBaseName = "${rootProject.archives_base_name}-MC${rootProject.minecraft_version}-${project.name}"

architectury {
platformSetupLoomIde()
fabric()
Expand Down Expand Up @@ -77,6 +73,7 @@ publishing {
from components.java
}
}

repositories {
maven {
name = "GitHubPackages"
Expand All @@ -96,13 +93,21 @@ curseforge {
releaseType = "release"
changelogType = "markdown"
changelog = System.getenv("CHANGELOG") ?: "Changelog not available."
addGameVersion project.name
addGameVersion "Fabric"
addGameVersion rootProject.minecraft_version
addGameVersion "Java 17"
relations {
requiredDependency "fabric-api"
requiredDependency "architectury-api"
requiredDependency "forge-config-api-port-fabric"
}
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
afterEvaluate {
uploadTask.dependsOn(remapJar)
}
}
options {
forgeGradleIntegration = false
}
}

Expand All @@ -113,10 +118,11 @@ modrinth {
versionNumber = "MC${rootProject.minecraft_version}-${project.name}-${rootProject.semver}"
versionName = "${rootProject.archives_base_name}-${project.version}"
versionType = "release"
uploadFile = jar
uploadFile = remapJar
gameVersions = [rootProject.minecraft_version]
loaders = ["fabric"]
dependencies {
required.project "P7dR8mSH" // Fabric API
required.project "lhGA9TYQ" // Architectury API
required.project "fabric-api"
required.project "architectury-api"
}
}
25 changes: 7 additions & 18 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.modrinth.minotaur' version '2.2.0'
}

project.archivesBaseName = "${rootProject.archives_base_name}-MC${rootProject.minecraft_version}-${project.name}"

architectury {
platformSetupLoomIde()
forge()
Expand Down Expand Up @@ -60,18 +56,6 @@ remapJar {

jar {
classifier "dev"

manifest {
attributes([
'Specification-Title' : 'MarkdownManual',
'Specification-Vendor' : 'Sangar',
'Specification-Version' : '1',
'Implementation-Title' : rootProject.archives_base_name,
'Implementation-Version' : "${rootProject.semver}",
'Implementation-Vendor' : 'Sangar',
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}

sourcesJar {
Expand Down Expand Up @@ -119,6 +103,10 @@ curseforge {
relations {
requiredDependency "architectury-api"
}
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
afterEvaluate {
uploadTask.dependsOn(remapJar)
}
}
}

Expand All @@ -129,9 +117,10 @@ modrinth {
versionNumber = "MC${rootProject.minecraft_version}-${project.name}-${rootProject.semver}"
versionName = "${rootProject.archives_base_name}-${project.version}"
versionType = "release"
uploadFile = jar
uploadFile = remapJar
gameVersions = [rootProject.minecraft_version]
loaders = ["forge"]
dependencies {
required.project "lhGA9TYQ" // Architectury API
required.project "architectury-api"
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fabric_api_version=0.70.0+1.19.2
forge_version=1.19.2-43.2.3

curse_project_id=502485
modrinth_project_id=nPQ9xkPg
modrinth_project_id=markdownmanual

# Set by build pipeline.
semver=0.0.0
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ include("common")
include("fabric")
include("forge")

rootProject.name = "markdown_manual"
rootProject.name = archives_base_name

0 comments on commit c5f3e6f

Please sign in to comment.