Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven publish from Gradle #658

Merged
merged 18 commits into from
Jun 23, 2024
Merged
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: ./gradlew clean shadowJar

- name: Stage jar
run: mkdir staging && cp Movecraft/build/libs/Movecraft.jar staging && mv staging/Movecraft.jar staging/Movecraft_$GITHUB_SHA.jar
run: mkdir staging && cp Movecraft/build/libs/Movecraft-all.jar staging && mv staging/Movecraft-all.jar staging/Movecraft_$GITHUB_SHA.jar
- name: Upload jar
uses: actions/upload-artifact@v4
with:
Expand Down
127 changes: 12 additions & 115 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,132 +6,29 @@ on:
types: [created, prereleased]

jobs:
# Build 1.18.2 NMS
v1_18:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17 # 1.18.2 can only be built with Java 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Cache 1.18.2 Maven package
id: cacheCaves
uses: actions/cache@v3
with:
path: |
~/.m2/repository/org/spigotmc/spigot/1.18.2-R0.1-SNAPSHOT/
~/.m2/repository/org/spigotmc/spigot-parent/
~/.m2/repository/org/spigotmc/minecraft-server/
key: ${{ runner.os }}-v1_18
restore-keys: ${{ runner.os }}-v1_18
- name: Cache Maven packages
id: cacheMain
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-v1_18
restore-keys: ${{ runner.os }}-m2-v1_18

- name: Setup BuildTools
run: mkdir BuildTools && wget -O BuildTools/BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
- name: Check 1.18.2 Spigot
id: caves
run: test -f ~/.m2/repository/org/spigotmc/spigot/1.18.2-R0.1-SNAPSHOT/spigot-1.18.2-R0.1-SNAPSHOT.jar && echo "sucess=true" >> $GITHUB_OUTPUT || echo "sucess=false" >> $GITHUB_OUTPUT
- name: Check 1.18.2 Spigot (Mojang)
id: cavesMojang
run: test -f ~/.m2/repository/org/spigotmc/spigot/1.18.2-R0.1-SNAPSHOT/spigot-1.18.2-R0.1-SNAPSHOT-remapped-mojang.jar && echo "sucess=true" >> $GITHUB_OUTPUT || echo "sucess=false" >> $GITHUB_OUTPUT
- name: Check 1.18.2 Spigot (Obf)
id: cavesObf
run: test -f ~/.m2/repository/org/spigotmc/spigot/1.18.2-R0.1-SNAPSHOT/spigot-1.18.2-R0.1-SNAPSHOT-remapped-obf.jar && echo "sucess=true" >> $GITHUB_OUTPUT || echo "sucess=false" >> $GITHUB_OUTPUT
- name: Build 1.18.2
if: steps.caves.outputs.sucess != 'true' || steps.cavesMojang.outputs.sucess != 'true' || steps.cavesObf.outputs.sucess != 'true'
run: cd BuildTools && java -jar BuildTools.jar --rev 1.18.2 --remapped

# Build 1.20.6 NMS
v1_20:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 21 # 1.20.6 can only be built with Java 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- name: Cache 1.20.6 Maven package
id: cacheWild_r2
uses: actions/cache@v3
with:
path: |
~/.m2/repository/org/spigotmc/spigot/1.20.6-R0.1-SNAPSHOT/
~/.m2/repository/org/spigotmc/spigot-parent/
~/.m2/repository/org/spigotmc/minecraft-server/
key: ${{ runner.os }}-v1_20
restore-keys: ${{ runner.os }}-v1_20
- name: Cache Maven packages
id: cacheMain
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-v1_20
restore-keys: ${{ runner.os }}-m2-v1_20

