Skip to content

Commit 6d2371b

Browse files
committed
build: Switch to GH action deployment
1 parent 053a286 commit 6d2371b

File tree

4 files changed

+48
-54
lines changed

4 files changed

+48
-54
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @Brennian
1+
* @Brennian

.github/workflows/build.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,43 @@ on: ["pull_request", "push"]
44

55
jobs:
66
build:
7-
runs-on: "ubuntu-20.04"
7+
runs-on: "ubuntu-latest"
88
steps:
99
- name: "Checkout Repository"
1010
uses: "actions/[email protected]"
11-
- name: "Setup JDK 16"
12-
uses: "actions/[email protected]"
11+
- name : "Validate Gradle Wrapper"
12+
uses : "gradle/[email protected]"
13+
- name: "Setup Java"
14+
uses: "actions/[email protected]"
1315
with:
1416
distribution: "temurin"
15-
java-version: "16"
17+
java-version: "17"
1618
- name: "Clean Build"
1719
run: "./gradlew clean build"
20+
- name : "Archive Artifacts"
21+
uses : "actions/[email protected]"
22+
with :
23+
name : "HeadDatabase-API-SNAPSHOT"
24+
path : "build/libs/*.jar"
25+
- name: "Determine release status"
26+
if: "${{ runner.os == 'Linux' }}"
27+
run: |
28+
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then
29+
echo "STATUS=snapshot" >> $GITHUB_ENV
30+
else
31+
echo "STATUS=release" >> $GITHUB_ENV
32+
fi
33+
- name: "Publish Release"
34+
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main'}}"
35+
run: "./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository"
36+
env :
37+
ORG_GRADLE_PROJECT_sonatypeUsername : "${{ secrets.SONATYPE_USERNAME }}"
38+
ORG_GRADLE_PROJECT_sonatypePassword : "${{ secrets.SONATYPE_PASSWORD }}"
39+
ORG_GRADLE_PROJECT_signingKey : "${{ secrets.SIGNING_KEY }}"
40+
ORG_GRADLE_PROJECT_signingPassword : "${{ secrets.SIGNING_PASSWORD }}"
41+
- name : "Publish Snapshot"
42+
if : "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}"
43+
run : "./gradlew publishToSonatype"
44+
env :
45+
ORG_GRADLE_PROJECT_sonatypeUsername : "${{ secrets.SONATYPE_USERNAME }}"
46+
ORG_GRADLE_PROJECT_sonatypePassword : "${{ secrets.SONATYPE_PASSWORD }}"

.github/workflows/validate-gradle-wrapper.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

build.gradle.kts

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.cadixdev.gradle.licenser.LicenseExtension
2+
import java.net.URI
23

34
plugins {
45
java
@@ -7,43 +8,32 @@ plugins {
78
signing
89

910
id("org.cadixdev.licenser") version "0.6.1"
11+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
1012

1113
idea
1214
eclipse
1315
}
1416

1517
java {
16-
toolchain.languageVersion.set(JavaLanguageVersion.of(16))
17-
}
18-
19-
tasks.compileJava.configure {
20-
options.release.set(8)
18+
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
2119
}
2220

2321
configurations.all {
24-
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 16)
22+
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
2523
}
2624

2725
group = "com.arcaniax"
28-
version = "1.3.1"
29-
30-
var versuffix by extra("SNAPSHOT")
31-
version = if (!project.hasProperty("release")) {
32-
String.format("%s-%s", project.version, versuffix)
33-
} else {
34-
String.format(project.version as String)
35-
}
26+
version = "1.3.1-SNAPSHOT"
3627

3728
repositories {
38-
mavenCentral()
3929
maven {
4030
name = "PaperMC"
4131
url = uri("https://papermc.io/repo/repository/maven-public/")
4232
}
4333
}
4434

4535
dependencies {
46-
compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT")
36+
compileOnly("com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT")
4737
}
4838

4939
configure<LicenseExtension> {
@@ -82,6 +72,9 @@ java {
8272

8373
signing {
8474
if (!version.toString().endsWith("-SNAPSHOT")) {
75+
val signingKey: String? by project
76+
val signingPassword: String? by project
77+
useInMemoryPgpKeys(signingKey, signingPassword)
8578
signing.isRequired
8679
sign(publishing.publications)
8780
}
@@ -126,29 +119,13 @@ publishing {
126119
}
127120
}
128121
}
122+
}
129123

124+
nexusPublishing {
130125
repositories {
131-
mavenLocal()
132-
val nexusUsername: String? by project
133-
val nexusPassword: String? by project
134-
if (nexusUsername != null && nexusPassword != null) {
135-
maven {
136-
val releasesRepositoryUrl =
137-
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
138-
val snapshotRepositoryUrl =
139-
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
140-
url = uri(
141-
if (version.toString().endsWith("-SNAPSHOT")) snapshotRepositoryUrl
142-
else releasesRepositoryUrl
143-
)
144-
145-
credentials {
146-
username = nexusUsername
147-
password = nexusPassword
148-
}
149-
}
150-
} else {
151-
logger.warn("No nexus repository is added; nexusUsername or nexusPassword is null.")
126+
sonatype {
127+
nexusUrl.set(URI.create("https://s01.oss.sonatype.org/service/local/"))
128+
snapshotRepositoryUrl.set(URI.create("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
152129
}
153130
}
154131
}

0 commit comments

Comments
 (0)