Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Commit f182602

Browse files
authored
Merge pull request #20 from LabyMod/develop
Merge develop into master (and publish to OSSHR releases)
2 parents 81e879d + 13ee6ef commit f182602

File tree

4 files changed

+109
-8
lines changed

4 files changed

+109
-8
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ jobs:
9696
run: "./gradlew -PCI=true -PnativeBinaryExternalDir=native-binaries ultralight-java-lwjgl3-opengl:build"
9797
- name: Check license
9898
run: "./gradlew licenseCheck"
99-
# - name: Deploy to maven central
100-
# if: github.ref == 'refs/heads/master'
101-
# run: "./gradlew -PCI=true -PenableSigning -PnativeBinaryExternalDir=native-binaries :publish"
102-
# env:
103-
# SIGNING_KEY: ${{ secrets.signingKey }}
104-
# SIGNING_PASSWORD: ${{ secrets.signingPassword }}
99+
- name: Deploy to OSSHR
100+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop'
101+
run: "./gradlew -PCI=true -PenableSigning -PnativeBinaryExternalDir=native-binaries publish"
102+
env:
103+
SIGNING_KEY: ${{ secrets.signingKey }}
104+
SIGNING_PASSWORD: ${{ secrets.signingPassword }}
105+
OSSHR_USER: ${{ secrets.osshrUser }}
106+
OSSHR_PASSWORD: ${{ secrets.osshrPassword }}
105107
- name: Upload artifacts
106108
uses: actions/upload-artifact@v2
107109
with:

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.3.0

build.gradle

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,37 @@ plugins {
55
}
66

77
group 'com.labymedia'
8-
version '0.3.0'
8+
apply from: 'version.gradle'
99

1010
apply from: 'ci.gradle'
1111

12-
def getSigningProperty(String name) {
12+
static String getSigningProperty(String name) {
1313
return System.getenv("SIGNING_${name}")
1414
}
1515

16+
String getAuthenticationProperty(String propName, String envName) {
17+
return project.hasProperty(propName) ? project.properties.get(propName) : System.getenv(envName)
18+
}
19+
1620
ext.commonPublish = { Project currentProject, Closure config ->
1721
currentProject.publishing {
22+
repositories {
23+
def releaseRepo = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
24+
def snapshotRepo = "https://oss.sonatype.org/content/repositories/snapshots/"
25+
26+
if(!version.endsWith("-UNSTABLE")) {
27+
maven {
28+
url version.endsWith("-SNAPSHOT") ? snapshotRepo : releaseRepo
29+
name "OSS${version.endsWith("-SNAPSHOT") ? "Snapshots" : "Release"}HostingRepository"
30+
31+
credentials {
32+
username getAuthenticationProperty("osshrUser", "OSSHR_USER")
33+
password getAuthenticationProperty("osshrPassword", "OSSHR_PASSWORD")
34+
}
35+
}
36+
}
37+
}
38+
1839
publications {
1940
mavenJava(MavenPublication) {
2041
from currentProject.components.java

version.gradle

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import org.apache.tools.ant.taskdefs.condition.Os
2+
3+
def versionFromFile = file("VERSION").text.trim()
4+
5+
static String getGithubVar(String name) {
6+
return System.getenv("GITHUB_${name}")
7+
}
8+
9+
static boolean isWindows() {
10+
return Os.isFamily(Os.FAMILY_WINDOWS)
11+
}
12+
13+
File getGitExecutable() {
14+
String gitExe = isWindows() ? "git.exe" : "git"
15+
return System.getenv("PATH")?.split(File.pathSeparator)?.collect {file("${it}/${gitExe}") }?.find {it.canExecute() }
16+
}
17+
18+
String getBranchName() {
19+
File gitExe = getGitExecutable()
20+
21+
if (gitExe == null) {
22+
logger.warn("Git not found on path")
23+
return "unknown"
24+
}
25+
26+
return new ByteArrayOutputStream().withStream { out ->
27+
String githubActionsRef = getGithubVar("REF")
28+
if (githubActionsRef != null) {
29+
return githubActionsRef.trim().substring(11).replace('/', '_')
30+
}
31+
32+
exec {
33+
executable gitExe
34+
workingDir rootDir
35+
args "rev-parse", "--abbrev-ref", "HEAD"
36+
standardOutput out
37+
}
38+
39+
return out.toString("UTF-8").trim()
40+
}
41+
}
42+
43+
String getCommit() {
44+
File gitExe = getGitExecutable()
45+
46+
if (gitExe == null) {
47+
logger.warn("Git not found on path")
48+
return "unknown"
49+
}
50+
51+
return new ByteArrayOutputStream().withStream { out ->
52+
exec {
53+
executable gitExe
54+
workingDir rootDir
55+
args "rev-parse", "--short", "HEAD"
56+
standardOutput out
57+
}
58+
59+
return out.toString("UTF-8").trim()
60+
}
61+
}
62+
63+
64+
String branchName = getBranchName()
65+
switch(branchName) {
66+
case "master":
67+
version = versionFromFile
68+
break
69+
70+
case "develop":
71+
version = "${versionFromFile}-SNAPSHOT"
72+
break
73+
74+
default:
75+
version = "${versionFromFile}-${getCommit()}-UNSTABLE"
76+
break
77+
}

0 commit comments

Comments
 (0)