- name: Setup BuildTools
run: mkdir BuildTools && wget -O BuildTools/BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
- name: Check 1.20.6 Spigot
id: wild
run: test -f ~/.m2/repository/org/spigotmc/spigot/1.20.6-R0.1-SNAPSHOT/spigot-1.20.6-R0.1-SNAPSHOT.jar && echo "sucess=true" >> $GITHUB_OUTPUT || echo "sucess=false" >> $GITHUB_OUTPUT
- name: Check 1.20.6 Spigot (Mojang)
id: wildMojang
run: test -f ~/.m2/repository/org/spigotmc/spigot/1.20.6-R0.1-SNAPSHOT/spigot-1.20.6-R0.1-SNAPSHOT-remapped-mojang.jar && echo "sucess=true" >> $GITHUB_OUTPUT || echo "sucess=false" >> $GITHUB_OUTPUT
- name: Check 1.20.6 Spigot (Obf)
id: wildObf
run: test -f ~/.m2/repository/org/spigotmc/spigot/1.20.6-R0.1-SNAPSHOT/spigot-1.20.6-R0.1-SNAPSHOT-remapped-obf.jar && echo "sucess=true" >> $GITHUB_OUTPUT || echo "sucess=false" >> $GITHUB_OUTPUT
- name: Build 1.20.6
if: steps.wild.outputs.sucess != 'true' || steps.wildMojang.outputs.sucess != 'true' || steps.wildObf.outputs.sucess != 'true'
run: cd BuildTools && java -jar BuildTools.jar --rev 1.20.6 --remapped

# Build Movecraft
build:
runs-on: ubuntu-latest
needs: [v1_18, v1_20]
permissions:
contents: read
packages: write

steps:
- name: Checkout Movecraft
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2
restore-keys: ${{ runner.os }}-m2
- name: Cache 1.18.2 Maven package
uses: actions/cache@v3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
path: |
~/.m2/repository/org/spigotmc/spigot/1.18.2-R0.1-SNAPSHOT/
~/.m2/repository/org/spigotmc/spigot-parent/
~/.m2/repository/org/spigotmc/minecraft-server/
key: ${{ runner.os }}-v1_18
restore-keys: ${{ runner.os }}-v1_18
- name: Cache 1.20.6 Maven package
uses: actions/cache@v3
with:
path: |
~/.m2/repository/org/spigotmc/spigot/1.20.6-R0.1-SNAPSHOT/
~/.m2/repository/org/spigotmc/spigot-parent/
~/.m2/repository/org/spigotmc/minecraft-server/
key: ${{ runner.os }}-v1_20
restore-keys: ${{ runner.os }}-v1_20

- name: Build with Maven
run: mvn -T 1C -B package --file pom.xml
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"

- name: Publish package
run: mvn --batch-mode deploy
- name: Build and publish package with Gradle
run: ./gradlew clean shadowJar publish --parallel
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 24 additions & 1 deletion Movecraft/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("buildlogic.java-conventions")
id("io.github.goooler.shadow") version "8.1.7"
`maven-publish`
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
Expand All @@ -14,7 +15,7 @@ dependencies {

tasks.shadowJar {
archiveBaseName.set("Movecraft")
archiveClassifier.set("")
archiveClassifier.set("all")
archiveVersion.set("")

dependencies {
Expand All @@ -33,4 +34,26 @@ tasks.processResources {
}
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "net.countercraft"
artifactId = "movecraft"
version = "${project.version}"

artifact(tasks["shadowJar"])
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/apdevteam/movecraft")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

description = "Movecraft"
40 changes: 5 additions & 35 deletions buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,47 +1,17 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
`java-library`
`maven-publish`
}

repositories {
mavenLocal()
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}

maven {
url = uri("https://maven.pkg.github.com/APDevTeam/Movecraft")
}

maven {
url = uri("https://hub.spigotmc.org/nexus/content/groups/public/")
}

maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}

maven {
url = uri("https://repo.dmulloy2.net/nexus/repository/public/")
}

maven {
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven("https://repo.maven.apache.org/maven2/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://repo.dmulloy2.net/nexus/repository/public/")
maven("https://repo.papermc.io/repository/maven-public/")
}

group = "net.countercraft"
version = "8.0.0_beta-3"

publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
}
}
version = "8.0.0_beta-3_gradle"

tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
Expand Down