Skip to content

Commit

Permalink
feat: the packages is back!
Browse files Browse the repository at this point in the history
  • Loading branch information
DuoDuoJuZi committed Jan 2, 2025
1 parent 193454f commit a2a8533
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
- name: Get Repository Name
uses: MariachiBear/[email protected]

# - name: Publish to GitHub Packages
# run: ./gradlew publish -PisGitHubActions=true
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GITHUB_USERNAME: ${{ github.actor }}
- name: Publish to GitHub Packages
run: ./gradlew publish -PisGitHubActions=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}

- uses: actions/[email protected]
with:
Expand Down
27 changes: 19 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ subprojects {
relocate("io.github.retrooper.packetevents", "io.fairyproject.libs.packetevents")
relocate("io.fairyproject.bukkit.menu", "${properties("package")}.fairy.menu")
archiveClassifier.set("plugin")

}

// Configure sourcesJar task
Expand All @@ -114,28 +115,38 @@ subprojects {
tasks.register("allJar") {
dependsOn("shadowJar", "sourcesJar", "javadocJar")
}

}

publishing {
if (isGitHubActions) {
publications {
modules.forEach { module ->
create<MavenPublication>("shadow-${module.capitalize()}") {
project.extensions.configure<com.github.jengelman.gradle.plugins.shadow.ShadowExtension>() {
component(this@create)
artifact(tasks.named<ShadowJar>("shadowJar").get().source)
groupId = group.toString()
artifactId = "$module"
version = "${properties("version")}-${LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd-MM-yy-hhmmss"))}"
}
val shadowJarTask = project(":$module").tasks.named<ShadowJar>("shadowJar")
artifact(shadowJarTask.get().archiveFile.get())

groupId = group.toString()
artifactId = "$module"
version = "${properties("version")}-${LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd-MM-yy-hhmmss"))}"
}
}
// modules.forEach { module ->
// create<MavenPublication>("shadow-${module.capitalize()}") {
// project.extensions.configure<com.github.jengelman.gradle.plugins.shadow.ShadowExtension>() {
// from(tasks.named<ShadowJar>("shadowJar").get().archiveFile.get)
// groupId = group.toString()
// artifactId = "$module"
// version = "${properties("version")}-${LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd-MM-yy-hhmmss"))}"
// }
// }
// }
}

// GitHub Packages
repositories {
maven {
url = uri("https://maven.pkg.github.com/DuoDuoJuZi/Legacy")
url = uri("https://github.com/LegacyLands/legacy-lands-library")
credentials {
username = project.findProperty("githubUsername")?.toString() ?: System.getenv("GITHUB_USERNAME")?.toString() ?: error("GitHub username is missing")
password = project.findProperty("githubToken")?.toString() ?: System.getenv("GITHUB_TOKEN")?.toString() ?: error("GitHub token is missing")
Expand Down

0 comments on commit a2a8533

Please sign in to comment.