mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-04-19 21:16:30 +02:00
Add GH actions Maven publishing, improve buildscript
This commit is contained in:
parent
66bc4c3e29
commit
fcf249166c
33
.github/workflows/release.yml
vendored
Normal file
33
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
name: Java Gradle Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v\d+.\d+.\d+'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Set up JDK 8
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
distribution: 'temurin'
|
||||||
|
cache: gradle
|
||||||
|
- name: Publish with Gradle
|
||||||
|
run: ./gradlew publish
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ Secrets.GITHUB_TOKEN }}
|
||||||
|
BUNNYCDN_TOKEN: ${{ Secrets.BUNNYCDN_TOKEN }}
|
||||||
|
RELEASE: true
|
||||||
|
- name: Cleanup Gradle Cache
|
||||||
|
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
|
||||||
|
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
|
||||||
|
run: |
|
||||||
|
rm -f ~/.gradle/caches/modules-2/modules-2.lock
|
||||||
|
rm -f ~/.gradle/caches/modules-2/gc.properties
|
29
.github/workflows/snapshot.yml
vendored
Normal file
29
.github/workflows/snapshot.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: Java Gradle Snapshot
|
||||||
|
|
||||||
|
on: ["push", "pull_request"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Set up JDK 8
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
distribution: 'temurin'
|
||||||
|
cache: gradle
|
||||||
|
- name: Publish with Gradle
|
||||||
|
run: ./gradlew publish
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ Secrets.GITHUB_TOKEN }}
|
||||||
|
BUNNYCDN_TOKEN: ${{ Secrets.BUNNYCDN_TOKEN }}
|
||||||
|
- name: Cleanup Gradle Cache
|
||||||
|
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
|
||||||
|
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
|
||||||
|
run: |
|
||||||
|
rm -f ~/.gradle/caches/modules-2/modules-2.lock
|
||||||
|
rm -f ~/.gradle/caches/modules-2/gc.properties
|
@ -22,6 +22,15 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val r8 by configurations.creating
|
val r8 by configurations.creating
|
||||||
|
val shrinkJarOutput by configurations.creating {
|
||||||
|
isCanBeResolved = false
|
||||||
|
isCanBeConsumed = true
|
||||||
|
|
||||||
|
attributes {
|
||||||
|
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.JAVA_RUNTIME))
|
||||||
|
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling::class.java, Bundling.EMBEDDED))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("commons-cli:commons-cli:1.5.0")
|
implementation("commons-cli:commons-cli:1.5.0")
|
||||||
@ -35,7 +44,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClassName = "link.infra.packwiz.installer.RequiresBootstrap"
|
mainClass.set("link.infra.packwiz.installer.RequiresBootstrap")
|
||||||
}
|
}
|
||||||
|
|
||||||
val gitVersion: groovy.lang.Closure<*> by extra
|
val gitVersion: groovy.lang.Closure<*> by extra
|
||||||
@ -70,9 +79,11 @@ tasks.shadowJar {
|
|||||||
exclude("META-INF/NOTICE.txt")
|
exclude("META-INF/NOTICE.txt")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<JavaExec>("shrinkJar") {
|
val shrinkJar by tasks.registering(JavaExec::class) {
|
||||||
val rules = file("src/main/proguard.txt")
|
val rules = file("src/main/proguard.txt")
|
||||||
val r8File = tasks.shadowJar.get().archiveFile.get().asFile.run { resolveSibling(name.removeSuffix(".jar") + "-shrink.jar") }
|
val r8File = base.libsDirectory.file(provider {
|
||||||
|
base.archivesName.get() + "-" + project.version + "-all-shrink.jar"
|
||||||
|
})
|
||||||
dependsOn(configurations.named("runtimeClasspath"))
|
dependsOn(configurations.named("runtimeClasspath"))
|
||||||
inputs.files(tasks.shadowJar, rules)
|
inputs.files(tasks.shadowJar, rules)
|
||||||
outputs.file(r8File)
|
outputs.file(r8File)
|
||||||
@ -82,7 +93,7 @@ tasks.register<JavaExec>("shrinkJar") {
|
|||||||
args = mutableListOf(
|
args = mutableListOf(
|
||||||
"--release",
|
"--release",
|
||||||
"--classfile",
|
"--classfile",
|
||||||
"--output", r8File.toString(),
|
"--output", r8File.get().toString(),
|
||||||
"--pg-conf", rules.toString(),
|
"--pg-conf", rules.toString(),
|
||||||
"--lib", System.getProperty("java.home"),
|
"--lib", System.getProperty("java.home"),
|
||||||
*(if (System.getProperty("java.version").startsWith("1.")) {
|
*(if (System.getProperty("java.version").startsWith("1.")) {
|
||||||
@ -93,48 +104,61 @@ tasks.register<JavaExec>("shrinkJar") {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
add("shrinkJarOutput", shrinkJar) {
|
||||||
|
classifier = "dist"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Used for vscode launch.json
|
// Used for vscode launch.json
|
||||||
tasks.register<Copy>("copyJar") {
|
val copyJar by tasks.registering(Copy::class) {
|
||||||
from(tasks.named("shrinkJar"))
|
from(shrinkJar)
|
||||||
rename("packwiz-installer-(.*)\\.jar", "packwiz-installer.jar")
|
rename("packwiz-installer-(.*)\\.jar", "packwiz-installer.jar")
|
||||||
into("build/libs/")
|
into(layout.buildDirectory.dir("dist"))
|
||||||
outputs.file("build/libs/packwiz-installer.jar")
|
outputs.file(layout.buildDirectory.dir("dist").map { file("packwiz-installer.jar") })
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.assemble {
|
tasks.build {
|
||||||
dependsOn("shrinkJar")
|
dependsOn(copyJar)
|
||||||
dependsOn("copyJar")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.hasProperty("github.token")) {
|
|
||||||
githubRelease {
|
githubRelease {
|
||||||
owner("comp500")
|
owner("comp500")
|
||||||
repo("packwiz-installer")
|
repo("packwiz-installer")
|
||||||
tagName("${project.version}")
|
tagName("${project.version}")
|
||||||
releaseName("Release ${project.version}")
|
releaseName("Release ${project.version}")
|
||||||
draft(true)
|
draft(true)
|
||||||
token(findProperty("github.token") as String? ?: "")
|
token(findProperty("github.token") as String?)
|
||||||
releaseAssets(tasks.jar.get().destinationDirectory.file("packwiz-installer.jar").get())
|
releaseAssets(copyJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.githubRelease {
|
tasks.githubRelease {
|
||||||
dependsOn(tasks.build)
|
dependsOn(copyJar)
|
||||||
}
|
enabled = project.hasProperty("github.token") && project.findProperty("release") == "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.compileKotlin {
|
tasks.compileKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xallow-result-return-type", "-Xopt-in=kotlin.io.path.ExperimentalPathApi", "-Xlambdas=indy")
|
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xallow-result-return-type", "-opt-in=kotlin.io.path.ExperimentalPathApi", "-Xlambdas=indy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks.compileTestKotlin {
|
tasks.compileTestKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xallow-result-return-type", "-Xopt-in=kotlin.io.path.ExperimentalPathApi", "-Xlambdas=indy")
|
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xallow-result-return-type", "-opt-in=kotlin.io.path.ExperimentalPathApi", "-Xlambdas=indy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val javaComponent = components["java"] as AdhocComponentWithVariants
|
||||||
|
javaComponent.addVariantsFromConfiguration(shrinkJarOutput) {
|
||||||
|
mapToMavenScope("runtime")
|
||||||
|
mapToOptional()
|
||||||
|
}
|
||||||
|
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
|
||||||
|
skip()
|
||||||
|
}
|
||||||
|
|
||||||
if (project.hasProperty("bunnycdn.token")) {
|
if (project.hasProperty("bunnycdn.token")) {
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
@ -147,7 +171,11 @@ if (project.hasProperty("bunnycdn.token")) {
|
|||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url = uri("https://storage.bunnycdn.com/comp-maven")
|
url = if (project.findProperty("release") == "true") {
|
||||||
|
uri("https://storage.bunnycdn.com/comp-maven/repository/release")
|
||||||
|
} else {
|
||||||
|
uri("https://storage.bunnycdn.com/comp-maven/repository/snapshot")
|
||||||
|
}
|
||||||
credentials(HttpHeaderCredentials::class) {
|
credentials(HttpHeaderCredentials::class) {
|
||||||
name = "AccessKey"
|
name = "AccessKey"
|
||||||
value = findProperty("bunnycdn.token") as String?
|
value = findProperty("bunnycdn.token") as String?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user