Skip to content

Commit

Permalink
Quick and dirty backport of new publishing workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Sep 7, 2023
1 parent 3a63793 commit 3476f81
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 266 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build
41 changes: 0 additions & 41 deletions .github/workflows/publish-curseforge.yml

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/publish-modrinth.yml

This file was deleted.

76 changes: 33 additions & 43 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,79 +9,69 @@ jobs:
name: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Extract Version from Tag
uses: rishabhgupta/split-by@v1
id: split_tag
with:
string: ${{ github.event.release.tag_name }}
split-by: '/'
run: |
tag=${{ github.event.release.tag_name }}
parts=(${tag//\// })
echo "mc_version=${parts[0]}" >> $GITHUB_OUTPUT
echo "mod_version=${parts[1]}" >> $GITHUB_OUTPUT
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
distribution: temurin
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
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ubuntu-latest-gradle-
- name: Build with Gradle
run: ./gradlew -Psemver='${{ steps.split_tag.outputs._1 }}' build
run: ./gradlew -Psemver='${{ steps.split_tag.outputs.mod_version }}' build

- name: Remove extra JARs
run: |
rm fabric/build/libs/*-dev-shadow.jar
rm fabric/build/libs/*-sources.jar
rm forge/build/libs/*-dev-shadow.jar
rm forge/build/libs/*-sources.jar
- name: Add Artifacts to Github Release
uses: alexellis/upload-assets@0.3.0
uses: alexellis/upload-assets@0.4.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["./forge/build/libs/*.jar","./fabric/build/libs/*.jar"]'
asset_paths: '["./forge/build/libs/*.jar","./fabric/build/libs/*.jar","./common/build/libs/*-api.jar"]'

- 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 Curseforge and Minotaur (Forge)
uses: Kir-Antipov/[email protected]
with:
name: ${{ github.event.repository.name }}-MC${{ steps.split_tag.outputs.mc_version }}-${{ steps.split_tag.outputs.mod_version }}
version: MC${{ steps.split_tag.outputs.mc_version }}-forge-${{ steps.split_tag.outputs.mod_version }}
java: Java 17

- 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 }}
files: |
forge/build/libs/*.jar
- 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 }}
modrinth-token: ${{ secrets.MODRINTH_API_KEY }}
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}

- 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 Curseforge and Minotaur (Fabric)
uses: Kir-Antipov/[email protected]
with:
name: ${{ github.event.repository.name }}-MC${{ steps.split_tag.outputs.mc_version }}-${{ steps.split_tag.outputs.mod_version }}
version: MC${{ steps.split_tag.outputs.mc_version }}-fabric-${{ steps.split_tag.outputs.mod_version }}
java: Java 17

- 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 }}
files: |
fabric/build/libs/*.jar
- 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 }}
modrinth-token: ${{ secrets.MODRINTH_API_KEY }}
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ allprojects {
options.release.set(17)
}

java {
withSourcesJar()
}

jar {
from("LICENSE") {
rename { "${it}_${rootProject.archivesBaseName}" }
Expand Down
68 changes: 0 additions & 68 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,76 +82,8 @@ jar {
classifier "dev"
}

sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}

publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = "${mod_id}-${rootProject.minecraft_version}-${project.name}"
from components.java
}
}

repositories {
maven {
name = "GitHubPackages"
url = System.getenv("GITHUB_MAVEN_URL") ?: ""
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

curseforge {
apiKey = System.getenv("CURSEFORGE_API_KEY") ?: ""
project {
id = rootProject.curse_project_id
releaseType = "release"
changelogType = "markdown"
changelog = System.getenv("CHANGELOG") ?: "Changelog not available."
addGameVersion "Fabric"
addGameVersion rootProject.minecraft_version
addGameVersion "Java 17"
relations {
requiredDependency "fabric-api"
requiredDependency "architectury-api"
requiredDependency "forge-config-api-port-fabric"
}
mainArtifact(remapJar)
afterEvaluate {
uploadTask.dependsOn(remapJar)
}
}
options {
forgeGradleIntegration = false
}
}

modrinth {
token = System.getenv("MODRINTH_API_KEY") ?: ""
projectId = rootProject.modrinth_project_id
changelog = System.getenv("CHANGELOG") ?: "Changelog not available."
versionNumber = "MC${rootProject.minecraft_version}-${project.name}-${rootProject.semver}"
versionName = "${mod_id}-${project.version}"
versionType = "release"
uploadFile = remapJar
gameVersions = [rootProject.minecraft_version]
loaders = ["fabric"]
dependencies {
required.project "fabric-api"
required.project "architectury-api"
required.project "forge-config-api-port"
}
}
15 changes: 13 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"tis3d.mixins.json"
],
"license": "MIT",

"environment": "*",
"entrypoints": {
"main": [
Expand All @@ -35,7 +34,7 @@
]
},
"depends": {
"fabric": ">=0.66.0",
"fabric-api": ">=0.66.0",
"forgeconfigapiport": ">=4.2.6",
"architectury": ">=6.4",
"minecraft": ">=1.19.2",
Expand All @@ -44,5 +43,17 @@
},
"recommends": {
"tooltipfix": "*"
},
"custom": {
"mc-publish": {
"modrinth": "L23x7zL8",
"curseforge": 238603,
"dependencies": [
"fabric-api@>=0.66.0(required){modrinth:P7dR8mSH}{curseforge:306612}",
"forgeconfigapiport@>=4.2.6(required){modrinth:ohNO6lps}{curseforge:547434}",
"architectury@>=6.4(required){modrinth:lhGA9TYQ}{curseforge:419699}",
"markdown_manual@>=1.2.3(required){modrinth:nPQ9xkPg}{curseforge:502485}"
]
}
}
}
Loading

0 comments on commit 3476f81

Please sign in to comment.