Skip to content

Commit

Permalink
plugin woho
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Jul 6, 2024
1 parent 07d9eb7 commit 32f7e95
Show file tree
Hide file tree
Showing 18 changed files with 1,214 additions and 201 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish
on:
push:
release:
types: [ published ]
jobs:
build:
runs-on: ubuntu-latest
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
LAVALINK_MAVEN_USERNAME: ${{ secrets.LAVALINK_MAVEN_USERNAME }}
LAVALINK_MAVEN_PASSWORD: ${{ secrets.LAVALINK_MAVEN_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
cache: gradle

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Build and Publish
run: ./gradlew build publish --no-daemon -PMAVEN_USERNAME=$MAVEN_USERNAME -PMAVEN_PASSWORD=$MAVEN_PASSWORD -PLAVALINK_MAVEN_USERNAME=$LAVALINK_MAVEN_USERNAME -PLAVALINK_MAVEN_PASSWORD=$LAVALINK_MAVEN_PASSWORD

- name: Upload main Artifact
uses: actions/upload-artifact@v3
with:
name: LavaQueue.jar
path: main/build/libs/lavaqueue-*.jar

- name: Upload plugin Artifact
uses: actions/upload-artifact@v3
with:
name: LavaQueue-Plugin.jar
path: plugin/build/libs/lavaqueue-plugin-*.jar

release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download main Artifact
uses: actions/download-artifact@v3
with:
name: LavaQueue.jar

- name: Download plugin Artifact
uses: actions/download-artifact@v3
with:
name: LavaQueue-Plugin.jar

- name: Upload Artifacts to GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: lavaqueue-*.jar
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
.gradle/
build/
application.yml
logs/
402 changes: 201 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import java.io.ByteArrayOutputStream

plugins {
`maven-publish`
id("org.jetbrains.kotlin.jvm") version "1.9.0" apply false
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.0" apply false
}

val (gitVersion, release) = versionFromGit()
logger.lifecycle("Version: $gitVersion (release: $release)")

allprojects {
group = "com.github.topi314.lavaqueue"

version = gitVersion

repositories {
mavenLocal()
mavenCentral()
maven("https://maven.arbjerg.dev/releases")
maven("https://maven.arbjerg.dev/snapshots")
maven("https://jitpack.io")
jcenter()
}
}

val isMavenDefined = findProperty("MAVEN_USERNAME") != null && findProperty("MAVEN_PASSWORD") != null

subprojects {
apply<JavaPlugin>()
apply<MavenPublishPlugin>()

configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}


configure<PublishingExtension> {
if (findProperty("MAVEN_PASSWORD") != null && findProperty("MAVEN_USERNAME") != null) {
repositories {
val snapshots = "https://maven.lavalink.dev/snapshots"
val releases = "https://maven.lavalink.dev/releases"

maven(if (release) releases else snapshots) {
credentials {
password = findProperty("MAVEN_PASSWORD") as String?
username = findProperty("MAVEN_USERNAME") as String?
}
}
}
} else {
logger.lifecycle("Not publishing to maven.lavalink.dev because credentials are not set")
}
}
}

fun versionFromGit(): Pair<String, Boolean> {
var versionStr = ByteArrayOutputStream()
var result = exec {
standardOutput = versionStr
isIgnoreExitValue = true
commandLine = listOf("git", "describe", "--exact-match", "--tags")
}
if (result.exitValue == 0) {
return Pair(versionStr.toString().trim(), false)
}

versionStr = ByteArrayOutputStream()
result = exec {
standardOutput = versionStr
isIgnoreExitValue = true
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
}
if (result.exitValue != 0) {
throw GradleException("Failed to get git version")
}

return Pair(versionStr.toString().trim(), true)
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 32f7e95

Please sign in to comment.