Skip to content

Commit

Permalink
Ci improvements (#4)
Browse files Browse the repository at this point in the history
* Combine publish into main CI

* Add auto-publishing to PaperMC Hangar
  • Loading branch information
TylerS1066 authored Jul 4, 2024
1 parent d0324bf commit c0e6491
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 59 deletions.
62 changes: 38 additions & 24 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
name: Java CI
name: Gradle CI

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

jobs:
# Build Movecraft-CoreProtect
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout Movecraft-CoreProtect
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- 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: Checkout Movecraft-CoreProtect
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- 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: Build with Gradle
run: ./gradlew clean build --parallel
- name: Build with Gradle
run: ./gradlew clean build --parallel

- name: Stage jar
run: mkdir staging && cp build/libs/Movecraft-CoreProtect.jar staging && mv staging/Movecraft-CoreProtect.jar staging/Movecraft-CoreProtect_$GITHUB_SHA.jar
- name: Upload jar
uses: actions/upload-artifact@v4
with:
name: Movecraft-CoreProtect_Dev-Build
path: staging/Movecraft-CoreProtect_*.jar
- name: Publish to GitHub Packages
run: ./gradlew publish --parallel
if: ${{ github.event_name == 'release' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to PaperMC Hangar
run: ./gradlew publishPluginPublicationToHangar --parallel
if: ${{ github.event_name == 'release' }}
env:
HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}

- name: Stage jar
run: mkdir staging && cp build/libs/Movecraft-CoreProtect.jar staging && mv staging/Movecraft-CoreProtect.jar staging/Movecraft-CoreProtect_$GITHUB_SHA.jar
- name: Upload jar
uses: actions/upload-artifact@v4
with:
name: Movecraft-CoreProtect_Dev-Build
path: staging/Movecraft-CoreProtect_*.jar
34 changes: 0 additions & 34 deletions .github/workflows/publish.yml

This file was deleted.

25 changes: 24 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
`java-library`
`maven-publish`
id("io.github.0ffz.github-packages") version "1.2.1"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
}

repositories {
Expand Down Expand Up @@ -29,7 +30,6 @@ tasks.jar {
archiveBaseName.set("Movecraft-CoreProtect")
archiveClassifier.set("")
archiveVersion.set("")

}

tasks.processResources {
Expand Down Expand Up @@ -60,3 +60,26 @@ publishing {
}
}
}

hangarPublish {
publications.register("plugin") {
version.set(project.version as String)
channel.set("Release")
id.set("Airship-Pirates/Movecraft-CoreProtect")
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
platforms {
register(io.papermc.hangarpublishplugin.model.Platforms.PAPER) {
jar.set(tasks.jar.flatMap { it.archiveFile })
platformVersions.set(listOf("1.18.2-1.21"))
dependencies {
hangar("Movecraft") {
required.set(true)
}
hangar("CoreProtect") {
required.set(true)
}
}
}
}
}
}

0 comments on commit c0e6491

Please sign in to comment.