Skip to content

Commit

Permalink
Update CI and build for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerS1066 committed Jul 5, 2024
1 parent 3ec607b commit a52da21
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 62 deletions.
62 changes: 24 additions & 38 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,58 @@
name: Java CI
name: Gradle CI

on:
workflow_dispatch:
push:
pull_request:
release:
types: [created, prereleased]

jobs:
# Build AP-Turrets
build:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write

steps:
- name: Checkout AP-Turrets
uses: actions/checkout@v4
with:
path: AP-Turrets
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Checkout Movecraft-Combat
uses: actions/checkout@v3
with:
repository: 'APDevTeam/Movecraft-Combat'
path: Movecraft-Combat
ref: 'main'
- name: Checkout Movecraft-WorldGuard
uses: actions/checkout@v3
with:
repository: 'APDevTeam/Movecraft-WorldGuard'
path: Movecraft-WorldGuard
ref: 'main'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"
- name: Cache Maven packages
id: cacheMain
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2
restore-keys: ${{ runner.os }}-m2

# Build Movecraft-Combat
- name: Build Movecraft-Combat
run: mvn -B package -T 1C --file Movecraft-Combat/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Gradle
run: ./gradlew clean reobfJar --parallel

# Build Movecraft-WorldGuard
- name: Build Movecraft-WorldGuard
run: mvn -B package -T 1C --file Movecraft-WorldGuard/pom.xml
- name: Publish to GitHub Packages
if: ${{ github.event_name == 'release' }}
run: ./gradlew publish --parallel
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build AP-Turrets
run: cd AP-Turrets && ./gradlew clean build

- name: Stage jar
run: mkdir staging && cp AP-Turrets/build/libs/AP-Turrets.jar staging && mv staging/AP-Turrets.jar staging/AP-Turrets_$GITHUB_SHA.jar
- name: Upload jar
- name: Stage jar for Actions
if: ${{ github.event_name != 'release' }}
run: mkdir staging && cp build/libs/AP-Turrets.jar staging && mv staging/AP-Turrets.jar staging/AP-Turrets_$GITHUB_SHA.jar
- name: Upload jar to Actions
if: ${{ github.event_name != 'release' }}
uses: actions/upload-artifact@v4
with:
name: AP-Turrets_Dev-Build
path: staging/AP-Turrets_*.jar

- name: Stage jar for Release
if: ${{ github.event_name == 'release' }}
run: mkdir staging && cp build/libs/AP-Turrets.jar staging && mv staging/AP-Turrets.jar staging/AP-Turrets_${{ github.event.release.tag_name }}.jar
- name: Upload jar to Release
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@v2
with:
files: staging/AP-Turrets_${{ github.event.release.tag_name }}.jar
54 changes: 30 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,27 @@ plugins {
repositories {
gradlePluginPortal()
mavenLocal()
githubPackage("apdevteam/movecraft")
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
maven {
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
maven {
url = uri("https://maven.enginehub.org/repo/")
}
maven {
url = uri("https://jitpack.io")
}
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven { githubPackage("apdevteam/movecraft")(this) }
maven { githubPackage("apdevteam/movecraft-worldguard")(this) }
maven("https://jitpack.io")
}

dependencies {
api("org.jetbrains:annotations-java5:24.1.0")
paperweight.paperDevBundle("1.18.2-R0.1-SNAPSHOT")
compileOnly("net.countercraft:movecraft:+")
compileOnly(files("../Movecraft-WorldGuard/target/Movecraft-WorldGuard.jar"))
compileOnly("net.countercraft.movecraft.worldguard:movecraft-worldguard:+")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.7")
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1")
}

group = "snowleapord.github.com"
version = "3.0.0_beta-2"
group = "com.snowleopard"
version = "3.0.0_beta-2_gradle"
description = "APTurrets"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

tasks.assemble {
dependsOn(tasks.reobfJar)
}

tasks.reobfJar {
outputJar = layout.buildDirectory.file("libs/AP-Turrets.jar")
}
Expand All @@ -55,3 +39,25 @@ tasks.processResources {
expand(mapOf("projectVersion" to project.version))
}
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "com.snowleopard"
artifactId = "ap-turrets"
version = "${project.version}"

artifact(tasks.reobfJar)
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/apdevteam/ap-turrets")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

0 comments on commit a52da21

Please sign in to comment.